[CentOS] remove newlines / perl /concise example

Stephen Harris lists at spuddy.org
Thu Dec 30 22:03:11 UTC 2010


On Thu, Dec 30, 2010 at 04:57:46PM -0500, ken wrote:
> open(my $in, "<", "$infilename") or die "Can't open file

> while (<$in>)
> {
> # Neither of the two commands below works as expected.
> 	chomp;			# remove trailing newline.
> #	s/\n/ /;		# replace newline with space
> 	print $out $in;

What exactly do you think you're printing here????  $in is the filehandle,
not the content.  $_ is the content.

print $out $_;

-- 

rgds
Stephen



More information about the CentOS mailing list