Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hirokidaichi/p5-data-destructuring-assignment
harmony's destructuring assignment for perl5
https://github.com/hirokidaichi/p5-data-destructuring-assignment
Last synced: 7 days ago
JSON representation
harmony's destructuring assignment for perl5
- Host: GitHub
- URL: https://github.com/hirokidaichi/p5-data-destructuring-assignment
- Owner: hirokidaichi
- Created: 2012-05-10T05:57:52.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-05-11T02:31:31.000Z (over 12 years ago)
- Last Synced: 2024-04-20T19:51:50.727Z (7 months ago)
- Size: 129 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NAME
Data::DestructuringAssignment - harmony's destructuring assignment for
perl5SYNOPSIS
use Data::DestructuringAssignment qw/destruct/;
destruct([\my $hoge,\my $fuga]) = [10,20];
print "hoge is $hoge";# hoge is 10
print "fuga is $fuga";# fuga is 20destruct( \my $hoge ) = 10;
destruct( [\my $a ,\my $b] ) = [1,2];
destruct( { hash => \my $hash } ) = { hash => [1,2,3]};
my @array = map{ +{ hoge => "$_",fuga => $_ * 2}} (1..10);
while(destruct({ hoge => \my $hoge } ) = shift @array) {
# $hoge..;
}
my @array = map{ +{ hoge => "$_",fuga => $_ * 2}} (1..10);
for my $elem (@array){
destruct({ hoge => \my $hoge, fuga => \my $fuga}) = $elem;
}
my $template = { hoge => 1,fuga => 2};
if( destruct({ hoge => \my $hoge ,piyo => \my $fuga }) = $template ){
::pass 'matched any';
}else {
# not come here
}DESCRIPTION
Data::DestructuringAssignment provides harmony's destructuring
assignment for perl5AUTHOR
Daichi HirokiSEE ALSO
LICENSE
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.