SPUG: RE / Split Question

Fred Morris m3047 at inwa.net
Wed Jul 30 22:01:53 CDT 2003


Yakkity Yacc....

Orr wrote:
>Please help with the following dilemma:
>
>     I am being given a glob of data from a web page that I need to fix
>with perl.  It comes in as $blob looking like this:
>
>425 501 sttlwa01t 425 712 sttlwa01t tacwa02t 425 337 tacwa02t ...
>
>I need to break this up so the word characters associated with the
>numbers stay with their numbers.  Ideally, I would have an array like
>this:
>
>425 501 sttlwa01t
>425 712 sttlwa01t tacwa02t
>425 337 tacwa02t
>
>As you can see, I am not assured of the number of words that will follow
>each set of numbers.  Could you please suggest a split or some other
>tool that will turn the glob into the fix?
>$new_array = [ split /(?=[A-Z]\s\d)/,$scalar ];

OK then, what are you assured of? Because if you're assured of nothing you
need LISP. Conversely, if you're not assured of something, maybe a neural
net. Plenty of peeps will feed your head, the question is: with what?

Again: what are you assured of?

>Which is as close as we got, does not work.  It keeps the split
>characters, but in a funky way that I cannot deal with.  It also will
>always miss the last chunk of the glob.

Looks to me like you say "...that will follow each set of numbers." Well
gooollllLEE! So why don't you parse the numbers, man? Wait a sec! Because
some idjit will be 37714217. I could see it coming.

Well then, mayhaps they've found a vulnerability and things ain't so peachy
in Mayberry. You need to go a little depper, if this is th' case..  ARRRRR!
Clean dem scuppers o'yer mind o'yer preconceptions and swim wit' da fishes!

Turn the sea ta quicksilver and anythin' will float. Sooth. Justin's and
Julie's teeth, even.

What's up with 425? Izzat changeable? What is it? Why not 420? Why not SPF?
MONAD? GOMER? NOMAD? HOMER?

I mean, the answer is really so simple, and it's to split on \sdb[@-I]\s.
Split however many ways you want to after that...


SPLIT ON 425!!

ARE YOU^H^H^HWE FOR REAL?

--

Fred Morris
m3047 at inwa.net






More information about the spug-list mailing list