, $ , \n ( /m). (. perlre Perldoc. g .
Perl (.. Perl , ) , Perl.
, chomp, . g.
, Linux/Mac, Windows. \r, \n. , \r chomp. ,
:
open my $file_handle, "<:crlf", $file...
\r\n \n, Windows Linux/Mac. Linux/Mac, . - Windows ( !).
, chomp :
$cat file
line one
line two
line three
line four
$ perl -pe 'chomp;s/$/addthis::/g`
line oneaddthis::line twoaddthis::line threeaddthis::line fouraddthis::
Chomp \n, , . ...
$ perl -pe 'chomp;s/$/addthis/g;print "\n";
line oneaddthis
line twoaddthis
line threeaddthis
line fouraddthis
! .
- , 12 Perl Best Practices:
\A \z .
/m, ^ $ - . , , ^ $ Perl 1. , ? , , ? Perl , " " " ":\A \z ( A, z). "/ " , /m. "/ " , ^ $mean.
Conaway :
perl -pe 's/\z/addthis/mg' myfile.txt
, addthis :
$cat file
line one
line two
line three
line four
$ perl -pe `s/\z/addthis/mg` myfile.txt
line one
addthisline two
addthisline three
addthisline four
addthis
, . addthis !... \n .
. (, , . , , , , ).
, , Python.
1. , ^ $ Perl? , , I. Perl . , . ( : $, -, , .)