in reply to Tidier and more efficient parsing code
One of MJD's red flags: whenever you've got variables named $fooone and $footwo you probably want an array. Likewise here, you've got multiple arrays named with indicies which means you probably want a hash.
my $cur_section = 0; my %sections; while( <TEXTFILE> ) { if( /^;section(\d+)/ ) { $cur_section = $1; next; } unless( $cur_section ) { warn "No section defined for `$_'\n"; next } push @{ $sections{ $cur_section } }, $_ }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Tidier and more efficient parsing code
by JPaul (Hermit) on Jan 24, 2002 at 21:49 UTC |