You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Michael Greenish <gr...@yahoo.com> on 2006/01/12 20:09:32 UTC
modperl not recognizing array reference
Hello,
This should be very easy but apache is not letting me
do this. I have a list of file names stored in an
array. The list is created as follows:
push @resizeList, $img->{path} . $img->{file};
The list is passed to a package via a new method as
follows:
my $imageResize = Ishare::Classes::ImageClass->new(
{
resize_list => \@resizeList
} );
The new method is as follows:
sub new {
my $this = shift;
my $class = ref($this) || $this;
my $objRef = shift;
bless $objRef, $class;
return $objRef;
}
Now, when I want to iterate over my list:
sub resizeImgs {
my $self = shift;
foreach my $file( @$self->{resize_list} ) {
...
I get the following error:
Not an ARRAY reference at
/http/greanie/perl-lib/Ishare/Classes/ImageClass.pm
line 193.
However, when I print out the reference type of
$self->{resize_list}, I get 'ARRAY'. When I print out
$self->{resize_list} using Data::Dumper::Simple, I
get:
@_ = (
[
'/ishare/greanie/images/34_Alyssa_Mike_and_Buddy_Sitting_On_Rocks_1.JPG',
'/ishare/greanie/images/35_Buddy_in_the_Sky.JPG',
'/ishare/greanie/images/36_Buddy_On_Leash_On_Cliffs.JPG',
'/ishare/greanie/images/37_Buddy_Sleeping_in_Grass.JPG',
'/ishare/greanie/images/38_Glorious_Buddy.JPG',
'/ishare/greanie/images/39_Group_Picture_on_Cliffs_1.JPG',
'/ishare/greanie/images/40_Group_Picture_Start_of_Trip.JPG',
'/ishare/greanie/images/41_Linda_Mike_Shiraz_On_Da_Trail.JPG',
'/ishare/greanie/images/42_Linda_Smiles.JPG',
'/ishare/greanie/images/43_Ned_and_Carrie.JPG',
'/ishare/greanie/images/44_View_From_Trail.JPG'
]
);
which looks like an array reference. So what is the
problem???!!!
Help greatly appreciated!
Thanks,
greanie
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: modperl not recognizing array reference
Posted by Harry Zhu <ha...@greatlodge.com>.
try @{$self->{resize_list}} ?
Harry Zhu
GreatLodge.com
----- Original Message -----
From: "Michael Greenish" <gr...@yahoo.com>
To: <mo...@perl.apache.org>
Sent: Thursday, January 12, 2006 1:09 PM
Subject: modperl not recognizing array reference
> Hello,
>
> This should be very easy but apache is not letting me
> do this. I have a list of file names stored in an
> array. The list is created as follows:
>
> push @resizeList, $img->{path} . $img->{file};
>
>
> The list is passed to a package via a new method as
> follows:
>
> my $imageResize = Ishare::Classes::ImageClass->new(
> {
> resize_list => \@resizeList
> } );
>
>
> The new method is as follows:
>
> sub new {
> my $this = shift;
> my $class = ref($this) || $this;
> my $objRef = shift;
>
> bless $objRef, $class;
> return $objRef;
> }
>
>
> Now, when I want to iterate over my list:
>
> sub resizeImgs {
> my $self = shift;
> foreach my $file( @$self->{resize_list} ) {
> ...
>
> I get the following error:
>
> Not an ARRAY reference at
> /http/greanie/perl-lib/Ishare/Classes/ImageClass.pm
> line 193.
>
>
> However, when I print out the reference type of
> $self->{resize_list}, I get 'ARRAY'. When I print out
> $self->{resize_list} using Data::Dumper::Simple, I
> get:
>
> @_ = (
> [
>
> '/ishare/greanie/images/34_Alyssa_Mike_and_Buddy_Sitting_On_Rocks_1.JPG',
>
> '/ishare/greanie/images/35_Buddy_in_the_Sky.JPG',
>
> '/ishare/greanie/images/36_Buddy_On_Leash_On_Cliffs.JPG',
>
> '/ishare/greanie/images/37_Buddy_Sleeping_in_Grass.JPG',
>
> '/ishare/greanie/images/38_Glorious_Buddy.JPG',
>
> '/ishare/greanie/images/39_Group_Picture_on_Cliffs_1.JPG',
>
> '/ishare/greanie/images/40_Group_Picture_Start_of_Trip.JPG',
>
> '/ishare/greanie/images/41_Linda_Mike_Shiraz_On_Da_Trail.JPG',
> '/ishare/greanie/images/42_Linda_Smiles.JPG',
>
> '/ishare/greanie/images/43_Ned_and_Carrie.JPG',
>
> '/ishare/greanie/images/44_View_From_Trail.JPG'
> ]
> );
>
> which looks like an array reference. So what is the
> problem???!!!
>
> Help greatly appreciated!
>
> Thanks,
>
> greanie
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.371 / Virus Database: 267.14.17/227 - Release Date: 1/11/2006
>
>
Re: modperl not recognizing array reference
Posted by Michael Greenish <gr...@yahoo.com>.
Well, that was definitely it. I did try wrapping in
{} but I guess I got a cached output because I still
got the error. This time, I restarted apache and
didn't get the error. Thanks for getting me
unstuck!!!
greanie
--- Ronald J Kimball <rj...@tamias.net>
wrote:
> On Thu, Jan 12, 2006 at 11:09:32AM -0800, Michael
> Greenish wrote:
>
> > sub resizeImgs {
> > my $self = shift;
> > foreach my $file( @$self->{resize_list} ) {
> > ...
> >
> > I get the following error:
> >
> > Not an ARRAY reference at
> >
> /http/greanie/perl-lib/Ishare/Classes/ImageClass.pm
> > line 193.
>
> @$self->{resize_list} is parsed by perl as
> (@$self)->{resize_list}, so the
> error message is correct; $self is not an array
> reference.
>
> You should do this instead: @{$self->{resize_list}}.
>
> BTW, this has nothing to do with Apache. You would
> get the same error
> running on the command line.
>
> Ronald
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: modperl not recognizing array reference
Posted by Ronald J Kimball <rj...@tamias.net>.
On Thu, Jan 12, 2006 at 11:09:32AM -0800, Michael Greenish wrote:
> sub resizeImgs {
> my $self = shift;
> foreach my $file( @$self->{resize_list} ) {
> ...
>
> I get the following error:
>
> Not an ARRAY reference at
> /http/greanie/perl-lib/Ishare/Classes/ImageClass.pm
> line 193.
@$self->{resize_list} is parsed by perl as (@$self)->{resize_list}, so the
error message is correct; $self is not an array reference.
You should do this instead: @{$self->{resize_list}}.
BTW, this has nothing to do with Apache. You would get the same error
running on the command line.
Ronald