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

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

Dear Mons, I have a doubt regarding the below codes. Can you pls suggest a way?

Is there a provision to pass a string to it like below,

my $Pager = "submit"; my $find_button = $mech->xpath('//*[@id="$Pager"]', single => 1 ); $mech->click( $find_button );

Its not getting me through! Giving an error like 'NO elements found'

Thanks in advance.

Replies are listed 'Best First'.
Re: WWW::Mechanize::Firefox Navigate Issue !
by aitap (Curate) on Nov 04, 2012 at 08:10 UTC
      *cough*  Possible unintended interpolation of @id in string at - line 1.
Re: WWW::Mechanize::Firefox Navigate Issue !
by hippo (Bishop) on Nov 03, 2012 at 14:45 UTC

    Using single quotes like you have in your example supresses variable substitution in Perl just like it does in bash. See what happens here:

    my $bcount = 5; print "I ate $bcount biscuits "; print 'I ate $bcount biscuits ';

    Use single quotes for literal strings, use double quotes for interpolation (including variable substitution.