Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion faster execution
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
venus  
View profile  
 More options Sep 24 2001, 4:16 am
Newsgroups: comp.lang.perl.misc
From: train2ve...@hotmail.com (venus)
Date: 24 Sep 2001 01:16:27 -0700
Local: Mon, Sep 24 2001 4:16 am
Subject: faster execution
Hi all,

I wrote a perl script but I'm not sure if there's a better way of
doing it.
The script runs very slow because the input file (txt file) I'm
reading from is very big. The script reads the input text file and if
it finds any location that equals to the list in array, it will
replace it with location code.
Here's a part of the script:

...
....

        %LOCATION = (
        'Gaborone,,BC',                 "GBE",
        'Cairo,,EG',                    "CAI",
        'Nairobi,,KN',                  "NBO",
        'Dar es Salaam,,TN',            "DAR",
        'Kampala,,UG',                  "KLA",
        'Cape Town,,ZA',                        "CPT",
        'Johannesburg,,ZA',                     "JNB",
        'Pretoria,,ZA',                 "PRY",
        'Harare,,ZW',                   "HRE",
        'Windhoek,,NM',                 "ERS",

        'London,,UK',                   "LON",
        'Vienna,,OS',                   "VIE",
        'Brussels,,BX',                 "BRU",
        'Copenhagen,,DN',                       "CPH",
        'Berlin,,DL',                   "BER",
        'Frankfurt,,DL',                        "FRA",
        'Athens,,GR',                   "ATH",
        'Tallinn,,EO',                  "TLL",
        'Dublin,,IE',                   "DUB",
        'Madrid,,SP',                   "MAD",
         );

        while (<INPUT_FILE>) {
        chomp;
        ( $city, $state, $country, @data ) = split(/,/);
         $location = "$city,$state,$country";
         if ( defined @data[0] && ! defined $StartDD ) {
                $StartDD = @data[0];
          }
           $day3 = $data[8];   $max3 = $data[9];       $min3 = $data[10];  
   $wx3 = $CONDITION{$data[11]};

         foreach $location_name (%LOCATION ) {
                $location_code = $LOCATION{$location_name};

                if ($location_name eq $location ) {

                printf FILE "$location_code\,";
                        printf FILE "%4s", "$min3\,";
                        printf FILE "%4s", "$max3\,";
                        printf FILE "%1s", "$wx3\n";

                }      

        }
        close(INPUT_FILE);
        close(FILE);
        }

Thanks in advance.
Regards,
Venus


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.