>> For example, my temptation was to do this:
>> 
>> **************************************
>> sub isDate {
>> 
>>     $_ = shift;
>>     if (m!\d{2}/\d{2}/\d{2}!) { return 1; }
>>     else { return 0; }
>> 
>> 
>> } 
> 
> Why is this in a subroutine at all?  If you are using it like:
[stuff cut out]

Understood, this was just a simplified example.  I didn't want to put a
200-line subroutine in an email...



>> **************************************
>> 
>> ... but by modifying $_ I was clobbering $_ elsewhere in the larger program!
> 
> Yes because $_ is a special global variable.  This effect is called
> "action at a distance" which is why it is better to use named lexically
> scoped variables instead of $_.

I have the Perl Bookshelf on CD (and perldoc, obviously) -- where can I read
more about this?



>> Oddly, perl won't let me do "my ($_) = shift;", so I'm stuck having to use
>> another variable.
> 
> Perl 5.10 *will* let you do "my $_".

Why is perl on OS X still at 5.8.8?  It's free, right?  why wouldn't Apple
include the latest one?  (I know this isn't an Apple list, just wondering if
anyone knows.)

Thanks, John, et al. -- always tremendously helpful, and much appreciated.

- Bryan



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to