Good morning Monks, Im fairly new to Perl, I get an output file from a software which is a text file seperate by tabs(although some tabs look longer than others). I can also send an edited version of the file if someone needs the actual file to work with. Here is the code I am using to parse it:

# Opens file $file3 = "c:\\users\\plor\\desktop\\Presc_count2.txt"; $file4 = "c:\\users\\plor\\desktop\\Presc_count3.txt"; open INPUT2, ">", $file4 or die $!; open OUTPUT2, "<", $file3 or die $!; while ($t2 = <OUTPUT2>) { @lines = split /s+/, $t2; print "$lines[0],$lines[1]\n"; } } close(OUTPUT2); close(INPUT2);

When I try to print to test "$lines[0], $lines1" it doesn't give me the output I was expecting, I would've thought it would give me the first two words on that line, instead it prints out either a blank space or nothing(i cant tell if its a space or not). I also tried using split with ('\t') also and I get the same result. Basically I just want each word stored in an element of an array so I can manipulate it. Thanks in advance for any knowledge you guys can pass down to me. -Pao


In reply to Extracting from output file by AllPaoTeam

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.