Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Subroutine and variable passing

by boftx (Deacon)
on Aug 24, 2013 at 06:12 UTC ( [id://1050765]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1050765]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found