Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by Sunnmann (Acolyte)
on May 13, 2006 at 01:10 UTC ( [id://549152]=note: print w/replies, xml ) Need Help??


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

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
you.

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?

m/(\S+)\s+(\S+)/

  • Comment on Re^4: Parse data from a line to get 2 variables

Replies are listed 'Best First'.
Re^5: Parse data from a line to get 2 variables
by Anonymous Monk on May 13, 2006 at 01:41 UTC

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

    So

    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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-19 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found