[tpm] chomp problem
J. Bobby Lopez
jbl at jbldata.com
Fri Feb 4 13:41:18 PST 2011
Something like
my $line = $_;
$line =~ s/(?:\r\n|\n)$//;
print $line;
.. should also work.
On Fri, Feb 4, 2011 at 3:56 PM, Mark Fowle <mfowle at navicominc.com> wrote:
> line ends in windows tend to be \r\n.
> comp safely removes one line end character, as aposed to chop that removed
> one cjharacter from the end of a line.
> so chomp$_; chomp $_; is safe and will work on any computer OS.
>
>
>
>
> ------------------------------
> *From:* toronto-pm-bounces+mfowle=navicominc.com at pm.org [mailto:
> toronto-pm-bounces+mfowle <toronto-pm-bounces%2Bmfowle>=navicominc.com@
> pm.org] *On Behalf Of *Omid Gulban
> *Sent:* Friday, February 04, 2011 3:42 PM
> *To:* tpm at to.pm.org
> *Subject:* [tpm] chomp problem
>
> Hello All,
>
> I have a simple script shown below:
> on windows xp platform.
>
>
>
> use warnings;
> use strict;
>
> while (<DATA>) {
> chomp $_;
> print "$_";
> }
>
> __END__
> a
> b
> c
> d
> e
> f
> g
> h
>
>
> Why do I get an output that looks like this:
> a
> ab
> bc
> cd
> de
> ef
> fg
> ghh
>
> I expected to see:
> abcdefg
>
>
> Thanks
> O
>
>
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/toronto-pm/attachments/20110204/617eb8cf/attachment.html>
More information about the toronto-pm
mailing list