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

I'm trying to use WWW::Mechanize and the website requires a login. I've used mech-dump to have a look at the form and both the username and password field contain several $ symbols within the field name. Any idea how I can deal with these as I am unable to define the field name as a variable with all the $s in it?

The field names are as follows:

ctl00$ContentPlaceHolder1$Login1$UserName= (text)

ctl00$ContentPlaceHolder1$Login1$Password= (password)

Thanks

Replies are listed 'Best First'.
Re: web form name contains $ symbols
by kcott (Archbishop) on Jul 01, 2013 at 05:18 UTC

    G'day Chris Clarke,

    Welcome to the monastery.

    "Any idea how I can deal with these as I am unable to define the field name as a variable with all the $s in it?"

    Without seeing your code, I'm somewhat guessing here; however, is there some reason you can't simply code:

    my $uname_field_name = 'ctl00$ContentPlaceHolder1$Login1$UserName'; my $pword_field_name = 'ctl00$ContentPlaceHolder1$Login1$Password';

    Take a look at perlop - Quote-Like Operators and quotemeta.

    Given that my solution is so straightforward (and, to me, very obvious), I suspect there may be something else going on here. If there is, please take a look at "How do I post a question effectively?" to get a better answer.

    -- Ken

      Ah yes. Thanks. It's been a while since I wrote a Perl script...