Here is a different technique that avoids the nasty regex that was growing out of control:

use warnings; use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new("data.xls"); my $worksheet = $workbook->add_worksheet(); $worksheet->write ("A1", 'Device'); $worksheet->write ("B1", '/var'); $worksheet->write ("C1", '/'); $worksheet->write ("D1", 'interleaved'); $worksheet->write ("E1", 'avm'); $worksheet->write ("F1", 'fre'); $worksheet->write ("G1", 'cs'); $worksheet->write ("H1", 'us'); $worksheet->write ("I1", 'sy'); $worksheet->write ("J1", 'id'); $worksheet->write ("K1", 'Date'); my $row = 1; open inFile, '<', 'data.txt' or die "Couldn't open data.txt: $!"; while (<inFile>) { chomp; next if ! length $_; if (/logging to (.*?) is/i) { ++$row; $worksheet->write("A$row", "$_"); print "\n$1 "; next; } elsif (/logging to (.*?) is/i) {$worksheet->write("B$row", "$1");} elsif (/(\d+)% \/var/i) {$worksheet->write("C$row", "$1");} elsif (/(\d+)% \//i) {$worksheet->write("D$row", "$1");} elsif (/(\d+)% Interleaved/i) {$worksheet->write("E$row", "$1");} elsif (/(\d+) (\d+) (\d+) (\d+) (\d+) (\d+)/i) { $worksheet->write("F$row", "$1"); $worksheet->write("F$row", "$2"); $worksheet->write("F$row", "$3"); $worksheet->write("F$row", "$4"); $worksheet->write("F$row", "$5"); $worksheet->write("F$row", "$6"); print "$1 $2 $3 $4 $5 $6 "; next; } else {next;} print "$1 "; } close inFile; $workbook->close ();

Perl is Huffman encoded by design.

In reply to Re: new : greping by GrandFather
in thread new : greping by pingme8705

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.