Hi,
With the following Perl syntax, how to print the $_ value after the substitution?
s/(\s*|\n)//g foreach (<>);
If I use the below code, it produces some numeric output
print s/(\s*|\n)//g foreach (<>);
Hi,
With the following Perl syntax, how to print the $_ value after the substitution?
s/(\s*|\n)//g foreach (<>);
If I use the below code, it produces some numeric output
print s/(\s*|\n)//g foreach (<>);
In a oneliner:
perl -ne 's/(\s*|\n)//g;print $_' inputfile
Inside a multiline script:
perl -e 's/(\s*|\n)//g && print $_ foreach (<>);' < inputfile
perl -npe 's/(\s*|\n)//g;' inputfile
see perldoc perlun
for details of runtime flags