I wanted to populate an anon array with stat from a file, with labels.... so..
#!/usr/bin/perl -w use strict; use List::MoreUtils qw(:all); use Smart::Comments; my @labels =qw(dev ino mode nlink uid gid rdev size atime mtime ctime +blksize blocks); my @stat = stat "/tmp"; my $stat = { zip @labels, @stat}; ### $stat
That works great. Prints out :
### $stat: {
### atime => 1156789541,
### blksize => 4096,
### blocks => 32,
### ctime => 1156791103,
### dev => 64768,
### gid => 0,
### ino => 2684353,
### mode => 17407,
### mtime => 1156791103,
### nlink => 15,
### rdev => 0,
### size => 12288,
### uid => 0
### }
But why declare the arrays in the fist place? ...
#!/usr/bin/perl -w use strict; use List::MoreUtils qw(:all); use Smart::Comments; my $stat = { zip qw(dev ino mode nlink uid gid rdev size atime mtime ctime blksize bl +ocks), ( stat '/tmp' ) }; # No! Don't like that! ### $stat
gives:
Type of arg 1 to List::MoreUtils::mesh must be array (not list) at tmp +.pl line 16, near "} }"
I can't figure out the correct way/syntax to have zip/mesh interpret these as arrays :( - Array? Not list? does this mean we must predeclare as an array?
In reply to using List::MoreUtils::zip with anon arrays ? by leocharre
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |