Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: List or Scalar?

by hagen (Friar)
on Aug 27, 2003 at 23:28 UTC ( #287204=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://287204]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2020-01-21 10:49 GMT
Find Nodes?
    Voting Booth?