DP::Perl - several languange extensions


NAME

DP::Perl - several languange extensions


SYNOPSIS

  use DP::Perl qw( :ALL );

  ...
  ...

=head1 DESCRIPTION

EXPORT

nothing


FUNCTIONS

all_defined
 $bool = all_defined( @values )

Return FALSE if some of values in array are undefined
hf (hash filter)
 @values_by_filtered_keys = hf( $precompiled_regex, %hash_array )
 %hash_array_of_filtered_keys = %{hf( $precompiled_regex, %hash_array )}

EXAMPLE:

 %hash   = (key_ax=>'val_ax', key_ay=>'val_ay', key_bx=>'val_bx', key_by=>'val_by');
 @values = hf(qr/\w+/,%hash);
 %values = %{hf(qr/\w+/,%hash)};

=cut

### -------- sub hf ($\%) ### -------- { my( $re, $h ) = @_; if( wantarray ) { return @$h{grep(/$re/,keys(%$h))} } else { return {map(($_,$$h{$_}),grep(/$re/,keys(%$h)))} } }

set_hmv
 set_hmv( \%hash, $key, $val, [ $force_single ] );

set hash multi-value - for multiple appearances of same key are values stored as arrayref rather than direct value. Usefull when parsing cooikes or url with multiple param names.

$force_single set to 1 drops/replaces previously stored values with the $val for the $key specified.

SEE ALSO the get_hmv manpage

get_hmv
 get_hmv( \%hash, $key, [ $index ] );

get hash multi-value - counterpart for the set_hmv manpage.

TIP: use $index = -1 to get last value or other negative values to index from end of values array. (Same way as with common perl array)


FILES


REVISION

project started: 2003/05/09 >

 $Id: Perl.pm_rev 1.5 2004/01/08 11:10:30 root Exp root $


AUTHOR

 Daniel Peder
 <Daniel.Peder@Infoset.COM>
 http://www.infoset.com


SEE ALSO

 DP::Perl - several languange extensions