[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] defining variables if not already defined



On Mon, 24 Jul 2000 16:14:28 -0700, Tom Sackett wrote:

>I'm having a problem with the following code:
>
>   my ($var) = "bongo";
>   print "The variable is: $var\n";
>   my ($var) = "conga" unless (defined($var));
>   print "The variable is now: $var\n";

You've not enabled the warnings, have you? It would have told you that
you've declared a lexical variable $var in the same scope, twice.

Drop the "my" on the third line.

-- 
	Bart.

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org