Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: can't use unpack or split??

by wufnik (Friar)
on Jun 07, 2004 at 22:48 UTC ( [id://362143]=note: print w/replies, xml ) Need Help??


in reply to can't use unpack or split??

hmmm; what about this. it's simple:
my @records = (<DATA>); # lookbehind to make sure those that start # with an apostrophe end with one... $tok1 = qr/[\'][A-Za-z0-9\s\']+(?<=\')/; $tok2 = qr/[A-Z\?0-9]+; # for each record in the above sample... # note precedence in regex below... foreach my $record (@records){ my @fields = ($record =~ /$tok1|$tok2/g); # do something with fields } __DATA__ #...those irritating records in full...
works for the dataset provided, and i think for seavers extension.
...wufnik

-- in the world of the mules there are no rules --

Replies are listed 'Best First'.
Re^2: can't use unpack or split??
by seaver (Pilgrim) on Jun 11, 2004 at 18:44 UTC
    It is definitely a good one, and one I'll remember for the future, but unfortunately, it relies on the delimitation of the second column by apostrophes, and this is not guaranteed, there are NO delimiters in the second column!

    So a regex search that tries to matches as much of the line as possible, as written by browserUk, is the straight forward answer that will include any possibilties.

    Thanks to everyone for answering

    Cheers
    Sam

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-26 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found