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

Re: (elbie) When does $_ get used?

by elbie (Curate)
on Jul 26, 2001 at 22:01 UTC ( [id://100070]=note: print w/replies, xml ) Need Help??


in reply to Re: When does $_ get used?
in thread When does $_ get used?

I'm sorry I confused the issue. My question wasn't "why doesn't while assign a value to $_" but "why doesn't shift?"

Certainly while( <> ) { ... } works as I expected it to. While talking it over with other helpful monks via the Chatterbox, I found that the individual functions will say if they use $_ in their descriptions.

That being said, is there a good reason why shift (for example) doesn't assign a value to $_ unless another variable is explicitly used?

Replies are listed 'Best First'.
Re: Re: (elbie) When does $_ get used?
by bikeNomad (Priest) on Jul 26, 2001 at 22:05 UTC
    Because, for one thing, it's useful to call shift in void context to remove an array element with no other side-effects. Clobbering $_ in these cases would make it less useful.

Log In?
Username:
Password:

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

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

    No recent polls found