突然发现csdn的代码直接复制粘贴会缺失$这个符号在开头
还自动放大和缩小一些字符,很难看阿
直接截图吧,有点难受这样,看着不太对
############################################
#ex2-1.pl
#!/usr/bin/perl
use warnings;
$pi=3.141592654;
c
i
r
c
=
2
∗
circ=2*
circ=2∗pi*12.5;
print “the circumference of a circle of radius 12.5 is $circ.\n”;
############################################
#ex2-2.pl
#!/usr/bin/perl
use warnings;
print “what is the radius?”;
chomp($radius=);
$pi=3.141592654;
c
i
r
c
=
2
∗
circ=2*
circ=2∗pi*$radius;
print “the circumference of a circle of radius 12.5 is $circ.\n”;
############################################
#ex2-3.pl
#!/usr/bin/perl
use warnings;
print “what is the radius?”;
chomp($radius=);
$pi=3.141592654;
c
i
r
c
=
2
∗
circ=2*
circ=2∗pi*
r
a
d
i
u
s
;
i
f
(
radius; if(
radius;if(radius<0){
$circ=0;
}
print “the circumference of a circle of radius 12.5 is $circ.\n”;
############################################
#ex2-4.pl
#!/usr/bin/perl -w
print “enter first number:”;
chomp(
o
n
e
=
<
S
T
D
I
N
>
)
;
p
r
i
n
t
"
e
n
t
e
r
s
e
c
o
n
d
n
u
m
b
e
r
:
"
;
c
h
o
m
p
(
one=<STDIN>); print "enter second number:"; chomp(
one=<STDIN>);print"entersecondnumber:";chomp(two=);
r
e
s
u
l
t
=
result=
result=one*$two;
print “the result is $result.\n”;
############################################
#ex2-5.pl
#!/usr/bin/perl
use warnings;
print “enter a string:”;
s
t
r
=
<
S
T
D
I
N
>
;
p
r
i
n
t
"
e
n
t
e
r
a
n
u
m
b
e
r
o
f
t
i
m
e
s
:
"
;
c
h
o
m
p
(
str=<STDIN>; print "enter a number of times:"; chomp(
str=<STDIN>;print"enteranumberoftimes:";chomp(num=);
r
e
s
u
l
t
=
result=
result=str x KaTeX parse error: Expected 'EOF', got '\n' at position 27: …"the result is:\̲n̲result ";