in reply to Hash reference as a parameter
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.)# 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'; # ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hash reference as a parameter
by ramya2005 (Scribe) on Sep 12, 2005 at 22:08 UTC |