in reply to How to put special characters($, @, #) into a field name?

Special characters have to be escaped1 (which is probably the search term you needed) with a backslash, as is done to the "@" in the first line below. (The bars in the second line are merely to make the printout show unambiguously what's in $ascalar.

$ascalar="myemail\@gmail.com"; print "\$ascalar is |" . $ascalar . "|\n";

Output of the code above looks like this:

$ascalar is |myemail@gmail.com|

And, at the hastiest of scans of your update, neverminda, same answer. BTW, this is the kind of question that's a good argument for reading the docs.

1 Belated Update: An excellent alternate -- use of appropriate quoting -- is well covered by others and should have been noted sooner, since my initial statement is incorrectly categorical. See the replies from Fletch & shmem below.

Replies are listed 'Best First'.
Re^2: How to put special characters($, @, #) into a field name?
by neverminda (Novice) on May 26, 2007 at 21:59 UTC
    I tried to use $mech->field(ab\$cd => $value) but it didn't work. How should I proceed now? Thanks.

      The left hand side of the fat comma (=>) only works its quote-like magic on a single sequence of word characters; "$" isn't a word character (see \w in perlre) so you have to quote it just like you would any other string. $mech->field( 'ab$cd' => $value )

      Try
      $mech->field( 'ab$cd' => $value);

      Use single quotes for literals.

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
        Thank you guys so much! I tried to search it on the web for several hours and didn't find any answer. I got it here so quickly! I really appreciate your help! --neverminda