http://qs321.pair.com?node_id=725273

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?
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