in reply to Re^3: new : greping
in thread new : greping

hi father !
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 504956 19880 32 3 24 72 device2 Tue Sep 5 10:26:44 GMT 2005 logging to device5-PPP is 2.3.5.1 . . . 156% /var 138% / 131% Interleaved disks faults avm fre cs us sy id 504956 19880 32 3 24 72 device5-PPP Tue Sep 9 11:26:44 ist 2005 logging to device8-PPm is 2.3.5.1 . . . 596% /var 688% / 100% Interleaved disks faults avm fre cs us sy id 504956 19880 32 3 24 72 device8-PPm Tue Sep 5 10:26:44 GMT 2005
if i want to take the avm fre id and its corresponding values and also the time in the text. wat should i do father ?

Replies are listed 'Best First'.
Re^5: new : greping
by GrandFather (Saint) on Sep 08, 2005 at 11:03 UTC

    As you will have seen the lines in each record are concatenated together to form one long line then the regex /(\d+)%\s+\/var\s+(\d+).*?(\d+)%\s+Interleaved\s+(\w+)/ is used to pull out the data of interest. You simply need to add more capture fields to gather the extra data and then to print that in the print "$device $1, $2, $3\n"; line and in extra $worksheet->write("D$row", "$3"); lines.

    See perlretut, perlre and perlreref for regular expression information.


    Perl is Huffman encoded by design.
      hello father ! i have tried with the following line:   ($line =~ /(\d+)%\s+\/var\s+(\d+).*?(\d+)%\s+Interleaved\s+.*?avm\s+fre\s+(\d+)\s+(+\d)+\s+(\w+)/i) i have also added the print lines as said by you !
      $worksheet->write("E$row", "$4"); print "$device $1, $2, $3, $4\n";
      but still no go !

        You should reread the regex documentation. Take particular note of what \d matches and what \w matches. I think then you will see the problem for yourself.


        Perl is Huffman encoded by design.