文字列を結合する演算子「.」
文字列の結合には「.」を使います。
str.pl
#!/usr/bin/perl $first = a; $second = b; $third = $first.$second; $home = $first." ".$second; print "$third\n"; print "$home\n";
実行してみる。
$chmod +x str.pl $./str.pl ab a b $
ちなみに.=という演算子もある。
strs.pl
#!/usr/bin/perl $strings = "a"; $strings .= "b"; $strings .= "c"; $strings .= "d"; $strings .= "e"; print "$strings\n"
実行してみる。
$chmod +x strs.pl $./strs.pl abcde $