($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+(\w+)/i)
Your cdoe works fine, except that last (\w+) is $9, which is "72" (the 'id' value) .. you're not capturing the date string at all.. if you just change it to:
$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+.*?(\d\d):(\d\d):(\d\d)/i print "$device $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12\n";
you get the hour/min/sec at the end ...

You might, however, consider a different approach to making the parsing easier:
use strict; use warnings; my @devices; while( my $line = <DATA> ){ next unless $line =~ /^\s*logging to (\w+) is ([0-9.]+) . . ./; my %device = ( name => $1, ip => $2, partitions => [], ); do { $line = <DATA>; } until $line =~ /\S/; while( $line =~ /^(\d+)%\s+(\S+)/ ){ push @{$device{partitions}}, { name => $2, pct_used => $1 }; $line = <DATA>; } warn "Expected 'disks faults' line" unless $line =~ /disks faults/; $line = <DATA>; chomp($line); warn "Expected 'avm fre cs us sy id' line" unless $line =~ /avm fre +cs us sy id/; my @cols = split ' ', $line; warn "wrong number of columns" unless scalar(@cols)==6; $line = <DATA>; chomp($line); warn "Expected numbers on '$line'" unless $line =~ /(\d+ ){5}\d+/ && + $line !~ /[^0-9 ]/; my @vals = split ' ', $line; warn "wrong number of values" unless scalar(@vals)==6; @{$device{attributes}}{ @cols } = @vals; $line = <DATA>; chomp $line; warn "Expected device name on '$line'" unless $line eq $device{name} +; $line = <DATA>; chomp $line; if( $line =~ /(\d\d):(\d\d):(\d\d)/ ){ @{$device{date}}{ qw/hour minute second/ } = ( $1, $2, $3 ); }else{ warn "Couldn't parse date line: '$line'"; } push @devices, \%device; } use Data::Dumper; print Dumper \@devices; exit; __DATA__ logging to device1 is 2.3.5.1 . . . 56% /var 38% / 31% Interleaved disks faults avm fre cs us sy id 504956 19880 32 3 24 72 device1 Tue Sep 9 11:26:44 ist 2005 logging to device2 is 2.3.5.1 . . . 96% /var 88% / 100% Interleaved disks faults avm fre cs us sy id 5049 198 32 3 24 72 device2 Tue Sep 5 10:26:44 GMT 2005
(there's many ways to do this -- e.g. another way might be to do something clever with $/)

In reply to Re^3: matching the date and time by davidrw
in thread matching the date and time 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.