On Monday, May 6, 2002, at 10:34 , Lance Prais wrote:

> sub createUniquePartitionFile {
>       my %args = (
>               PARTITION => '',
>               PARTITIONFILE => '',
>               OUTPUTFILENAME => '',
>               @_,
>       );
>       $status = 0;
>       $partitionFile = $args{PARTITIONFILE};
>       $outputFileName = $args{OUTPUTFILENAME};
>       # Message
>       print "topten: Creating a unique solution file for [$partition].\n";
>       # Remove existing output file
>       $command_string = "/usr/bin/rm -f " . $outputFileName;
>       $status = `$command_string`;
>
>       $command_string = "sort -u " . $partitionFile . " \> " . 
> $outputFileName;
>       $status = `$command_string`;
>
>       return  $status;
> }


the benchmarks for jonathan's proposals are at:

http://www.wetware.com/drieux/CS/lang/Perl/Beginners/BenchMarks/uniqDeList.
txt

but think a bit about what your 'function' here should be doing..

I'm very confused by the idea of

        my %args = (
                PARTITION => '',
                PARTITIONFILE => '',
                OUTPUTFILENAME => '',
                @_,
        );

why not the simpler

        my ( $outputFile, $partitionFile, $partition) = @_;

and save on the re-assignment to those variables from the
way interesting %arg???

also you are using perl as if it were /bin/sh -


        $command_string = "/usr/bin/rm -f " . $outputFileName;
        $status = `$command_string`;

vice say

        unlink $outputFileName if ( -f $outputFileName );

which does not require a fork of an external command...

If you have the dope already in memory, why not stay in memory
rather than buying the file IO AND the forks???

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to