Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: How to handle passed data in subroutines

by !1 (Hermit)
on Nov 20, 2003 at 03:27 UTC ( #308481=note: print w/replies, xml ) Need Help??


in reply to How to handle passed data in subroutines

There's a bit of magic happening in the background. First thing you need to know is that if you work directly with the @_ array, you are altering the values passed to the subroutine directly. When you use for, the variable assigned to (in this case, $_) is actually an alias in the list the for is iterating over. uc returns a new value and does not work on $_. To fix it, it's only a matter of:

$_ = uc($_);

Of course, since we're working with the variable $_, we can just use $_ = uc; instead and still get the desired results. I hope this helps you with your problem.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2021-09-26 12:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?