P
perl Newbie
Hello ,
I am having trouble how to "match whole word only", the script I am
using here is
use warnings;
use strict;
my @lines=(
"l qa1;c=c(a0)'1'.or.c(a10)'2';&sort;&nz",
"n01 blah ... ;c=c(a9)'1'.and.c(a07)'1'",
"n01 blah ... ;c=c(a08)'1'.and.c(a11)'1'",
"*include q1.qin;kod=a05;axm=q4a4",
"*include q2.qin;pod=a06"
) ;
my @aval;
foreach my $l (@lines){
print "$l\n";
}
print "\n\n";
foreach my $l (@lines){
if ($l =~/a[0-9]+/) {
##print "$l\n";
my (@push_txt) = $l=~/(a[0-9]+)/g;
push @aval,@push_txt;
}
}
print "@aval\n";
With this I am getting all the values that qualifies condition a[0-9]+
including a1 from qa1 & a4 from q4a4.
How can I get match whole word values, in this case it should outputs
values a0 a10 a9 a07 a08 a11 a05 a06.
I am having trouble how to "match whole word only", the script I am
using here is
use warnings;
use strict;
my @lines=(
"l qa1;c=c(a0)'1'.or.c(a10)'2';&sort;&nz",
"n01 blah ... ;c=c(a9)'1'.and.c(a07)'1'",
"n01 blah ... ;c=c(a08)'1'.and.c(a11)'1'",
"*include q1.qin;kod=a05;axm=q4a4",
"*include q2.qin;pod=a06"
) ;
my @aval;
foreach my $l (@lines){
print "$l\n";
}
print "\n\n";
foreach my $l (@lines){
if ($l =~/a[0-9]+/) {
##print "$l\n";
my (@push_txt) = $l=~/(a[0-9]+)/g;
push @aval,@push_txt;
}
}
print "@aval\n";
With this I am getting all the values that qualifies condition a[0-9]+
including a1 from qa1 & a4 from q4a4.
How can I get match whole word values, in this case it should outputs
values a0 a10 a9 a07 a08 a11 a05 a06.