in reply to Subroutine and variable passing
Yet I'll try proposing an alternative solution: Replace it with sprintf?
my $url = [ 2, "/home/user/sym_dir/%s_2013 'http://www.downloadsite.co +m/%s.dat'" ]; get_symbol_data($url); sub get_symbol_data { my ($base_url) = @_; my ($repeats, $fmt_string) = @$base_url; my @sym_array = ('foo', 'bar', 'baz'); for my $symbol (@sym_array) { my $url = sprintf($fmt_string, ( $symbol ) x $repeats); print $url, "\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Subroutine and variable passing
by boftx (Deacon) on Aug 26, 2013 at 05:58 UTC |