Is it possible to pass a subroutine a string with a variable in it, and act on that string within the subroutine and update the embedded variable?
For example, pass to a subroutine file with a list of symbols and a URL with a variable for the undefined symbol embedded in it, like the following.
When I run the following code, it tries to execute and download the file as expected, but $symbol info in the file directory and in URL are undefined.
my $testfile="/home/user/symbol_list"; my $wget_url="/home/user/sym_dir/${symbol}_2013 'http://www.downloadsi +te.com/${symbol}.dat'"; &get_symbol_data($testfile,$wget_url); sub get_symbol_data { open (FILE, $_[0]) || die "Can't open $_[0] $!\n"; @sym_array = <FILE>; close <FILE>; foreach $symbol (@sym_array) { chomp $symbol; `usr/bin/wget -O $_[1]`; } }
In reply to Subroutine and variable passing by tman77
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |