[San-Diego-pm] Perl Problem
Bob Kleemann
rkleeman at energoncube.net
Mon May 14 15:21:06 PDT 2012
I'm not sure how "foreach (@{ @A })" ever worked. You want "foreach
(@A)", then your first line inside the loop, "@B = @{$_};" will do
what you intend. And yes, you probably should test to see if $ref is
undef, and act accordingly.
Alternatively, you could rewrite this bit of code as such:
my $ref = $dbh->selectall_arrayref("...");
if (! $ref) {
# Do something!
}
foreach my $row (@$ref ) {
push @ID, $row->[0];
push @Grupo, $row->[1];
...
}
On Mon, May 14, 2012 at 3:03 PM, Joel Fentin <joel at fentin.com> wrote:
> BlueHost upgraded to CentOS 6 and Perl 10. At that moment several of my
> sites there stopped working.
> Can't use string ("0") as an ARRAY ref while "strict refs" in use at
> CDsearch.pl line 283.
>
>
> my $ref=$dbh->selectall_arrayref("$Select $From $Where $Order $Limit");
> my @A=@{$ref}; #@A=array of refs
> my @B; #@B=array of info on 1 CD
> foreach(@{@A}) #error here
> {
> @B=@{$_};
> push(@ID,$B[0]);
> push(@Grupo,$B[1]);
> push(@Disco,$B[2]);
> push(@Vol,$B[3]);
> push(@Ano,$B[4]);
> push(@Cancion,$B[5]);
> push(@Image,$B[6]);
> push(@CancionNo,$B[7]);
> }
>
>
> Do I need a test for an empty @A?
> Or is there something more graceful?
>
> --
> Joel Fentin tel: 760-749-8863
> Biz Website: http://fentin.com
> Personal Website: http://fentin.com/me
> _______________________________________________
> San-Diego-pm mailing list
> San-Diego-pm at pm.org
> http://mail.pm.org/mailman/listinfo/san-diego-pm
More information about the San-Diego-pm
mailing list