sandy105 has asked for the wisdom of the Perl Monks concerning the following question:
i have a script which just reads a file and depending upon a keyword i just write selected line to an output file
however i am not getting the expected output
use warnings; my @lines; my $mess; open(hanr,"splitin.pl")or die"error $!\n"; open hanw, ">", "output.csv" or die $!; @lines = <hanr>; foreach my $line (@lines) { chomp($line); $line =~ /^\$outcome /x or next; my $Length = -2; my $mess = substr $line , 10 ,$Length; print hanw "$mess , \n"; } close hanr; close hanw;
upon checking even after chomp i am getting lines such as these
if ( $prevseg ne "Iaw" ) { $outcome="alT - spi - Script $0 aborted. new Error Code: 022. ";
because of indentation the regex fails , but i am puzzled as to why chomp doesnt work ?? ; why it does'nt remove the white spaces
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Chomp not working
by Athanasius (Archbishop) on Sep 24, 2014 at 08:47 UTC | |
|
Re: Chomp not working (Path::Tiny lines spew)
by Anonymous Monk on Sep 24, 2014 at 09:15 UTC | |
|
Re: Chomp not working
by misterperl (Friar) on Sep 24, 2014 at 14:59 UTC | |
by sandy105 (Scribe) on Sep 25, 2014 at 10:13 UTC | |
|
Re: Chomp not working
by codiac (Beadle) on Sep 29, 2014 at 01:03 UTC |