summaryrefslogtreecommitdiffstats
path: root/MDK
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-07-23 12:24:09 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-07-23 12:24:09 +0000
commit2878efe1d9cee58887489257b8a677ac29879931 (patch)
tree23e48ce7224412b0403dce4cd53c6494e47a3089 /MDK
parent938d42ec4730ab52eab8df881415944d05c02494 (diff)
downloadperl-MDK-Common-2878efe1d9cee58887489257b8a677ac29879931.tar
perl-MDK-Common-2878efe1d9cee58887489257b8a677ac29879931.tar.gz
perl-MDK-Common-2878efe1d9cee58887489257b8a677ac29879931.tar.bz2
perl-MDK-Common-2878efe1d9cee58887489257b8a677ac29879931.tar.xz
perl-MDK-Common-2878efe1d9cee58887489257b8a677ac29879931.zip
MDK/Common/DataStructure.pm: add deref_array
Diffstat (limited to 'MDK')
-rw-r--r--MDK/Common/DataStructure.pm10
1 files changed, 9 insertions, 1 deletions
diff --git a/MDK/Common/DataStructure.pm b/MDK/Common/DataStructure.pm
index e4b04b4..f139555 100644
--- a/MDK/Common/DataStructure.pm
+++ b/MDK/Common/DataStructure.pm
@@ -47,6 +47,13 @@ whereas C<scalar f()> would return "b"
de-reference
+=item deref_array(REF)
+
+de-reference arrays:
+
+ deref_array [ "a", "b" ] #=> ("a", "b")
+ deref_array "a" #=> "a"
+
=item is_empty_array_ref(SCALAR)
is the scalar undefined or is the array empty
@@ -99,7 +106,7 @@ use MDK::Common::Func;
use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK);
@ISA = qw(Exporter);
-@EXPORT_OK = qw(ikeys add2hash add2hash_ put_in_hash member invbool listlength deref is_empty_array_ref is_empty_hash_ref uniq difference2 intersection next_val_in_array group_by2 list2kv);
+@EXPORT_OK = qw(ikeys add2hash add2hash_ put_in_hash member invbool listlength deref deref_array is_empty_array_ref is_empty_hash_ref uniq difference2 intersection next_val_in_array group_by2 list2kv);
%EXPORT_TAGS = (all => [ @EXPORT_OK ]);
@@ -112,6 +119,7 @@ sub invbool { my $a = shift; $$a = !$$a; $$a }
sub listlength { scalar @_ }
sub strcpy { substr($_[0], $_[2] || 0, length $_[1]) = $_[1] }
sub deref { ref $_[0] eq "ARRAY" ? @{$_[0]} : ref $_[0] eq "HASH" ? %{$_[0]} : $_[0] }
+sub deref_array { ref $_[0] eq "ARRAY" ? @{$_[0]} : $_[0] }
sub is_empty_array_ref { my $a = shift; !defined $a || @$a == 0 }
sub is_empty_hash_ref { my $a = shift; !defined $a || keys(%$a) == 0 }