diff options
author | Olivier Blin <oblin@mandriva.org> | 2005-11-15 16:00:42 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2005-11-15 16:00:42 +0000 |
commit | 06a335b68dc2cf67704e9b9367e9b7a256eebd8e (patch) | |
tree | 81dc5fce55850722e35ac1ee0da09a08a90dd903 | |
parent | 4ea2af164dd4b7e2b4d5ca5e2df573403db4bfc9 (diff) | |
download | perl-MDK-Common-06a335b68dc2cf67704e9b9367e9b7a256eebd8e.tar perl-MDK-Common-06a335b68dc2cf67704e9b9367e9b7a256eebd8e.tar.gz perl-MDK-Common-06a335b68dc2cf67704e9b9367e9b7a256eebd8e.tar.bz2 perl-MDK-Common-06a335b68dc2cf67704e9b9367e9b7a256eebd8e.tar.xz perl-MDK-Common-06a335b68dc2cf67704e9b9367e9b7a256eebd8e.zip |
inline unneeded cat_a_file() in cat_(), simplify using map (perl_checker could have detected this push/map like structure)
-rw-r--r-- | MDK/Common/File.pm | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/MDK/Common/File.pm b/MDK/Common/File.pm index 7aea145..661ddc3 100644 --- a/MDK/Common/File.pm +++ b/MDK/Common/File.pm @@ -132,8 +132,7 @@ our %EXPORT_TAGS = (all => [ @EXPORT_OK ]); sub dirname { local $_ = shift; s|[^/]*/*\s*$||; s|(.)/*$|$1|; $_ || '.' } sub basename { local $_ = shift; s|/*\s*$||; s|.*/||; $_ } -sub cat_a_file { open(my $F, $_[0]) or return; my @l = <$F>; @l } -sub cat_ { my @l; @l = (@l, cat_a_file($_)) foreach @_; wantarray() ? @l : join '', @l } +sub cat_ { my @l = map { my $F; open($F, $_) ? <$F> : () } @_; wantarray() ? @l : join '', @l } sub cat_or_die { open(my $F, $_[0]) or die "can't read file $_[0]: $!\n"; my @l = <$F>; wantarray() ? @l : join '', @l } sub cat__ { my ($f) = @_; my @l = <$f>; wantarray() ? @l : join '', @l } sub output { my $f = shift; open(my $F, ">$f") or die "output in file $f failed: $!\n"; print $F $_ foreach @_; 1 } |