learingperl01
MIS
Hello all,
hoping someone can help me or point me in the right direction. I have a script which I currently use but running into some problems with the output that I am getting back. I've created a new script to try to figure out the part that I am having problems which is below.
The script currently searches for a bunch of regex's then print out the name of the regex that matched. The problem that I currently have is that I want to match on the regex's between the boundary defined by the start of "*** followed by a random number/letters" and then search for the regex's within that boundary.
Or if I am going about this the wrong with my logic what would be the best way to do this?
Desired output
hoping someone can help me or point me in the right direction. I have a script which I currently use but running into some problems with the output that I am getting back. I've created a new script to try to figure out the part that I am having problems which is below.
The script currently searches for a bunch of regex's then print out the name of the regex that matched. The problem that I currently have is that I want to match on the regex's between the boundary defined by the start of "*** followed by a random number/letters" and then search for the regex's within that boundary.
Or if I am going about this the wrong with my logic what would be the best way to do this?
Code:
#!/usr/bin/perl
use strict;
use warnings;
while ( <DATA> ) {
my $boundary = $_;
if ( $boundary =~ /stringa|stringb|stringc/gm ) {
if ( $boundary = /stringa/g ) {
print "Found stringa\n";
}
if ( $boundary = /stringb/g ) {
print "Found stringb\n";
}
if ( $boundary = /stringc/g ) {
print "Found stringc\n";
}
}
}
__DATA__
*** 3993.2399
stringa
stringb
stringc
*** 3993.23384j
stringc
junk data
junk data
*** 3993.23993k
stringa
stringb
junk data
Desired output
Code:
Found the following strings within boundary *** 3993.2399
Found stringa
Found stringb
Found stringc
Found the following strings within boundary *** 3993.23384j
stringc
Found the following strings within boundary *** 3993.23993k
stringa
stringb