Re: remove newlines / perl /concise example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux