in reply to Best way to pass variables?
If by "global" you mean a lexical outside of any enclosing block (which is not the customary meaning), and you have some aversion to having such a thing, just wrap a block around the area where it's used:die "Required argument missing!\n" unless ($ARGV[0]); my $response; if ($ARGV[0] =~ /Hello/i) { $response = "Hello to you.\n"; }else{ $response = "Huh?\n"; } print $response;
die "Required argument missing!\n" unless ($ARGV[0]); { #scoping block my $response; if ($ARGV[0] =~ /Hello/i) { $response = "Hello to you.\n"; }else{ $response = "Huh?\n"; } print $response; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Best way to pass variables?
by Elijah (Hermit) on Mar 05, 2004 at 22:07 UTC | |
by Roy Johnson (Monsignor) on Mar 05, 2004 at 22:31 UTC | |
by Prior Nacre V (Hermit) on Mar 06, 2004 at 18:57 UTC |