http://www.perlmonks.org?node_id=308481


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.