in reply to @_ the default variable?
Really, I do not recommend explicitly defining the @_ var, but I hope it is just for example purposes.
So in that case....
#! /usr/bin/perl -w use strict; @_ = qw( Lucy, I'm home! ); sub main { while(my $d = shift) { print "$d\n"; } } &main;
You can use this if it really upsets you.
However, assuming your code is not just an example, why in the world are you using the @_ array??? And if your not explicitly defining something to @_, there should not be a variable to read in the main. The package main should always be called first on program execution, and should have @ARGV, and the variables you assigned (globally...). (Side note, yes, I know other built-ins are there, but these are really the vars he needs to deal with.)
Dont just think of @_, $_, etc, as "default variables", but more as pronouns. "These are as bad as it." Is not a proper sentence, and a worse program. "These are apples, and it is an orange. These cannot compare to it." Now the sentence makes no sense for a reason other than bad grammar.
So from what I can tell, you're doing something you shouldn't, and perl is making you type three more charachters... Whatta language.
What would happen to this:
#!/usr/bin/perl -w use strict; @_ = qw( hello world ) @other = qw( hasta la vista baby ) sub main { while(my $d = shift) { print "$d\n"; # Are we coming or going? } } &main;
The code actually reads the @_ array, which it should, but more importantly, you can't tell if you're coming or going just from reading it.
Bad monky...
~Hammy
|
---|