in reply to Seperating Fixed Line Feed into Fields

I'd say you'd definitely want to unpack, as JavaFan mentioned. Something similar to:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $rcount = 1; while (<DATA>) { my $string = $_; next if $rcount++ < 8; my @fields = unpack ('A34 A30 A40', $string); print Dumper(@fields), "\n"; } __DATA__ Ignore Me Line 1 Ignore Me Line 2 Ignore Me Line 3 Ignore Me Line 4 Ignore Me Line 5 Ignore Me Line 6 Ignore Me Line 7 This is a very long sentence which should illustrate the unpacking fun +ctionality in accordance to what you require.
Outputs:
$VAR1 = 'This is a very long sentence which'; $VAR2 = ' should illustrate the unpacki'; $VAR3 = 'ng functionality in accordance to what y';
For writing excel spreadsheets, Spreadsheet::WriteExcel does the trick for me.

Replies are listed 'Best First'.
Re^2: Seperating Fixed Line Feed into Fields
by drodinthe559 (Monk) on Jun 10, 2009 at 20:38 UTC
    Now, that works but every time it loops through it adds to the array instead of creating a new index.
      If you want to save the array off each time (it didn't look like you were doing that in your original code) you can declare an array outside of the loop and push the arrayref of the fields into that larger array. e.g.
      my @big_list_of_fields; while (<DATA>) { ... # unpacking here ... push @big_list_of_fields, \@fields; }
      Edit: I may be reading your question incorrectly. It should declare a new @fields inside each loop iteration though, so there should be nothing added to the array, it's a fresh array each iteration.
        Thank you, that worked. This is a huge improvement than what I had before. Not that I'm thinking about it, I should be able to go from unpack into Excel spread sheet right?