The error I get is:#!/usr/bin/perl use strict; use CGI; package WeirdBugObject; use fields qw{weird bug object}; sub new{ return fields::new(shift); } package main; my @params=CGI::param(); my $wbArrayRef=[WeirdBugObject->new(),WeirdBugObject->new()]; foreach my WeirdBugObject $wbo (@$wbArrayRef){print(ref($wbo),"\n"); +}
CGI::read_from_cmdline: Can't declare class for non-scalar @words in + "my" at testWeirdBug.pl line 11.
This corresponds to the line where I invoke CGI::param();
I find this puzzling since the error message refers to class @words which is not a variable in my program, but rather in CGI.pm. But even weirder is the behavior with respect to the typed lexical in the loop a few lines below. The error actually goes away if I do not use a typed lexical in line 13. For example,
foreach my $wbo (@$wbArrayRef){ print(ref($wbo),"\n");}
I got perl 5.6.0 on my workstation with CGI Version 2.93. Does anyone know if this is a bug in perl 5.6.0 or in CGI? The problem doesn't seem to happen in perl 5.8.0 with CGI version 2.89. I think I need to upgrade something, but I am not sure I want to upgrade the whole perl install yet if it is not necessary to.
I generally use fields pragma and type my lexicals.
Thanks for any help you can give!
-JonathanU
In reply to Weird behavior with CGI, typed lexicals by jonathanu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |