in reply to passing information through hidden fields using CGI.pm

yay! CGI.pm! :) What you want is:

print hidden(-name=>'hey',-value=>'you');

or just
print hidden('hey,'you');
Because the first two fields default to name then value. You should check out the documentation for all sorts of amazing stuff it can do.

Also, never input plain HTML in your script. Usually, thats where all the bugs are because maybe you forgot to backslash a quote:
print "<input type="text">";
Would obviously give an error as would many other things. Basically, always use CGI.pm and I am glad that you already are :)

Almost a Perl hacker.
Dave AKA damian

I encourage you to email me

Replies are listed 'Best First'.
Re: Re: passing information through hidden fields using CGI.pm
by runrig (Abbot) on Feb 13, 2001 at 02:08 UTC
    Since he's just 'passing through' the values, and CGI.pm parameters are 'sticky', this:
    print hidden('hey','you');
    can be shortened to this:
    print hidden('hey');
    In fact, you have to specifically pass an override flag if you want to override the 'sticky' default, so the first example wouldn't even work if you were trying to change the value of the 'hey' parameter.

    Update:damian1301 is wrong below. See this:

    $ perl -e 'use CGI qw(:standard -debug);print hidden("hey")' hey=you <input type="hidden" name="hey" value="you"> $ perl -e 'use CGI qw(:standard -debug); print hidden("hey","there")' hey=you <input type="hidden" name="hey" value="you"> $ perl -e 'use CGI qw(:standard -debug);print hidden(-override=>1, -name=>"hey",-value=>"there")' hey=you <input type="hidden" name="" value="there">
      Very true, thank you. But  print hidden("hey"); would only pass myscript.pl?hey= which might not always be what you wanted. Especially if you want to maintain state in a HTTP authentication through hidden fields. Mostly, it depends on what your doing to decide what you want to use. Thanks. Later

      Almost a Perl hacker.
      Dave AKA damian

      I encourage you to email me
Re: Re: passing information through hidden fields using CGI.pm
by markjugg (Curate) on Feb 13, 2001 at 01:41 UTC
    Thanks Damian,

    I'll look more closely at how the sticky hidden fields work with CGI.pm

    -mark