mrityunjaynath has asked for the wisdom of the Perl Monks concerning the following question:
i am trying to write a code to find two pattern from one file sequentially. while the code is running but only i am getting one pattern and not the second pattern. when i have added a print statement in second loop it shows n time "into the second loop.." print for the same no of times as n as no of lines in the file but not the second pattern
opendir( my $synthdir,$target_dirsynth1) or die "Couldn't enter config + directory: $!\n"; print("\nSYNTHESIS INPUT FILES IN CURRENT DIRECTORY \n"); my $synthfilelist = glob "*.qsf"; print ("\n$synthfilelist \n"); my $originalquartus ; my $latestquartus ; my $readlineqo; my $readlineql ; open (my $OFILE,$synthfilelist) || die "couldnt open file: $!"; while ($readlineqo = <$OFILE>) { chomp $readlineqo; if ($readlineqo =~ /ORIGINAL_QUARTUS_VERSION/) { my @originalqarray = (split / +/ , $readlineqo); $originalquartus = $originalqarray[3]; print "\nthe original quartus $originalquartus\n"; } next if $readlineqo =~ /^ $/; } close($OFILE); open (my $LFILE,$synthfilelist) || die "couldnt open file: $!"; while ($readlineql = <$LFILE>) { chomp $readlineql; print "into the second loop $readlineql\n"; if ($readlineql =~ /LAST_QUARTUS_VERSION/) { my @latestqarray = (split / +/ , $readlineql); $latestquartus = $latestqarray[3]; print "\nthe latest quartus $latestquartus\n"; } next if $readlineql =~ /^ $/; } close($LFILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: searching two pattern sequentially from one file
by haukex (Archbishop) on May 13, 2016 at 09:45 UTC | |
by mrityunjaynath (Acolyte) on May 13, 2016 at 10:13 UTC | |
by haukex (Archbishop) on May 13, 2016 at 10:24 UTC | |
by mrityunjaynath (Acolyte) on May 13, 2016 at 11:24 UTC | |
by Corion (Patriarch) on May 13, 2016 at 11:44 UTC | |
| |
by haukex (Archbishop) on May 13, 2016 at 11:52 UTC |