>On the other hand, I hardly ever use $_ in main-stream programming.  I
>always perform:

>for my $var ( .. ) { .. }

Certainly I seldom *mention* $_, but I sure use it a lot, as in 

    for (@array) { s/foo/bar/ } 

It's not something I'd like made Law, but I do advise my beginning
students that the proper length of variable is proportionate
to its scope, and that since $_ is the shortest of Perl variables
(well, and @_ for pop and shit, etc) that they should probably keep
its use reasonably brief.  It's best when you're doing repeated operations
on the same variable where many or most of those operations can default
to $_.  When you find yourself mixing and matching, sometimes with the
common variable, sometimes with others, then I generally advise what
you do.  Also, if it does no good to use $_, don't bother.  For 
exapmle, I would write

    for $item (@array) { func($item) } 

Unless func() were something that could default to using $_.

--tom

Reply via email to