Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: How to capture all occurances from a slurped file.

by shmem (Chancellor)
on Aug 24, 2006 at 22:04 UTC ( [id://569465]=note: print w/replies, xml ) Need Help??


in reply to How to capture all occurances from a slurped file.

You're just missing the loop:
while ($data =~ m{(\d+-)(\d+-)(\d+)(\s*/\s*)(\d+)(\s*/\s*)(\d+)}g) { print "$1, $2, $3, $4, $5, $6, $7\n"; }

After each match is found, the search continues where the last match left. So you get all occurrences.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: How to capture all occurances from a slurped file.
by Grey Fox (Chaplain) on Aug 24, 2006 at 23:21 UTC
    Thanks;
    I knew I was close. I just could not put my finger on what to use for the loop.
    -- Grey Fox
    Perl - Hours to learn lifetime to master.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2025-03-17 09:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (54 votes). Check out past polls.