Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Null scalars in array

by lyklev (Pilgrim)
on Sep 20, 2006 at 22:05 UTC ( [id://574017]=note: print w/replies, xml ) Need Help??

in reply to Null scalars in array

It looks like you have a string containg some words (or numbers) between "foo" and "bar". The words themselves are separated with spaces, so

foo a b cd efg bar
is what you want to search for, I assume.

The regular expression you mention expects "foo" and "bar" to occur more than once, so it might not be the regexp you are looking for. You could use two steps: first, find everything between "foo" and "bar", then split that into separate words or numbers. The code would then be:

my @matches; if ($data =~ m/foo (.*) bar/) { # everything between foo and bar go +es into $1 @matches = split(' ', $1); # split on whitespace }

I cannot think of a regexp that does it in one go, so I welcome smarter solutions.

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-05-26 11:20 GMT
Find Nodes?
    Voting Booth?

    No recent polls found