in reply to Re: opening a file destroys nulling entries in a list?!?!
in thread opening a file destroys nulling entries in a list?!?!
When you do screwed($_) variable $_ gets aliased to $_[0] inside screwed() as subroutine parameters always aliased to elements of @_ array inside the subroutine. So later when while loop modifies $_ it affects $_[0] too.
Shorter demo:
Yet another example why I think while(<>) { ... } considered harmful.$_ = 1; test($_); sub test { $_ = 2; print $_[0], "\n"; } # output of script __END__ 2
--
Ilya Martynov, ilya@iponweb.net
CTO IPonWEB (UK) Ltd
Quality Perl Programming and Unix Support
UK managed @ offshore prices - http://www.iponweb.net
Personal website - http://martynov.org
|
---|