in reply to Re: Seperating Fixed Line Feed into Fields
in thread Seperating Fixed Line Feed into Fields

Thanks, JohnGG. Your suggestions made a huge improvement to the script. Moreover, you showed me several better techniques I can utilize. When I first started writing it, I knew it could be way better; hence the posting. I think I am going to take a breather now and work on generating the file to excel. Since you skipped the set of rows, I can leave out $rcount. Below is how it looks now. Thanks, Dave
use strict; use warnings; use Win32::OLE; my $ex = Win32::OLE->new('Excel.Application') or die "oops\n"; my $book = $ex->Workbooks->Add; my $sheet = $book->Worksheets(1); my $inputFile = q{c:/INPUT.TXT}; open my $inputFH, q{<}, $inputFile or die qq{open: < $inputFile: $!\n} +; my $outputFile = q{C:/OUTPUT.TXT}; open my $outputFH, q{>}, $outputFile or die qq{open: > $outputFile: $! +\n}; { local $/ = \1173; my $discard = <$inputFH> for 1 .. 7; while (<$inputFH>) { $rcount ++; $sheet->Range("A1:CD100")->{value} = unpack("A34 A30 A40 A40 +A40 A40 A40 A2 A9 A9 A6 A40 A34 A3 A8 A1 A1 A10 A20 A10 A34 A15 A15 A15 A8 A8 A8 A8 A3 A3 A +40 A10 A7 A20 A7 A15 A5 A8 A20 A15 A15 A15 A15 A15 A15 A1 A4 +0 A5 A8 A1 A3 A3 A3 A20 A10 A1 A15 A15 AA50 A1 A8 A1 +0 A1 A7 A3 A7 A1 A1 A15 A8 A15 A3 A15 A8 A20 A6 A6 A +20 A15 A15 A15 A40 A15", $_); } } close $inputFH; close $outputFH; $book->SaveAs('C:\test.xls'); undef $book; undef $ex;