Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: store multiple files in multidimensional array

by repellent (Priest)
on Mar 19, 2012 at 02:06 UTC ( #960354=note: print w/replies, xml ) Need Help??


in reply to store multiple files in multidimensional array

If you're globbing as in @filesList = <*> or @filesList = glob "*", consider what the order of the files would be in the array. You may want it sorted:
bash-3.2$ cat d1 abc cde edf bash-3.2$ cat d2 rst tuv uvw bash-3.2$ cat d3 ghi hij jkl bash-3.2$ cat t4.pl my %data; while (<>) { chomp; push @{ $data{$ARGV} }, $_; } my @sorted_data = map $data{$_}, sort keys %data; use Data::Dumper; warn Dumper \@sorted_data; bash-3.2$ t4.pl * $VAR1 = [ [ 'abc', 'cde', 'edf' ], [ 'rst', 'tuv', 'uvw' ], [ 'ghi', 'hij', 'jkl' ] ];

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://960354]
help
Chatterbox?
[shmem]: sub wanted { push @files, $File::Find::name if $File::Find::name =~/\.mp3$/ }
[Lady_Aleena]: shmem, that is understandable! The two examples in File::Find don't make sense to me on a quick glance.
[marioroy]: LA if the find worked from Unix command line, or does it not. Likely a quoting issue inside Perl qx.
[Lady_Aleena]: marioroy, the find worked fine at the command line.
[marioroy]: LA, yeah. than there's no reason why it cannot work inside qx. But chatting is hard in PM. I cannot see the code now.
[shmem]: Lady_Aleena: sometimes a quick glance isn't enough.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2017-04-23 20:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.