Ref::List - Punctuation-free dereferencing of arrayrefs and hashrefs
version 0.002
use Ref::List qw(list); my $data = { countries => [ { name => 'Bulgaria', language = 'Bulgarian' }, { name => 'Germany', language = 'German' }, ], }; print $_->{name} for list $data->{countries};
This tiny module exports a single function, list, which dereferences the arrayref or hashref passed to it as an argument. list $argument is basically a synonym for @{$argument}, but is less awkward when $argument is a longer expression part of a nested data structure and may appeal to people with a dislike of punctuation overuse.
list
list $argument
@{$argument}
$argument
As of perl 5.14 you should be using the built-in values function instead.
values
Given a hash or array reference, dereference it and return its contents as a list. If the argument is undef, returns undef.
undef
Peter Shangov <pshangov@yahoo.com>
This software is copyright (c) 2011 by Peter Shangov.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Ref::List, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ref::List
CPAN shell
perl -MCPAN -e shell install Ref::List
For more information on module installation, please visit the detailed CPAN module installation guide.