>>>>> "PP" == Philip Potter <philip.g.pot...@gmail.com> writes:
PP> my %readfsgs_flags; PP> my @flags_to_copy = qw(limit); # can scale up by adding more hash keys here PP> @readfsgs_fla...@flags_to_copy} = @{$flag...@flags_to_copy}; PP> my @results = readfsgs($testfilename, \%readfsgs_flags); PP> } PP> but this has a bug: if $flags doesn't contain limit, %readfsgs_flags PP> will contain (limit => undef); ie $readfsgs_flags will exist but be PP> undefined. It shouldn't exist. easy fix. just grep through all the keys you want and test for exists. my @flags_to_copy = grep { exists( $flags->{$_} } qw(limit); then the slice works as you have it and you only get flags you are interested in and also that exists coming in. you can also simplify the copy a little with a hash ref: my $readfsgs_flags = { map { $_ => $flags->{$_} } @flags_to_copy } ; and if you feel like really combining lines (not so great in this case): my $readfsgs_flags = { map { $_ => $flags->{$_} } grep { exists( $flags->{$_} } qw(limit) ; or another cleaner way would be to put the exists inside the map: my $readfsgs_flags = { map { ( exists( $flags->{$_} ) ? $_ => $flags->{$_} : () } qw(limit) ; uri -- Uri Guttman ------ u...@stemsystems.com -------- http://www.sysarch.com -- ----- Perl Code Review , Architecture, Development, Training, Support ------ --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/