gizmo_mathboy has asked for the wisdom of the Perl Monks concerning the following question:
I recently had the opportunity to use brian d foy's post about how to use smart matching to test against many regexes. This is for a web crawler to check my work site for bad links (and to gather links for accessibility testing).
The smart matching doesn't seem to be working. Here is my test code:
use 5.010; my $string = q(foo); my @patterns = map { qr/$_/i } qw( foo ba(r|z) quux ); say @patterns; if( $string ~~ @patterns ) { say q(matched); }
...and this is the output:
gizmo@veterok: <bash>[~/dev/smart_match_regex_test] $ ./test.pl (?i-xsm:foo)(?i-xsm:ba(r|z))(?i-xsm:quux)
I am rather befuddled why this isn't working and what I might be doing wrong.
Thanks,
gizmo
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: string/array smart match regex failing me
by toolic (Bishop) on Jan 05, 2011 at 20:54 UTC | |
by hsinclai (Deacon) on Jan 05, 2011 at 21:10 UTC | |
by gizmo_mathboy (Friar) on Jan 06, 2011 at 01:37 UTC | |
Re: string/array smart match regex failing me
by ikegami (Patriarch) on Jan 05, 2011 at 22:50 UTC | |
Re: string/array smart match regex failing me
by JavaFan (Canon) on Jan 05, 2011 at 21:01 UTC | |
by ikegami (Patriarch) on Jan 05, 2011 at 22:48 UTC | |
by GrandFather (Saint) on Jan 05, 2011 at 23:55 UTC | |
Re: string/array smart match regex failing me
by oko1 (Deacon) on Jan 05, 2011 at 21:14 UTC |
Back to
Seekers of Perl Wisdom