Helter has asked for the wisdom of the Perl Monks concerning the following question:
There are probably a few people out there that have no idea why the above segment is wrong (besides error checking, or doing something truly useful in the body of the loop).open( HANDLE, "<file"); while( my($line) = <HANDLE> ) { print $line; }
Based on my background this looks good to me, but now that I have done some research I don't think it is correct. The correct lines should be:my($var); my($othervar) = 43;
That does assume we don't want to declare multiple items...my $var; my $othervar = 43;
1. So my questions are, what other nuances are there with my that have either been Gotcha's or could be?my($var1, $var2, $var3);
"You really probably want to be using `my' instead, because `local' isn't what most people think of as "local"."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: nuances of my, and maybe local
by Chmrr (Vicar) on Sep 27, 2002 at 17:25 UTC | |
|
Re: nuances of my, and maybe local
by Zaxo (Archbishop) on Sep 27, 2002 at 17:34 UTC | |
|
•Re: nuances of my, and maybe local
by merlyn (Sage) on Sep 27, 2002 at 18:16 UTC | |
|
Don't Use Local
by Wally Hartshorn (Hermit) on Sep 27, 2002 at 18:50 UTC | |
by merlyn (Sage) on Sep 27, 2002 at 19:28 UTC | |
|
Re: nuances of my, and maybe local
by rir (Vicar) on Sep 27, 2002 at 19:26 UTC | |
|
Re: nuances of my, and maybe local
by samurai (Monk) on Sep 27, 2002 at 17:20 UTC | |
by diotalevi (Canon) on Sep 27, 2002 at 17:35 UTC | |
by shotgunefx (Parson) on Sep 27, 2002 at 17:31 UTC | |
by Anonymous Monk on Sep 27, 2002 at 21:16 UTC | |
by shotgunefx (Parson) on Sep 28, 2002 at 02:59 UTC | |
by Helter (Chaplain) on Sep 27, 2002 at 17:32 UTC | |
by Helter (Chaplain) on Sep 27, 2002 at 17:39 UTC |