Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Overloading for List Context

by webfiend (Vicar)
on May 31, 2002 at 16:29 UTC ( [id://170757]=note: print w/replies, xml ) Need Help??


in reply to Overloading for List Context

I can make it work with while. I'm just a monkeyboy, so I have no idea why it works. Anyways:

package main; my $quux = LuckyDeck->new(0..9); print 'List Context',$/; while (<$quux>) { print $_; } print $/;

Or, putting the while in the same style as the rest of the program:

print while <$quux>;

Would somebody smart like to explain why while works, but for doesn't?

Update: Drank some more coffee, realized that wasn't really the question. Back to the drawing board ...

Update: Okay, I am stumped (which isn't a major news item itself ;-) ). I have found no way to convince LuckyDraw that I wantarray. List assignment and while both come up in a scalar context. Where is the oddity coming from? Overload? The iterator <> operator? Does perl have a hangover today?


"All you need is ignorance and confidence; then success is sure."-- Mark Twain

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-19 07:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found