in reply to Hash reference as a parameter

Did you get the answer you wanted about the issue of "optional" parameters? Is this the kind of thing you're after?
# caller: StartCapture( { twigs => {filter => $filterTwig, capture => $captureTw +ig}, hashes => {filter => \%filterHash, capture => \%captur +eHash}, files => {filter => 'filter.txt', capture => 'capture. +txt'}, results => 'c:/temp.txt' } ); # ... sub StartCapture { my $hashref = shift; $$hashref{results} ||= 'c:/SomeDefault.txt'; # ... }
Using the "||=" operator, the LHS (hash element in this case) will be assigned the RHS value iff the original LHS evaluates to false. (I believe that the most recent perl version also has a "//=" operator, which makes the assignment only if the LHS is undef, as opposed to being zero or an empty string.)

Replies are listed 'Best First'.
Re^2: Hash reference as a parameter
by ramya2005 (Scribe) on Sep 12, 2005 at 22:08 UTC
    Thanks. My optional parameters problem is solved, but I learned a new way of doing it by seeing your post