[Edinburgh-pm] help again with lists

Chris Benson chrisb at jesmond.demon.co.uk
Sun Mar 18 10:09:31 PDT 2007


On Sun, Mar 18, 2007 at 05:04:48PM +0000, Andrew Smith wrote:
> Having,  I think fully understood list assignments with () and qw, I've 
> moved on to dabbling  with lists in code.
> Why can I not refer to the number of elements in @words1 using  $words1 
> in lines 6 & 7 in the attached test program  ?

The clue is:
	Global symbol "$words1" requires explicit package name at - line 4.
Which is: 
	my $words1count=$words1;

$words1 hasn't been mentioned anywhere, you need to do:
	my $words1count = @words1;
And that enables the rest of the program to work:
words1
------
There are 5 elements  in list @words1
abc:1:2:3:def
1
2

Best wishes
-- 
Chris Benson


More information about the Edinburgh-pm mailing list