变量与输入

来源:互联网 发布:全套钓鱼工具淘宝 编辑:程序博客网 时间:2024/05/16 16:54
[root@mysql1 perl]# ./10.pl 
what is the radius? 0
the circumference of a circle of radius 0 is 0.
[root@mysql1 perl]# ./10.pl 
what is the radius? 1
the circumference of a circle of radius 1 is 6.283185308.
[root@mysql1 perl]# ./10.pl 
what is the radius? 2
the circumference of a circle of radius 2 is 12.566370616.
[root@mysql1 perl]# 
[root@mysql1 perl]# 
[root@mysql1 perl]# 
[root@mysql1 perl]# cat 10.pl 
#!/usr/bin/perl -w


$pi=3.141592654;
print "what is the radius? ";
chomp($radius=<STDIN>);
$circ=2 * $pi * $radius;
print "the circumference of a circle of radius $radius is $circ.\n";
0 0