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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: unable to post to forum
by talexb (Chancellor) on Nov 29, 2005 at 04:53 UTC

    Well, it's very tantalizing .. you got an illegal value error .. yes .. yes .. but where? On which line of your script? (And don't say line 17 or we'll smack you -- tell us which statement it had problems with.)

    Have you tried single stepping through the script with the debugger, or does this finely crafted piece of code compile cleanly?

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: unable to post to forum
by johnnywang (Priest) on Nov 29, 2005 at 05:49 UTC
    It worked fine for me, no errors, although I didn't check what it is supposed to do.

    I'm curious about the syntax:

    $agent->get(my $url="http:.....");
    I didn't know that's valid, anyone cares to explain? Thanks.

      The embedded my? Yes it's perfectly valid, although I quite agree that it looks odd, but the simple fact of the matter is that lexicals can be created pretty much anywhere in a statement.

      It's (I think) what lets you do:

      if( my $foo = bar(@quux) ) { $foo exists here } # no foo here

      I'm certain it's what lets you say:

      (my $copy = $original) =~ s/foo/bar/;

      That is, the variable $copy doesn't fall out of scope outside the parentheses. Sometimes it makes for nicer code, sometimes bizarre. Be wary of trying this new toy out everywhere :)

      • another intruder with the mooring in the heart of the Perl

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: unable to post to forum
by Popcorn Dave (Abbot) on Nov 29, 2005 at 20:09 UTC
    I've used WWW::Mechanize but never the FormFiller part so this may or may not help you but I noticed in your code that you never use the name of the form. When I've used WWW::Mechanize, I've had to put the name of the form I posted to so my assumption is that you have to do that too, otherwise it won't know which form to post to.

    This is a partial example of what I did to pull names and addresses from yellowpages.com:

    use WWW::Mechanize; my ($name, $city, $state); my $url = 'http://www.yellowpages.com/Index.aspx'; my $mech = WWW::Mechanize->new(autocheck => 1); $mech->get( $url ); $mech->form_name("__aspnetForm"); $mech->field("Mainhomectrl2:BasicForm1:businessname", $name); $mech->field("Mainhomectrl2:BasicForm1:city", $city); $mech->field("Mainhomectrl2:BasicForm1:state", $state); $mech->click("Mainhomectrl2:BasicForm1:searchbtn");

    I think you need to add $agent->form_name("post") to your code. I just tried it and it didn't throw an error when I added that to your code.

    HTH!

    Useless trivia: In the 2004 Las Vegas phone book there are approximately 28 pages of ads for massage, but almost 200 for lawyers.
    A reply falls below the community's threshold of quality. You may see it by logging in.