#!/usr/bin/perl -w
use strict;
print reverse <>;
#!/usr/bin/perl -w
use strict;
print “Enter some lines,then press ctrl-z:\n”;
chomp (my @lines=);#需要用my来创建新的私有数组
print “1234567890” x 4 ,"\n"; #标尺行
foreach my KaTeX parse error: Expected '}', got 'EOF' at end of input: …rintf "%20s\n",line;#字符串内插,设定的字段宽度 前面都是空格,右对齐
}
print “another way of using the default variable:\n”;
foreach (@lines){
printf “%20s\n”,KaTeX parse error: Expected 'EOF', got '}' at position 5: _; }̲ ![在这里插入图片描述](h…; }
print "The Width of the Rule Line Width = ";
w
i
d
t
h
=
<
S
T
D
I
N
>
;
p
r
i
n
t
"
1234567890
"
x
(
width = <STDIN>; print "1234567890" x (
width=<STDIN>;print"1234567890"x(width/10);
foreach(1…9) { if(
<
=
(
_ <= (
<=(width%10)) { print KaTeX parse error: Expected 'EOF', got '}' at position 4: _; }̲ } say; foreach…; }
#!/usr/bin/perl -w
use strict;
print “what column width would you like?”;
chomp (my KaTeX parse error: Expected 'EOF', got '\n' at position 60: …n press ctrl-z:\̲n̲"; chomp (my @l…width/10)*2) ,"\n";
foreach (@lines){
printf "%KaTeX parse error: Expected 'EOF', got '\n' at position 9: {width}s\̲n̲",_;#(%s代表字符串格式)字符串内插,设定的字段宽度 前面都是空格,右对齐
#
w
i
d
t
h
和
{width}和
width和width一样,花括号只是便于分隔,跟在shell中相同
}
print “1234567890” x ((KaTeX parse error: Expected 'EOF', got '\n' at position 16: width+9)/10) ,"\̲n̲"; #对x右边的操作数是取整…width,KaTeX parse error: Expected 'EOF', got '}' at position 5: _; }̲ #print (width/10);