Elijah has asked for the wisdom of the Perl Monks concerning the following question:
For Example:
Now if I syntax check this or run it I would get the following error.#!/usr/bin/perl -w use strict; die "Required argument missing!\n" unless ($ARGV[0]); if ($ARGV[0] =~ /Hello/i) { my $response = "Hello to you.\n"; }else{ my $response = "Huh?\n"; } print $response;
Global symbol "$response" requires explicit package name at syn_check line 11. syn_check had compilation errors.What is the best way to pass the variable $response out of the if statement to make it visible at another level? Remember I do not want to make the variable global either.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Best way to pass variables?
by Roy Johnson (Monsignor) on Mar 05, 2004 at 21:51 UTC | |
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 | |
|
Re: Best way to pass variables?
by Corion (Patriarch) on Mar 05, 2004 at 21:51 UTC | |
|
Re: Best way to pass variables?
by PodMaster (Abbot) on Mar 05, 2004 at 21:52 UTC | |
|
Re: Best way to pass variables?
by BUU (Prior) on Mar 06, 2004 at 07:51 UTC |