Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Static variable problem

13 views
Skip to first unread message

Dave Saville

unread,
Nov 13, 2012, 10:15:21 AM11/13/12
to
Apologies if this appears twice but I have not seen it and my sent
posts folder does not have a copy - but I would swear I hit send :-)


Please can someone explain why the following throws an error?

[T:\tmp]cat try.pl
use strict;
use warnings;

foo("Hello World");
exit;
{
my $bar = 1;

sub foo
{
my $a = shift;
print "$bar $a\n"; <== line 12
return;
}
}

[T:\tmp]try.pl
Use of uninitialized value in concatenation (.) or string at try.pl
line 12.
Hello World

$bar is private to foo - yes? So you can't initialize it?
--
Regards
Dave Saville
0 new messages