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

In reply to Re^4: Pattern Matching Q? by 80degreez
in thread Pattern Matching Q? by 80degreez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.