Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Constructive criticism of a dictionary / text comparison script

by TomDLux (Vicar)
on Aug 30, 2003 at 02:20 UTC ( #287867=note: print w/replies, xml ) Need Help??


in reply to Constructive criticism of a dictionary / text comparison script

Initializing variables to an empty string is generally no advantage. Why not collapse those declarations into one line?

my ( $help, $man, $version, $token_debug, $glossary_output, $dictionar +y_output ); # or my ( $help, $man, $version, $token_debug, $glossary_output, $dictionar +y_output ) = ( '', '', '', '', '', '' );

GetOptions will also take a reference to a hash as its first argument, instead of all the variables. Much more concise and you don't have to worry three pages down what that variable was called.

--
TTTATCGGTCGTTATATAGATGTTTGCA

  • Comment on Re: Constructive criticism of a dictionary / text comparison script
  • Download Code

Replies are listed 'Best First'.
Re: Re: Constructive criticism of a dictionary / text comparison script
by allolex (Curate) on Aug 30, 2003 at 05:58 UTC

    You put your finger right on a major problem: I didn't actually go through and fix things that were a result of adding features to the script over a few days. Your version is a lot more legible (and looks cooler) than mine. I think I'll take you last bit of advice and stick everything in a hash.

    --
    Allolex

Re: Re: Constructive criticism of a dictionary / text comparison script
by PodMaster (Abbot) on Oct 13, 2003 at 10:57 UTC
    If you're gonna initialize all those vars to the same value, you might as well do it using x, as in
    my( $help, $man, $version, $token_debug, $glossary_output, $dictionary_output ) = ('') x 6;

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://287867]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2020-07-12 17:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?