Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Processing .RES file

by arun_kom (Monk)
on Sep 30, 2009 at 14:55 UTC ( [id://798355]=note: print w/replies, xml ) Need Help??


in reply to Processing .RES file

Set a flag to true when your condition is met. Then you can execute the "last" statement if the flag is true.

Replies are listed 'Best First'.
Re^2: Processing .RES file
by raghvens (Novice) on Oct 01, 2009 at 04:31 UTC

    Hi Arun,

    I kept the flag when the condition is met, but still processes all lines instead of processing only the matched line.

    open (FH, "$ARGV[0]") or die "couldn't open .RES $! file"; @res=<FH>; close(FH); $flag=0; $ARGV[1]="$ARGV[1]_$ARGV[0].txt"; #open (RH, ">$ARGV[1]"); $count=0; $flag=0; foreach $line (@res) { if ($line =~ m/\-\-gnu\s/) { $flag=1; chomp($line); @new = split(" ",$line); foreach $n (@new) { if ($n !~ m/^$/) { #if ($n =~ m/^$/) { next; } if ($flag == 1) { if (($n =~ /^\-D(\w\_\=\d)*/) || ($n =~ /^\-U(\w\_\=\d)*/) && +($n !~/^\-I(\w\_\=\d)*/)) { $count++; chomp($n); print "\n$count $n"; #print RH "$count $n \n"; } } } } } $flag=0; #exit; } close (RH);

    Please suggest what mistake i have encountered? Thanks for your suggestions.... BR, Raghvens

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://798355]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-19 19:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found