Afternoon Monks!

For the life of me I have been searching for this
information for a while now. I am not good at perl (as
I have stated before), but still learning slowly as I
get the chance to use it.

What I need is to take information from a file, which I
know how to do with the code below.

open (LABELS, "labellist.txt") or die "I could not get at labellist.tx +t as input"; while (<LABELS>) { }
Now, labellist.txt has information like so:

LOT1 PRODUCT1 LOT2 PRODUCT1 LOT3 PRODUCT2 LOT4 PRODUCT3 LOT5 PRODUCT2
Those are tabs between the LOT and PRODUCT.
What I would like to do is somehow get each LOT# into
a variable $lotnumber and each PRODUCT# into a variable
$product.

A little more information:
LOT# will always be 8 characters long and be in the
format 1Letter followed by 7 Numbers or 8 Numbers
(Exs: F1234567, J1234567, 12345678). Product can range
from 6-9 characters and ussually start with a number
followed by 2 Letters then 3 numbers and most times at
the end have 2-3 letters (Exs: 4GT765, 4GT765HF,
6JK764BVD)

I have tried something like this but it is not working out!

my @Info; open (LABELS, "labellist.txt") or die "I could not get at labellist.tx +t as input"; while (<LABELS>) { chomp; if (m%E\n%) { print "$_\n"; print "\n"; @Info=$_; } }
What I get is not what I want when I test it by
printing out @info or trying to get $Info[0] and
$info[1]. the only thing in @Info is the whole line and the LOT
and PRODUCT dont go in the array as seperate entities.

In reply to Parse data from a line to get 2 variables by Sunnmann

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.