Re: [問題]新手問題
※ 引述《shelling (shelling)》之銘言:
: 我也來練練 :p
: 1 #!/usr/bin/perl
: 2
: 3 use warnings;
: 4 use utf8;
: 5
: 6 sub main::puts {
: 7 if (@_) {
: 8 print @_;
: 9 }
: 10 print "\n";
: 11 }
: 12
: 13 sub line1 {
: 14 $item = shift;
: 15 "$item " x 10;
: 16 }
: 17
: 18 sub line2 {
: 19 $item = shift;
: 20 $length = " " x (length("$item ") * 9);
: 21 "$item ".$length."$item ";
: 22 }
: 23
: 24 puts "what is your favorite color?";
: 25 $input = <STDIN>;
: 26 chomp $input;
: 27
: 28 puts line1($input);
: 29 puts line2($input);
: 30 puts line2($input);
: 31 puts line1($input);
很喜歡shelling大用sub的方法來print
注意到你們都是用
$scalar = <STDIN>;
chomp $scalar;
請問這樣和
chomp($scalar = <>);
有沒有不一樣
sorry if this question is really stupid...
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.56.137.23
推
09/20 13:17, , 1F
09/20 13:17, 1F
討論串 (同標題文章)