Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Splitting Multiple files into arrays.

by jwkrahn (Monsignor)
on Jul 20, 2013 at 21:49 UTC ( #1045474=note: print w/ replies, xml ) Need Help??


in reply to Splitting Multiple files into arrays.

I am trying to read a file and split(by space) into an array called values and finally puttin it into a array table.I am able to do it for a single file but i want to split 8 files in a loop one after the other into 8 different arrays..table1 table2....table 8. But the following code below is not working. Please advise. for (my $i = 1 ;$i <=8; $i++) { open (MYFILE,"server$i"); while (<MYFILE>) { chomp; my @values = split " ",$_; push @{ "table$i"},\@values; } }
use warnings; use strict; @ARGV = map "server$_", 1 .. 8; my %data; while ( <> ) { push @{ $data{ $ARGV } }, [ split ]; }


Comment on Re: Splitting Multiple files into arrays.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045474]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2015-07-31 14:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls