in reply to Re: File parsing query
in thread File parsing query
Updated: to correct errors noticed by Animator (who answered the original question first as well :) ).my $widgetsFound=0; my $databaseName; my $databaseSection; while( <> ) { if( /^DATABASE:/ ) { if( $databaseName ) { print $databaseName; print "Widgets found: $widgetsFound\n"; print $databaseSection; } $databaseName = $_; $databaseSection = ""; $widgetsFound = 0; } else { $databaseSection .= $_; } if( $something ) { $widgetsFound++; } } # print the last database section that was parsed if( $databaseName ) { print $databaseName; print "Widgets found: $widgetsFound\n"; print $databaseSection; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: File parsing query
by Animator (Hermit) on Feb 16, 2005 at 21:03 UTC |