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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.