I having trouble parsing links out of a web page source. The regexp picks up the beginning of one similar match and the second part of a similar match.I have used lookback's and lookforward's to no avail.The false match is the first match the rest are correct. Thanks in advance.
use strict; use warnings; use WWW::Curl::Easy; my $curl = WWW::Curl::Easy->new; $curl->setopt(CURLOPT_HEADER,1); $curl->setopt(CURLOPT_URL, 'http://www.reddit.com/r/wallpapers.rss'); my $response_body; $curl->setopt(CURLOPT_WRITEDATA,\$response_body); # Starts the actual request my $retcode = $curl->perform; # Looking at the results... if ($retcode == 0){ print("Transfer went ok\n\n"); my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE); # judge result and next action based on $response_code open(F ,">/home/philip/Desktop/reg-out.txt"); print F "$response_body\n\n"; close(F); my @urls=$response_body =~ m{(http://b.thumbs.redditmedia.com/(?!png) +(?<!png).+?(?!png)(?<!png)\.jpg)}gi; #print("Received response: $response_body\n\n"); print scalar @urls ."\n\n"; $" ="\n\n"; print "@urls\n"; #`feh --bg-seamless $urls[$number]`; } else { # Error code, type of error, error message print("An error happened: $retcode ".$curl->strerror($retcode)." ".$ +curl->errbuf."\n"); }
In reply to regex problem by grasshopper!!!
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |