Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Can't locate object method REDIRECTS via package "HTTP::Headers" at eval 19 line 1.

Can someone help me figure out what I need to do to fix this error in the code below?
#!/usr/bin/perl use warnings; use strict; use CGI qw/:simple/; use CGI::Carp qw(fatalsToBrowser); use lib "/home/content/68/7511668/html/DOMAIN-askageek/lib"; use WWW::Mechanize; print header; my $username = ''; my $password = ''; my $url_to_sign_on = ''; my $post_new = ''; my $mech = WWW::Mechanize->new(); $mech->get($url_to_sign_on); $mech->submit_form( form_name =>'loginform', fields => { user_login => $username, user_pass => $password, } ); ###### # get html for page after sign on ###### my $page_source1 = $mech->content; if ($page_source1 =~ m/dashboard/i) { print "Sign on successful.<br><br>"; } else { print "sign on failed.<br><br>"; exit; } ##### # load page to post new post ##### $mech->get($post_new); if ($post_new =~ m/log out/i) { print "Post_new page loaded successfully.<br><br>"; } else { print "Post_new page failed to load.<br><br>"; exit; } ##### # Fill out the post form ##### #<input type="hidden" id="_wpnonce" name="_wpnonce" value="35bb69e3ce" + /> #my @post_new = split(/\n/, $post_new); $post_new =~ m#name\=\"_wponce\"\s+value=\"([a-z][0-9]){10}\"#i; print "found $1"; exit; $mech->submit_form( form_name =>'post', fields => { _wpnonce => '', _wp_http_referer => '/wp-admin/post-new.php', parent_id => '0', user_ID => '1', action => 'editpost', originalaction => 'editpost', post_author => '1', post_type => 'post', original_post_status => 'auto-draft', referredby => 'http', _wp_original_http_referer => '_wp_original_http_referer', auto_draft => '1', post_ID => '', autosaveonce => '', 'meta-box-order-nonce' => '', } );

Replies are listed 'Best First'.
Re: Can't locate object method REDIRECTS in package HTTP::Headers
by GrandFather (Saint) on Mar 14, 2011 at 21:29 UTC

    Add:

    use HTTP::Headers;

    toward the top of your script.

    True laziness is hard work
      I tried adding that to the top of the code and it still says the exact same thing. I also went to the site the other person posted and I don't think that will help since I'm not using the product that page is outlining.

      Any other advice? Thank you!

        You could try to get a stack trace (i.e. calling context) by putting the following near the top of your script:

        use Carp; BEGIN { $SIG{__DIE__} = sub { confess @_ }; }

        This might help to narrow down on where the error is originating from.  YMMV.

        I also went to the site the other person posted and I don't think that will help since I'm not using the product that page is outlining. Any other advice? Thank you!

        You missed the point, the error message is the same, it is apparently because of a mismatch between versions of Mechanize/LWP/HTTP::Headers etc etc , so just install the latest version of each module, say with

        perl -MCPAN -e 'install Bundle::LWP'
        or
        cpan LWP WWW::Mechanize