in reply to Subroutine and variable passing
Is there a reason you have to define $wget_url outside of the subroutine? If not, then this change should allow it to work as you desire:
my $testfile="/home/user/symbol_list"; &get_symbol_data($testfile); sub get_symbol_data { open (FILE, $_[0]) || die "Can't open $_[0] $!\n"; @sym_array = <FILE>; close <FILE>; foreach $symbol (@sym_array) { chomp $symbol; my $wget_url=qq~/home/user/sym_dir/${symbol}_2013 'http://www.downl +oadsite.com/${symbol}.dat'~; `usr/bin/wget -O $wget_url`; } }
The qq~...~ allows all occurrences of $symbol to be properly interpolated, even inside single quotes in a string assignment.
|
|---|