in reply to Re^3: Constructing a hash with filepath,filename and filerev
in thread Constructing a hash with filepath,filename and filerev
I am trying to output the hash to a file "hash_glf.txt",using the following code,the file given as input is 40,000 lines.It takes a lot of time to outpuf to "hash_glf.txt",if I change the input file to some 100 lines,I can see the hash structure being output'ed to hash_glf.txt immediately.Is there a way I can quicken the script to output to the file quickly?
#!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; my %files_by; print "Enter File1 "; my $file1_name = <>; chomp($file1_name); open my $DATA, '<', $file1_name or die "Cannot open file 1\n"; while (<$DATA>) { my ($file_path, $file_name, $version) = m{^(.*/(.*))#(\d+)$}; push @{ $files_by{$file_name} }, { file_path => $file_path, version => $version, }; } open my $hash_glf, '>', "hash_glf.txt"; print $hash_glf Dumper( \%files_by ); close $DATA;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Constructing a hash with filepath,filename and filerev
by graff (Chancellor) on Dec 11, 2010 at 19:08 UTC |