hi father !
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 = 2; my $line = ''; my $device; open inFile, '<', 'logs.txt' or die "Couldn't open data.txt: $!"; while (! eof inFile) { $line .= ' ' . <inFile>; chomp $line; next if ! ($line =~ /logging\sto\s(.*?)\s+/i) and ! eof inFile; my $nextDevice = $1; if #($line =~ /(\d+)%\s+\/var\s+(\d+).*?(\d+)%\s+Interleaved\s+.* +?avm\s+.*?fre\s+.*?cs\s+.*?us\s+.*?sy\s+.*?id\s+.*?(\d+)\s+(\d+)\s+(\ +d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\w+)/i) ($line =~ /(\d+)%\s+\/var\s+(\d+).*?(\d+)%\s+Interleaved\s+.*?avm +\s+.*?fre\s+.*?cs\s+.*?us\s+.*?sy\s+.*?id\s+.*?GMT\s+(\d\d:\d\d:\d\d) +\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d\d):(\d\d):(\d\d)\s+(\w+)/i) #($line =~ /(\d+)%\s+\/var\s+(\d+).*?(\d+)%\s+Interleaved\s+.*?avm +\s+.*?fre\s+.*?id\s+.*?\s+(\d+)\s+(\d+)\s+(\w+)/i) #($line =~ /(\d+)%\s+\/var\s+(\d+).*?(\d+)%\s+Interleaved\s+(\ +w+)/i) { $worksheet->write("A$row", "$device"); $worksheet->write("B$row", "$1"); $worksheet->write("C$row", "$2"); $worksheet->write("D$row", "$3"); $worksheet->write("E$row", "$4"); $worksheet->write("F$row", "$5"); $worksheet->write("G$row", "$6"); $worksheet->write("H$row", "$7"); $worksheet->write("I$row", "$8"); $worksheet->write("j$row", "$9"); $worksheet->write("j$row", "$10"); ++$row; print "$device $1, $2, $3, $4, $5, $6, $7, $8, $9, $10\n"; } $device = $nextDevice; $line = ''; } close inFile; $workbook->close ();
is my final code and i couldn't get the date stamp. that's the only problem !

In reply to Re^8: new : greping by pingme8705
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.