寒假【perl语言学习脚本】5.1 5.2 5.3

寒假【perl语言学习脚本】5.1 5.2 5.3
寒假【perl语言学习脚本】5.1 5.2 5.3

#!/usr/bin/perl -w
use strict;
print reverse <>;
寒假【perl语言学习脚本】5.1 5.2 5.3
#!/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 = "; width=&lt;STDIN&gt;;print&quot;1234567890&quot;x(width = &lt;STDIN&gt;; print &quot;1234567890&quot; x (width/10);
foreach(1…9) { if(&lt;=(_ &lt;= (width%10)) { print KaTeX parse error: Expected 'EOF', got '}' at position 4: _; }̲ } say; foreach…
; }

寒假【perl语言学习脚本】5.1 5.2 5.3

#!/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代表字符串格式)字符串内插,设定的字段宽度 前面都是空格,右对齐
#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);