This is a slightly different take on
Tomte's
concept, remembering that we only want it to catch
specific request lines. Though
pzbagel's
approach is also good, this one has the advantage of not needing the data in an array (you could read it directly from a file), and not requiring the following line(s) of interest to be at fixed offsets from the 'request' line. In
pzbagel's version you could read ahead if using a file, but that's a bit more messy as you need to check for EOF at each read. How you end up doing it will depend on further examination of your data, and some consideration of what else you might have to do with it later.
my $buf;
for my $line (@lines) {
if($line =~ /^request\((.+)$/ ) {
$buf = $1;
undef $buf if $buf =~ /BADSTRING/;
}elsif(defined $buf) {
print "$buf: ", (split ', ', $line)[1],"\n";
undef $buf;
}
}
--
I'd like to be able to assign to an luser