Version of code that reads the data from a file. Data is identical to that in the __DATA__ section of my previous post.
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'); my $row = 2; open inFile, '<', 'data.txt' or die "Couldn't open data.txt: $!"; while (<inFile>) { my ($p1, $p2, $p3, $device) = /(?:\. ){3}(\d+)%\s\/var\s(\d+).*?(\d+ +)%\sInterleaved (\w+)/; $worksheet->write("A$row", $device); $worksheet->write("B$row", $p1); $worksheet->write("C$row", $p2); $worksheet->write("D$row", $p3); ++$row; print "$device $p1, $p2, $p3\n"; } $workbook->close (); close inFile;
In reply to Re: new : greping
by GrandFather
in thread new : greping
by pingme8705
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |