`perldoc -f defined` yields a couple of sentences:

You may also use C<defined()> to check whether a subroutine exists, by
saying C<defined &func> without parentheses.  On the other hand, use
of C<defined()> upon aggregates (hashes and arrays) is not guaranteed to
produce intuitive results, and should probably be avoided.

why not use:

if(@foo_in)

instead of:

if (defined @foo_in)

cliff rayman
genwax.com

Jeffrey Baker wrote:

> Hi,
>
> I haven't had time to really hunt this bug to its source, but here is
> the report anyway.
>
> Take as an example the URI /program?foo=bar&foo=baz&foo=quux
>
> In program, which uses libapreq, I have code which looks like this:
>
> my @foo_in = $r->param('foo');
>
> @foo_in should not be defined if there are no foo arguments in the query
> string.  The problem is that once a foo argument has been seen, the
> @foo_in array is defined in that Apache child process for all time.  The
> array will not be defined in any other Apache child.
>
> To reproduce the problem, use the handler I have included below and
> perform the following steps:
>
> 1) Visit /yoururl
> 2) Visit /yoururl?foo=bar&foo=baz
> 3) Visit /yoururl as many times as you have Apache child processes
>
> Here is the handler:
>
> package JWB;
> use Apache::Request;
>
> use strict;
>
> sub handler {
>         my $r = Apache::Request->new(shift());
>         $r->status(200);
>         $r->content_type("text/plain");
>         $r->send_http_header;
>
>         my @foo_in = $r->param('foo');
>
>         if (defined @foo_in) {
>                 print "foo_in is defined!\n";
>         }
>         else {
>                 print "foo_in is not defined!\n";
>         }
>
>         print "foo_in has this many entries: ",scalar(@foo_in);
>
>         return 0;
> }
>
> 1;
>
> Regards,
> Jeffrey
> --
> Jeffrey W. Baker * [EMAIL PROTECTED]
> Critical Path, Inc. * we handle the world's email * www.cp.net
> 415.808.8807

Reply via email to