in reply to Hash of Lists Subroutine Problem
When you pass a hash, it is passed as a list, so everything you are passing to the subroutine is ending up in %URLS, leaving $title empty (and perl would warn you of this, by telling you that an odd number of elements had been assigned to a hash, if you were using -w). To avoid the problem you either have to pass scalars first, and put the list at the end, or pass lists by reference.
To pass by reference you can either do it explicitly:
printurls(\%URLS,$title); sub printurls { my($urls,$title) = @_; my %URLS = %{$url}; }
Or, you can use prototypes, to make them references for you:
printurls(%URLS,$title); sub printurls(%$) { my($urls,$title) = @_; my %URLS = %{$urls}; }
|
|---|