From: Bogart Salzberg <[EMAIL PROTECTED]>
   Date: Fri, 23 Jul 2004 12:56:31 -0400

   Hi all,

   First post... I'm a member of maine.pm, too, but we're a quiet bunch 
   and I have a noisy problem. So, here goes...

   The problem is that one of my CGI scripts dies on older versions of 
   Perl with a "not a CODE reference", though it runs fine on newer 
   versions. (The cut-off is somewhere between 5.6.1 and 5.8.1). 

FWIW, it also runs on 5.8.0.

   I watered down the production code and ran a test version on
   different servers (see below). To sum it up, this line works on the
   new and not on the old, and I'm wondering if there is a "low-profile"
   workaround:

   my ($process, $target) = wantarray? (\&push_array, [EMAIL PROTECTED]): 
   (\&concat, \$record); 

If I run your script with "-w", I get this warning:

        Useless use of reference constructor in void context at ./perl-test.pl line 28.

But I have no clue what that means.  However, I note that it works if I
rewrite the line above as follows:

        my $process = wantarray ? \&push_array : \&concat;
        my $target  = wantarray ? [EMAIL PROTECTED]: \$record;

Better (and still working) is:

        my $wa = wantarray;
        my ($process, $target) = $wa ? (\&push_array, [EMAIL PROTECTED]): (\&concat, 
\$record);

So it would appear to be some bug relating to the '?' operator with
lists appearing in the result clauses and wantarray appearing in the
conditional.  I bet the warning means that the line is being misparsed
somehow.  But more than that I wouldn't venture to say.

   Good thing I could still find a 5.6.1 installation with which to
experiment.  ;-}

                                        -- Bob Rogers
                                           http://rgrjr.dyndns.org/
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to