convenientstore has asked for the wisdom of the Perl Monks concerning the following question:
hi folks,
below is part of my existing program(below code NOT tested) and wanted to write this in different style(or more efficient)... I just don't like the fact that I have strings of if statement like this.. any other(better) ways to write this?
below is part of my existing program(below code NOT tested) and wanted to write this in different style(or more efficient)... I just don't like the fact that I have strings of if statement like this.. any other(better) ways to write this?
use warnings; use strict; my ($newyork,$miami); while (<DATA>) { if ( $_ =~ /^NEW YORK:\s+(\S+)/ ) { $newyork = $1; $newyork = $newyork || 'NA'; next; } if ( $_ =~ /^MIAMI:\s+(\S+)/ ) { $miami = $1; $miami = $miami || 'NA'; next; } } __END__ NEW YORK: knicks CHICAGO: bulls MIAMI: heat LA: lakers
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Please fix my writing style
by dragonchild (Archbishop) on Nov 22, 2008 at 04:53 UTC | |
Re: Please fix my writing style
by jwkrahn (Abbot) on Nov 22, 2008 at 02:10 UTC | |
Re: Please fix my writing style
by hydo (Monk) on Nov 22, 2008 at 03:10 UTC | |
by blazar (Canon) on Nov 23, 2008 at 23:24 UTC | |
Re: Please fix my writing style
by juster (Friar) on Nov 22, 2008 at 07:38 UTC | |
by convenientstore (Pilgrim) on Nov 22, 2008 at 16:43 UTC | |
by juster (Friar) on Nov 22, 2008 at 19:48 UTC | |
by convenientstore (Pilgrim) on Nov 23, 2008 at 03:53 UTC | |
by convenientstore (Pilgrim) on Nov 22, 2008 at 16:40 UTC |
Back to
Seekers of Perl Wisdom