http://www.perlmonks.org?node_id=1028874

Cody Fendant has asked for the wisdom of the Perl Monks concerning the following question:

This is probably pretty simple, but I can't figure it out.

Say a website redirects me to example.com#foobar -- how do I get the #foobar part of the URI from the $mech object?

Replies are listed 'Best First'.
Re: How to get the fragment of a URI from WWW::Mechanize ?
by Corion (Patriarch) on Apr 16, 2013 at 11:28 UTC

    See URI. That part of the URI is named the "fragment".

      $ perl -MURI -e " print URI->new( shift )->fragment " http://a/#frag frag
Re: How to get the fragment of a URI from WWW::Mechanize ?
by Your Mother (Archbishop) on Apr 17, 2013 at 02:31 UTC

    I’ll go one more step. :P

    perl -MWWW::Mechanize -le '$m=WWW::Mechanize->new; $m->get("http://per +lmonks.org/#wut"); print $m->uri->fragment' wut
      example.com is official url for examples :)

        Next you'll tell me wut is actually spelled what and that the Gods will take me to small claims court to make me pay for this egregious waste of perlmonks bandwidth. You guys and your things and your stuff.