in reply to Optional and default parameters for a subroutine

It looks like you've already got the the optional arguments handled correctly in your subroutine, but you're passing it a hash reference where it expects a plain list. Change your subroutine invocation to:

StartCapture( twigs => {filter => $filterTwig, capture => $captureTwig}, hashes => {filter => \%filterHash, capture => \%captureHash}, files => {filter => 'filter.txt', capture => 'capture.txt'}, results => 'c:/temp.txt' );

Notice that I also changed %captureHash and %filterHash to \%captureHash and \%filterHash so they are passed as references instead of flattening into lists.

To access nested elements, you can do something like $args{twigs}{filter}. For more, see perlreftut and perldsc.

Replies are listed 'Best First'.
Re^2: Optional and default parameters for a subroutine
by ramya2005 (Scribe) on Aug 29, 2005 at 20:25 UTC
    I didn't notice that I passed a hash referece..Thanks for pointing out the mistake!
    Your code works! Thanks once again.