Hello Jennifer,

Tuesday, August 21, 2001, Jennifer Pan <[EMAIL PROTECTED]> wrote:

JP> I have a file :
JP> #myfile.txt
JP> a       b       c       d
JP> a       c       s       g
JP> g       o       y       g
JP> _END_

JP> I wrote a perl script to put each line into a list;

JP> #/usr/bin/perl -w
JP> open (FH, "myfile.txt") ;
JP> while ($LINE = <FH>) {
JP>         chomp $LINE;
JP>         push @list, $LINE;
JP> }
JP> close FH;

JP> print $_ for (@list);

JP> _END_

JP> I expect to get 
JP> a       b       c       da      c       s       gg      o       y
JP> g
JP> instead I got
JP> a       b       c       d
JP> a       c       s       g
JP> g       o       y       g

JP> why didn't chomp work??!!
chomp removes part of your string, defined in '$/' variable.

JP> any insight is appreciated
what is your environment?
you can get above result if, for example, you have created myfile.txt in
windows ($/=\r\n), tranfers myfile.txt to unix-like OS ($/=\n) in binary mode,
and then run your script in unix.

Best wishes,
 Maxim                            mailto:[EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to