Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Question: Capturing a repeated pattern

by robmderrick (Initiate)
on Apr 08, 2010 at 22:19 UTC ( [id://833651]=note: print w/replies, xml ) Need Help??


in reply to Re: Question: Capturing a repeated pattern
in thread Question: Capturing a repeated pattern

A split for that input line alone would work perfectly. But, my input is quite varied, and for this purpose, I only want to match those lines that exactly match my pattern, and not all of the others that split would grab.

Replies are listed 'Best First'.
Re^3: Question: Capturing a repeated pattern
by BrowserUk (Patriarch) on Apr 08, 2010 at 22:34 UTC

    You could always match first and then split:

    $s = 'somename 1000 0.24 280 2 2576.9 2731.9 12.0 4195.3';; $s =~ m[\w+(?:\s+(?:\d+\.)?\d+){8}] and @a = split ' ', $s and shift @a and print "@a";; 1000 0.24 280 2 2576.9 2731.9 12.0 4195.3

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: Question: Capturing a repeated pattern
by rubasov (Friar) on Apr 08, 2010 at 22:43 UTC
    Sorry, I've updated the grandparent node before I saw your answer. And of course if the separator part cannot be easily subtracted from your regex then split won't suffice and you will need what kennethk recommended.

      Please indicate in the node that you have updated it otherwise future readers of the thread will be left somewhat bemused by the disconnect between what is written and the reply it seemingly received.

      True laziness is hard work
        For the history:

        I haven't deleted or modified anything in that node, only added the "update" section. After that as I've seen the answer and the "disconnection", I've tried to indicate that with my node starting with "Sorry".

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-03-19 10:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found