CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [Gorgarian] Need to speed up Perl script: Edit Log



wickedxter
User

Dec 18, 2012, 6:14 PM


Views: 1548
Re: [Gorgarian] Need to speed up Perl script


Code
#!/usr/local/bin/perl  

use strict;
use warnings;

my %temp_hash;
my @temp_array;

open my $file, '<', 'F.dump';
while (my $line = <$file>){
my($data,$hash_key) = split(/ /, $line);

$temp_hash{$hash_key} = $data if !$temp{$hash_key};

}
close $file;
@temp_array = keys %temp;

$a=($#temp_array+1)/2;
print "$a records from file F.dump read into linear array \n";
print " added to Female hash, now ".keys(%temp_hash)." records \n";
undef @temp_array;


try this and let me know... this will skip all keys that already exists so if you have a key of 28 in the file already and 28 around the end of the file it will skip the data of the second one.

is that all the code of the script?


(This post was edited by wickedxter on Dec 18, 2012, 6:18 PM)


Edit Log:
Post edited by wickedxter (User) on Dec 18, 2012, 6:18 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives