* Raphael Brunner <[EMAIL PROTECTED]> [2006-10-16T08:38:00]
> But, my problem is, i must see this variable after the call of the sub.
> I'm sorry for the first example, it was inaccurate. But this is ok (I
> think) :) (because I have a lot of variables, which I must change in the
> sub, I want to define they as "global" inside my parent-routine (in the
> example: the programm, but by me: the parent-sub)).
So, pass in a reference to it.
Instead of:
> my $var = 20;
>
> print "before: $var\n";
> &routine;
> print "after: $var\n";
> exit;
>
>
> sub routine {
> $var += 1;
> }
Write:
my $var = 20;
print "before: $var\n";
routine(\$var);
print "after: $var\n";
sub routine {
my ($input_ref) = @_;
$$input_ref += 1;
}
Consult "perldoc perlreftut" for more.
--
rjbs
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>