diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2002-07-23 12:24:09 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2002-07-23 12:24:09 +0000 |
commit | 2878efe1d9cee58887489257b8a677ac29879931 (patch) | |
tree | 23e48ce7224412b0403dce4cd53c6494e47a3089 | |
parent | 938d42ec4730ab52eab8df881415944d05c02494 (diff) | |
download | perl-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
-rw-r--r-- | MDK/Common/DataStructure.pm | 10 | ||||
-rw-r--r-- | perl-MDK-Common.spec | 6 |
2 files changed, 14 insertions, 2 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 } diff --git a/perl-MDK-Common.spec b/perl-MDK-Common.spec index 2b80bea..38ddb92 100644 --- a/perl-MDK-Common.spec +++ b/perl-MDK-Common.spec @@ -2,7 +2,7 @@ # do not change the version here, change in MDK/Common.pm.pl %define version THEVERSION -%define release 4mdk +%define release 5mdk Summary: Various simple functions Name: perl-MDK-Common @@ -49,6 +49,10 @@ rm -rf $RPM_BUILD_ROOT # MODIFY IN THE CVS: cvs.mandrakesoft.com:/cooker soft/perl-MDK-Common %changelog +* Tue Jul 23 2002 Pixel <pixel@mandrakesoft.com> 1.0.3-5mdk +- perl_checker: catch misuse of =~ when = was meant +- MDK/Common/DataStructure.pm: add deref_array + * Wed Jul 17 2002 Pixel <pixel@mandrakesoft.com> 1.0.3-4mdk - perl_checker: add new checks - perl_checker: exclude Date::Manip |