SPUG: returning variables from subs
Showell30 at aol.com
Showell30 at aol.com
Tue Jun 19 12:19:59 CDT 2001
$summary_var, $problem_var, $subproc_xml_var are "my" variables, which means
they only have scope within that function, so it makes sense that the other
function does not see them.
You want to make them global variables, so you should declare them outside of
both functions. You can adjust scope by adding braces (see below) or by
using packages.
{
my $foo;
sub foo1
{
print "foo was $foo\n";
$foo = 1;
}
sub foo2
{
print "foo was $foo\n";
$foo = 2;
}
}
sub foo3
{
# can't print foo here
# print $foo;
}
foo1();
foo2();
foo1();
foo3();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/archives/spug-list/attachments/20010619/41a1c688/attachment.htm
More information about the spug-list
mailing list