Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Tidier and more efficient parsing code

by Fletch (Bishop)
on Jan 24, 2002 at 08:58 UTC ( [id://141141]=note: print w/replies, xml ) Need Help??


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
    Technically, the arrays are called @predecl, @precode, @header, @main and @trailer.
    But I get the point :)

    JP,
    -- Alexander Widdlemouse undid his bellybutton and his bum dropped off --

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 13:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found