Richard Heintze wrote:
> James,
> The problem occurs when $q->param('next') returns a
> null of sorts because there is no such parameter in
> the URL.
If there is no such parameter then 'param' will return
either 'undef' or an empty list according to context.
> Apparently, this does not get passed.
Not sure what you mean by this?
> When this is the case, all the subsequent function
> parameters are offset by one.
If you put the function call in list context like this:
print_args("abc", $q->param('next'), "xyz");
then this is the same as
print_args("abc", ( ), "xyz");
which in turn is the same as
print_args("abc", "xyz");
If you force scalar context onto the call first like this
my $n = $q->param('next');
print_args("abc", $n, "xyz");
this is the same as
print_args("abc", undef, "xyz");
and the 'undef' will be printed as a null string by your
function.
my @values = $q->param;
on its own will return a list of the names of all the values
in the URL, and hence all valid parameters to 'param'.
By the way, never use the ampersand on function calls like
&print_args("abc", $q->param('next'), "xyz"); # Wrong!
unless you want the strange and exotic effects that
you get by making the call this way. If you don't know
what they are then you don't want them!
> Very strange...
> What a language...
People only think Perl is strange if they try to make it be
another language X. Which it isn't. All languages are strange
when viewed from this point of view.
> I'll try your suggestion of using scalar a little later...
James' suggestion will work. I hope I've explained why. But
surely you don't need a fix so that you can print a blank for
non-existent URL query values?
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]