S
sravi
I have the following piece of code,
#-----------------------
my $sd = '(\d{8})\s+(\d\d:\d\d:\d\d)';
my $ed = '(\d{8}|-1)\s+(\d\d:\d\d:\d\d|-1)';
my $up_com = '^#?(\S+)\s*(\S+)\s*'."$startDateRegex\$";
my $regex = "([+#-]?)\s*$sd\\s+$ed\\s+(\\S+)\\s+(\\S+)\\s+(.+)";
while (<>) {
if (/$regex/o) {
my @line =
($1, $2, $3, $4, $5, $6, $7, $8);
# Process the data and print
}
elsif (/$up_com/o) {
my ($a,$b,$c) = ($2,$3,$4);
# Process the data and print
}
else {
print;
}
}
#-----------------------
I have two regex that can match the given line. Is it possible to
combine first and second regex into one regex and process the data
optimally?
#-----------------------
my $sd = '(\d{8})\s+(\d\d:\d\d:\d\d)';
my $ed = '(\d{8}|-1)\s+(\d\d:\d\d:\d\d|-1)';
my $up_com = '^#?(\S+)\s*(\S+)\s*'."$startDateRegex\$";
my $regex = "([+#-]?)\s*$sd\\s+$ed\\s+(\\S+)\\s+(\\S+)\\s+(.+)";
while (<>) {
if (/$regex/o) {
my @line =
($1, $2, $3, $4, $5, $6, $7, $8);
# Process the data and print
}
elsif (/$up_com/o) {
my ($a,$b,$c) = ($2,$3,$4);
# Process the data and print
}
else {
print;
}
}
#-----------------------
I have two regex that can match the given line. Is it possible to
combine first and second regex into one regex and process the data
optimally?