James, Joseph, drieux, Thank you very much for your feedbacks. I wasn't checking mails over the weekend. Sorry for the confusion. I was just trying give an example. Didn't realize they were integers :) I tried the approach below and it works just fine.
Thanks for your help Rajesh -----Original Message----- From: James Edward Gray II [mailto:[EMAIL PROTECTED] Sent: Saturday, November 22, 2003 8:18 AM To: Rajesh Dorairajan Cc: '[EMAIL PROTECTED]' Subject: Re: dereferencing a list from a class On Nov 21, 2003, at 3:19 PM, Rajesh Dorairajan wrote: > I've a class (blessed, of course :)) that has variables like: > > $self->a = "1"; > $self->b = "2"; > $self->c = [ '1', '2', '3', '4' ]; I think/hope you meant: $self->{a} = '1'; # any reason we're quoting integers? $self->{b} = '2'; $self->{c} = [ qw(1 2 3 4) ]; > Now, I want to write a foreach loop to iterate through $self->c and > print > the values. However: > > foreach my $foo ( $self->c ) { > print $foo; > } for my $foo ( @{ $self->{c} } ) { print $foo; } Hope that helps. James