in reply to Re: Good practice: Variable declaration
in thread Good practice: Variable declaration

That's fine. You could be spiffy and write it like:
my %class = qw( n Noun v Verb );
my $word = ($class{$part} || "Adjective")->new(...);

Spiffier.

my $word = ({ qw/n Noun v Verb/ }->{$part} || 'Adjective')->new(...);

- Yes, I reinvent wheels.
- Spam: Visit eurotraQ.

Replies are listed 'Best First'.
Re: Re: Re: Good practice: Variable declaration
by japhy (Canon) on Jun 27, 2002 at 17:13 UTC
    I changed my code from that because that doesn't lend itself to repetition. Easier to change one data structure than many lines of code. Although I un-abstracted from what I had originally:
    my %class = qw( n Noun v Verb ); my $default = 'Adjective'; ...

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;