in reply to List or Scalar?
Many thanks to antirice and NetWallah - their diagnosis is absolutely correct; and I have now a (little) better understanding of Perl's references
Using the $term->[0] syntax is the answer and I now assume that the print command was kinda "DWIM"ing the ref for me, but in the for loop it wasn't. A bit subtle for my present level of Perlishness 8-)... but on further reflection this would be because print is in list context - and of course the (-1..@{$term}) is scalar - Insight!
antirice... Data::Dumper printed as follows
$term is 120 $VAR1 = [ '120' ];
... are the single quotes trying to tell me something?
and NetWallah... Thanks for that very revealing code snippet... I'll keep a copy of that to remind me of the various syntactic options re references. I've just re-read MJD's perlreftut and I think I see where I misunderstood the syntax.
cheers and thanks again... what a great resource Perl Monks is..... hagen.
|
---|