Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

ftp://192.168.100.100/, www.xxxcon, which comes first ob_start or session, wwwxxx/58/2010, xxxxdup, xxxxdup, mailx informatii, should producers of software-based services, such as atms, be held liable for economic injuries suffered when their systems fail?, mysql feiertage, bash netcat eof

Links

XODOX
Impressum

#1: CGI.PM and hidden()

Posted on 2008-04-13 19:12:30 by dtshedd

I am trying to replace this

print "<input type=\"hidden\" name=\"page\" value=$page>\n";


with this

print hidden(-name=>"page", -value=>$page);

problem is that the new line does not print the correct value of $page
(its supposed to change every pass through the perl code), I have
tried enclosing the contents of the hidden() command in "{}" but this
made no difference. I am not sure what the role of these brackets
are, some syntax shows them present and other forms of the syntax
shows them absent.

appreciate any help

dts

Report this message

#2: Re: CGI.PM and hidden()

Posted on 2008-04-13 21:36:16 by paduille.4061.mumia.w+nospam

On 04/13/2008 12:12 PM, dtshedd@yahoo.com wrote:
> [...]
> print hidden(-name=>"page", -value=>$page);
>
> problem is that the new line does not print the correct value of $page
> (its supposed to change every pass through the perl code),
> [...]

You should create a small (but complete) script that demonstrates the
problem you're having. For example, see this program:

#!/usr/bin/perl
use strict;
use warnings;
use CGI qw/:standard/;
use File::Slurp;

my $counter = '/tmp/ses/count';
-f $counter || write_file($counter, '0');
my $page = read_file($counter) + 1;
write_file($counter, $page);

print header('text/plain');
print hidden(-name=>"page", -value=>$page);

Report this message

#3: Re: CGI.PM and hidden()

Posted on 2008-04-13 22:00:20 by Claudio Calvelli

On 2008-04-13, dtshedd@yahoo.com wrote:
[...]
> print hidden(-name=>"page", -value=>$page);
>
> problem is that the new line does not print the correct value of $page
> (its supposed to change every pass through the perl code), I have

If there's already a value for a 'page' field, hidden() uses it. The
manual suggests to change the value before calling hidden():

param("page", $page);
print hidden(-name=>"page", -value=>$page);

I personally never read the manpage before posting this, so delete the
parameter instead:

Delete("page");
print hidden(-name=>"page", -value=>$page);

C

--
Real email address: join('@', 'intercal', 'freeshell.org')
It helps the spam filter if you include the word CAMEL in the subject.

Report this message

#4: Re: CGI.PM and hidden()

Posted on 2008-04-14 15:02:23 by Steve van der Burg

dtshedd@yahoo.com wrote in
news:1d83c539-ec4e-4c1e-8e24-40131fcd1809@8g2000hsu.googlegr oups.com:

> I am trying to replace this
> print "<input type=\"hidden\" name=\"page\" value=$page>\n";

> with this
> print hidden(-name=>"page", -value=>$page);
>
> problem is that the new line does not print the correct value of
> $page (its supposed to change every pass through the perl code),
<snip>

Try '-override', like this:

print hidden(-name=>"page", -value=>$page, -override=>1);

....Steve

--
Steve van der Burg
Technical Analyst, Information Services
London Health Sciences Centre
London, Ontario, Canada
Email: steve.vanderburg@lhsc.on.ca

Report this message

#5: Re: CGI.PM and hidden()

Posted on 2008-04-15 19:08:51 by xhoster

dtshedd@yahoo.com wrote:
> I am trying to replace this
>
> print "<input type=\"hidden\" name=\"page\" value=$page>\n";
>
> with this
>
> print hidden(-name=>"page", -value=>$page);
>
> problem is that the new line does not print the correct value of $page
> (its supposed to change every pass through the perl code),

CGI has "sticky" fields. The value that was just submitted has priority
over the the value specified by -value.

This is usually a good thing. If someone's submission is malformed in one
field, and you need to tell them to change it and resubmit, you want
the new page to retain their previous selections rather than forcing them
to start over with the original defaults (although this argument is less
compelling in the case of hidden fields.)

To change this default behavior for an individual field, specify
-override => 1

You can also turn it off globally by using -nosticky when CGI is "use"d.


> I have
> tried enclosing the contents of the hidden() command in "{}" but this
> made no difference. I am not sure what the role of these brackets
> are, some syntax shows them present and other forms of the syntax
> shows them absent.

CGI offers an absurd amount of flexibility in how parameters are passed
to it's methods/functions. The list-vs-hash is part of that. It shouldn't
change the behavior.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Report this message