U
usaims
I'm having a little problem with this example in the Perl Cookbook.
True if pattern BAD does not match, but pattern GOOD does:
/(?=(??!BAD).)*$)GOOD/s
My objective is to print only lines that have 'suspended' but not
'Data_services'. It is still printing lines with 'suspended' and
'Data_services' in the same line. So, ideally, this script should
print any lines. Correct me if I am wrong.
##############################
#!/usr/bin/perl
use strict;
use diagnostics;
use warnings;
my @stuff = <DATA>;
foreach my $foo(@stuff) {
if ($foo =~ /(?=(??!Data_services).)*$)suspended/s) {
print $foo;
}
}
close(DATA);
__DATA__
<Query id='Data_services.LSSI_Weekly.42' suspended='1' error='Loading
Data Only - cannot run query' wuid='W20070227-140132'
associatedName='libW20070227-140132.so'/>
<Query id='Data_services.SSNMapKeys.14' suspended='1' error='Loading
Data Only - cannot run query' wuid='W20070105-115230'
associatedName='libW20070105-114650.so'/>
<Query id='Data_services.WatercraftKeys.5' suspended='1'
error='Loading Data Only - cannot run query' wuid='W20070123-114242'
associatedName='libW20070123-114242.so'/>
True if pattern BAD does not match, but pattern GOOD does:
/(?=(??!BAD).)*$)GOOD/s
My objective is to print only lines that have 'suspended' but not
'Data_services'. It is still printing lines with 'suspended' and
'Data_services' in the same line. So, ideally, this script should
print any lines. Correct me if I am wrong.
##############################
#!/usr/bin/perl
use strict;
use diagnostics;
use warnings;
my @stuff = <DATA>;
foreach my $foo(@stuff) {
if ($foo =~ /(?=(??!Data_services).)*$)suspended/s) {
print $foo;
}
}
close(DATA);
__DATA__
<Query id='Data_services.LSSI_Weekly.42' suspended='1' error='Loading
Data Only - cannot run query' wuid='W20070227-140132'
associatedName='libW20070227-140132.so'/>
<Query id='Data_services.SSNMapKeys.14' suspended='1' error='Loading
Data Only - cannot run query' wuid='W20070105-115230'
associatedName='libW20070105-114650.so'/>
<Query id='Data_services.WatercraftKeys.5' suspended='1'
error='Loading Data Only - cannot run query' wuid='W20070123-114242'
associatedName='libW20070123-114242.so'/>