I have a text file which I managed to split the text and print out to an outfile but when it comes to the rest of data I do not know how to proceed.I am new to perl so sorry if I come off as I do not know what I am doing. I really trying to learn but this is very difficult for me.
my $infile = "COSC146_project01_dataset_2.txt"; #project input file. my $outfile = "fileoutput.txt"; # assigned an output file. open FILE,$infile or die "failed to open!"; #open project text. open OUT, ">fileoutput.txt" or die "failed to output!"; my $line = undef; #read line by line. Assigned global value to the sca +lar line. my $text = <FILE>; # Split on spaces. my @items = split ' ', $text; use Data::Dumper; #print Dumper(@items); print "$items[0]\t"; print "$items[2]\t"; print "$items[1]\t"; print "$items[3]\t"; print "$items[18]\t"; print "$items[23]\t"; print "$items[34]\t"; print "$items[36]\t"; print OUT "$items[0]\t"; print OUT"$items[2]\t"; print OUT"$items[1]\t"; print OUT "$items[3]\t"; print OUT"$items[18]\t"; print OUT "$items[23]\t"; print OUT"$items[34]\t"; print OUT "$items[36]\t";
^^^ is what I have. i have to generate a report for management that looks similar to this, but consolidates each set of four rows and eliminates many of the columns. Your report should be an output file created by your Perl code. The columns to keep in your report are the following:
'Date of Test', 'G400-TYP', 'G400-SN', 'G400-Ver.', 'G400-USER', 'Mode', 'Result', 'DS400-SN.', and 'DS400-Name' Again, re +alize that, for each set of four rows, you may not simply check 'Result' for 'ERR' in the first of each + four-row set. G400-TYP G400-SN. G400-USER G400-Ver. Sensor-Typ Sensor-SNSensor range + A1 A2 A3 STEL TWA LEL-Value STEL-Time Date of Test Mode Test Gas Gas Bottle Res +ult Horn LED tA1 tA2 t50 t90 ZP-before ZP CAL-before CAL DS400-SN. DS400- Name DS400-Ver. DS400-ID G450 09010119 3.44 MK429-00 00000 0.0 - 100.0 ppm H2S 10.0 ppm 30.0 pp +m 15.0 ppm 10.0 ppm 2012-06-20 13:19 CAL 20.0 ppm OK OK OK -0.1 ppm 0.1 ppm 18.8 ppm 20.3 ppm 12063580 -default- 2.21 1 G450 09010119 3.44 MK437-00 00000 0 - 500 ppm CO 35 ppm 50 ppm 50 ppm 35 ppm 2012-06-20 13:19 CAL 200 ppm OK OK OK -1 ppm 0 ppm 203 ppm 200 ppm 12063580 -default- 2.21 1 G450 09010119 3.44 MK427-00 00000 0.0 - 25.0 Vol% O2 19.5 Vol% 17.0 Vo +l% 23.5 Vol% 2012-06-20 13:19 CAL N/A OK OK 20.9 Vol% 20.9 Vol% 12063580 -default- 2.21 1 G450 09010119 3.44 MK221-01 00000 0.0 - 100.0 %LEL CH4 10.0 %LEL 20.0 +%LEL 60.0 %LEL 5.0 Vol% 2012-06-20 13:19 CAL 50.0 %UEG OK OK OK -0.5 %LEL 0.0 %UEG 47.5 %LEL 50.5 %LEL 12063580 -default- 2.21 1 G450 09010119 3.44 MK429-00 00000 0.0 - 100.0 ppm H2S 10.0 ppm 30.0 pp +m 15.0 ppm 10.0 ppm 2012-06-20 13:41 CAL 20.0 ppm OK OK OK -0.3 ppm 0.1 ppm 20.5 ppm 20.3 ppm 12063580 -default- 2.21 1

In reply to How do I seperate my data in this txt file. by perltypeofguy

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.