I tried with the following code:
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
use HTML::TokeParser::Simple;
my $mech = WWW::Mechanize->new( stack_depth => 1, agent =>"Mozilla/5.0
+ (X11; U; Linux i68+6; en-US; rv:1.7) Gecko/20040918 Firefox/0.9.3 ")
+;
my $pic = "C:\/LV3.JPG";
$mech->cookie_jar( HTTP::Cookies->new(stack_depth => 1) );
$mech->get("http://tinypic.com");
if($mech->content() =~ /UPLOAD NOW/ ){
print "TinyPic loaded... ";
$mech->form_name("upload_form");
$mech->field('the_file' => $pic);
$mech->submit();
m{
<strong # match "<strong"
.*? # skip to the next
( # (start capturing)
http:// # "http://"
.*? # skip to the next
) # (stop capturing)
& # ampersand
}x
print $1;
}
and it returned a syntax error. I also tried with the other version you gave me here:
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
use HTML::TokeParser::Simple;
my $mech = WWW::Mechanize->new( stack_depth => 1, agent =>"Mozilla/5.0
+ (X11; U; Linux i68+6; en-US; rv:1.7) Gecko/20040918 Firefox/0.9.3 ")
+;
my $pic = "C:\/LV3.JPG";
$mech->cookie_jar( HTTP::Cookies->new(stack_depth => 1) );
$mech->get("http://tinypic.com");
if($mech->content() =~ /UPLOAD NOW/ ){
print "TinyPic loaded... ";
$mech->form_name("upload_form");
$mech->field('the_file' => $pic);
$mech->submit();
m{<strong.*?(http://.*?)&};
print $1;
}
This version didn't get a syntax error but also didn't output anything |