Hello, I have a question about how to split a line into an array or hash... I have listed a small example of my ascii text file output... (The format of the ascii file has Tabs and spaces mixed with-in it But I don't seem to be able to post it with the tabs in)

Group Name A/C G F Start-Time End-time H/M/S MB +s Files L Kb/sec ====================================================================== +======================= dbweb.cloneuhn C 1 0 14 20:00:00 14 20:00:11 0/0/11 0 +.00 0 s 0.00 1 dbweb.uhn C 1 0 14 20:00:00 14 20:10:05 0/10/5 351 +.00 88 i 594.09 2 dbweb.clonedv6 C 1 0 14 21:30:00 14 21:30:08 0/0/8 0 +.00 0 s 0.00 3 dbweb.imdv C 1 0 14 17:01:00 14 22:06:05 5/5/5 10842 +4.00 101636 f 6065.35 4 dbweb.clonedv7 C 1 0 14 23:05:00 14 23:05:07 0/0/7 0 +.00 0 s 0.00 5 dbweb.clonedv2 C 1 0 14 23:10:00 14 23:10:03 0/0/3 0 +.00 0 s 0.00 6 dbweb.dv3 C 1 0 14 22:00:00 14 23:16:37 1/16/37 31002 +.00 156 i 6905.82 7 dbweb.clonedv5 C 1 0 14 23:20:00 14 23:20:03 0/0/3 0 +.00 0 s 0.00 8 dbweb.clonebaa1 C 1 0 15 13:05:00 15 13:05:03 0/0/3 0 +.00 0 s 0.00 9 dbweb.dv8 C 1 0 15 13:10:00 15 13:10:03 0/0/3 0 +.00 0 s 0.00 10 ====================================================================== +=======================

This small example is the output from a backup software tool. All of the information that I am trying to extract is listed on each line of this report... I seem to be brain dead figuring out how to split each line into an array (do I count the spaces between each element of data..?) I have captured each line that I need from the ascii file (listed in example below)...

$file = "c:\\somepath\\somefilename"; open (FILE, "<$file") or die "Cannot open $FILE for read :$!"; @lines = <FILE>; close(FILE); for($i=0;$i<@lines;$i++) { if ($lines[$i] =~ /\bdbweb./) { chomp($templine = $lines[$i]); push(@newarry, $templine); } }

I need to extract the Group name, F (failure 0 or 1), start-time, end-time, h/m/s and MB's. I was thinking that splitting each line into an array is the correct approch for extracting the required data...
Does anyone have some input to push me into the right direction..?
Thank you... Darrick...

Edit by tye, put CODE tags around fix-width text


In reply to splitting a line into an array by dbrock

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.