M
Mintcake
The script at the end of this post produces the folllowing output...
Matching on 'plugh'
Contains the word plugh
Does not contain the word plugh
Matching on 'xyzzy'
Contains the word xyzzy
Matching on ''
1
I don't understand why 3rd call to gettd() does not produce any
matches.
#!/usr/bin/env perl
use strict;
use warnings;
my $tr = <<EOTR;
<tr>
<td>Contains the word plugh</td>
<td>Does not contain the word plugh</td>
<td>Contains the word xyzzy</td>
</tr>
EOTR
sub gettd {
my $regex = shift;
print "Matching on '$regex'\n";
for (grep /$regex/, $tr =~ /<td>(.*?)<\/td>/g) {
print " $_\n";
}
}
gettd('plugh');
gettd('xyzzy');
gettd('');
my $regex = '';
my $str = 'Any old string';
print $str =~ /$regex/, "\n";
Matching on 'plugh'
Contains the word plugh
Does not contain the word plugh
Matching on 'xyzzy'
Contains the word xyzzy
Matching on ''
1
I don't understand why 3rd call to gettd() does not produce any
matches.
#!/usr/bin/env perl
use strict;
use warnings;
my $tr = <<EOTR;
<tr>
<td>Contains the word plugh</td>
<td>Does not contain the word plugh</td>
<td>Contains the word xyzzy</td>
</tr>
EOTR
sub gettd {
my $regex = shift;
print "Matching on '$regex'\n";
for (grep /$regex/, $tr =~ /<td>(.*?)<\/td>/g) {
print " $_\n";
}
}
gettd('plugh');
gettd('xyzzy');
gettd('');
my $regex = '';
my $str = 'Any old string';
print $str =~ /$regex/, "\n";