Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^3: Parse data from a line to get 2 variables

by devnul (Monk)
on May 13, 2006 at 00:48 UTC ( #549151=note: print w/replies, xml ) Need Help??

in reply to Re^2: Parse data from a line to get 2 variables
in thread Parse data from a line to get 2 variables

He actually gave you the answer, more or less:

my ($lot,$prod) = m/(\S+)\s+(\S+)/;
instead of:
$Info=$_; $lotNumber=substr($Info, 0,8); $productName=substr($Info, 9);
I'm not sure what you are doing with the if(m%E%), but I presume that is for testing...


Replies are listed 'Best First'.
Re^4: Parse data from a line to get 2 variables
by Sunnmann (Acolyte) on May 13, 2006 at 01:10 UTC
    First of all, I want to thank you all for your help. This is awesome!
    You guys have come through for me every time I have asked for help and I
    appreciate it! So thank you very much and I am tipping my hat to all of

    And, yes it was for testing purposes, and at first I thought I may need
    to parse it by the type of lot# it was. But that was for nought. The
    main thing I do with Perl right now is change stuff I have to work in
    new situations, I get stuck alot while trying to learn. My mentor here
    at work left a while back and we dont use perl as much anymore so there
    has been no need for this until now when I write simple scripts to do
    some mundane stuff. I kind fo wish there was more need and i had the
    time to really get down and learn it.

    Anyways, enough of that, I did have another question. Could one of you
    write out in words what the below line is saying? Or point me to a good
    site that will tell me?


      \S+ matches one or more non-whitespace characters
      \s+ matches one or more whitespace chars


      my ($lot,$prod) = m/(\S+)\s+(\S+)/;

      is matching the lotnumber and putting it into $lot,
      matching the tab and throwing it away,
      then matching the product code and putting it into $prod

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://549151]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-01-27 03:31 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (70 votes). Check out past polls.