in reply to regex problem
What stevieb said. Handing someone a bunch of code and saying "This doesn't work. Please figure out how it should work and fix it" is not likely to be productive unless you also hand over a bunch of money.
That said, one note: In the regex
my @urls=$response_body =~ m{(http://b.thumbs.redditmedia.com/ ... }gi;
the sub-pattern b.thumbs.redditmedia.com has embedded . (dot) metacharacters that match anything (except a newline, unless the /s switch is asserted, which it isn't). Here's the effect:
Now try meta-quoting in some way, e.g.:c:\@Work\Perl\monks>perl -wMstrict -le "for my $str (qw(aXbXc a.b.c)) { printf qq{for '$str' }; print $str =~ m{ a.b.c }xms ? 'match' : 'NO match'; } " for 'aXbXc' match for 'a.b.c' match
c:\@Work\Perl\monks>perl -wMstrict -le "for my $str (qw(aXbXc a.b.c)) { printf qq{for '$str' }; print $str =~ m{ \Qa.b.c\E }xms ? 'match' : 'NO match'; } " for 'aXbXc' NO match for 'a.b.c' match
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex problem
by grasshopper!!! (Beadle) on Nov 04, 2015 at 21:28 UTC | |
by grasshopper!!! (Beadle) on Nov 05, 2015 at 00:18 UTC | |
by AnomalousMonk (Archbishop) on Nov 05, 2015 at 00:48 UTC |