in reply to Re: printing contents of small files into one larger one
in thread printing contents of small files into one larger one
If the only goal here is to print out the data, I would do it holli's way. Reading all the files into memory into one big data structure wouldn't scale very well.
#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my @files = glob('data/*'); my %filedata; for my $file (@files) { open my $fh, "<$file" or die "Ack, Can't open $file"; chomp( my @data = <$fh> ); close $fh; $filedata{$file} = \@data; } print Dumper(\%filedata);
$VAR1 = { 'test/bb' => [ '5.6', '5.7', '5.9' ], 'test/aa' => [ '1.3', '1.4', '1.5' ] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: printing contents of small files into one larger one
by inman (Curate) on Nov 09, 2005 at 17:12 UTC |