[tpm] chomp problem
Indy Singh
indy at indigostar.com
Fri Feb 4 20:26:48 PST 2011
Hello,
The scripts works as expected for me. There is no issue with line
endings. On Windows Perl automatically translats the input lines so
they terminate with a newline ('\n'). This works if the file is in
Windows format, or even if it is in Unix format. This works correctly
with several versions of Perl from 5.6.1 to 5.12.2.
Your problem is that your source file is corrupted in some way. It may
conain a mixture of incorrect lineending or there be be some invisible
space characters in it.
To view a hex dump of the file, type the command 'debug filename.pl'.
Then type 'd' and enter a few times.
To fix the file create a new text file with notepad and copy and paste
the text from your own email.
If you are still not sure, then send the file as an attachment, or post
a hex dump of the file. Let us know what version of Perl you are using.
Indy Singh
IndigoSTAR Software -- www.indigostar.com
----- Original Message -----
From: "Omid Gulban" <omid.gulban at sickkids.ca>
To: "Toronto Perl Mongers" <tpm at to.pm.org>
Sent: Friday, February 04, 2011 3:23 PM
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
> Omid
>
> This e-mail may contain confidential, personal and/or health
> information(information which may be subject to legal restrictions on
> use, retention and/or disclosure) for the sole use of the intended
> recipient. Any review or distribution by anyone other than the person
> for whom it was originally intended is strictly prohibited. If you
> have received this e-mail in error, please contact the sender and
> delete all copies.
> _______________________________________________
> toronto-pm mailing list
> toronto-pm at pm.org
> http://mail.pm.org/mailman/listinfo/toronto-pm
More information about the toronto-pm
mailing list