in reply to pulling fields out of a ascii print file

Limbic~Region's solution is fine; I'm throwing mine in just for a slightly different point of view.
use strict; use warnings; my( $company, $co_id ); my $item; local $, = ","; local $\ = "\n"; while (<DATA>) { next unless /\S/; # ignore blank lines next if defined $item && /^ *Total \Q$item\E /; next if defined $co_id && /^ *Total \Q$company:$co_id\E /; if ( /^ *(.+):(\S+) *$/ ) { ( $company, $co_id ) = ( $1, $2 ); } elsif ( /^ *(\S+) *$/ ) { $item = $1; } else { my( $date, $person, $value ) = /^ {10}(.{10}) {5}(.*) +(\S+)/; $person =~ s/ +$//; $date =~ s/^ +//; print $co_id, qq("$company"), $item, qq("$date"), qq(" +$person"), $value; } } __DATA__ Slate Enterprises, Inc.:2001050.01 104 1/24/2002 Johnson, Dean A. 10.0 +0 1/24/2002 Botwell, Michael J 10.0 +0 Total 104 20.0 +0 302 1/25/2002 Beers, James T. 2.5 +0 1/28/2002 Beers, James T. 4.0 +0 1/29/2002 Beers, James T. 1.0 +0 1/30/2002 Beers, James T. 0.5 +0 Total 302 8.0 +0 Total Slate Enterprises, Inc.:2001050.01 28.0 +0
Since the desired output appears to be CSV, one might consider using the Text::CSV_XS module for formatting the output:
use Text::CSV_XS; my $csv = new Text::CSV_XS; . . . . . . $csv->combine( $co_id, $company, $item, $date, $person +, $value ); print $csv->string, "\n";

jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.