leocharre has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using List::MoreUtils::zip with anon arrays ?
by Tanktalus (Canon) on Aug 28, 2006 at 20:05 UTC | |
by leocharre (Priest) on Aug 28, 2006 at 20:12 UTC | |
|
Re: using List::MoreUtils::zip with anon arrays ?
by stvn (Monsignor) on Aug 28, 2006 at 21:39 UTC | |
|
Re: using List::MoreUtils::zip with anon arrays ? (&)
by tye (Sage) on Aug 28, 2006 at 20:17 UTC | |
|
Re: using List::MoreUtils::zip with anon arrays ?
by philcrow (Priest) on Aug 28, 2006 at 20:11 UTC | |
|
Re: using List::MoreUtils::zip with anon arrays ?
by nothingmuch (Priest) on Aug 28, 2006 at 21:16 UTC | |
by leocharre (Priest) on Aug 29, 2006 at 14:40 UTC | |
by nothingmuch (Priest) on Aug 30, 2006 at 12:22 UTC |