Otherwise, just declare them at the top of your program, and make call_variables update them. Don't put my $one = ... inside the function because that would create lexicals in the scope of the function body (not what you want).
With hash:
# [at the top, before subroutine definitions and code] my %my_vars; # [...] sub call_variables { #pick up a string I've passed from previous program via 'spec_vars' my $spec_vars = param('spec_vars'); @my_vars{qw/one two three four five/} = split /~/, $spec_vars; }
With globals (file-scoped lexicals, not dynamic variables):
# [at the top, before subroutine definitions and code] my ($one, $two, $three, $four, $five); # [...] sub call_variables { #pick up a string I've passed from previous program via 'spec_vars' my $spec_vars = param('spec_vars'); ($one, $two, $three, $four, $five) = split /~/, $spec_vars; }
If you don't want to declare them, you have to use fully scoped package variable names such as $::one under use strict. The variables will be dynamic, of course.
Update: replaced @my_vars{one, two, three, four, five} with @my_vars{qw/one two three four five/}
In reply to Re: Re-calling in a list of variables into different .pl's
by calin
in thread Re-calling in a list of variables into different .pl's
by Lori713
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |