N
Nene
I wrote a perl script that opens a file. I wrote a regex that
captures $1 $2 and prints it to output. What I want it to do which I
can't figure out is to print the next line (which has a regex that I
need to capture as well) under the line that has the the regex but I
can't figure it out so far. Any help will be greatly appreciated.
#!/usr/bin/perl -w
use strict;
use diagnostics;
open( FILE, $ARGV[0] ) || die "can't open file!";
my @TEST = <FILE>;
foreach my $current_line (@TEST) {
if ($current_line =~ /^\S+ (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) \S+
\S+/) {
print "$1 $2\n";
## But I also want to print a regex from the line underneath the
$current_line ###
}
}
captures $1 $2 and prints it to output. What I want it to do which I
can't figure out is to print the next line (which has a regex that I
need to capture as well) under the line that has the the regex but I
can't figure it out so far. Any help will be greatly appreciated.
#!/usr/bin/perl -w
use strict;
use diagnostics;
open( FILE, $ARGV[0] ) || die "can't open file!";
my @TEST = <FILE>;
foreach my $current_line (@TEST) {
if ($current_line =~ /^\S+ (\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}) \S+
\S+/) {
print "$1 $2\n";
## But I also want to print a regex from the line underneath the
$current_line ###
}
}