Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Splitting into variables columned data without delimiters with a regexp ?

by BrowserUk (Patriarch)
on Nov 01, 2011 at 09:46 UTC ( [id://935075]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Splitting into variables columned data without delimiters with a regexp ?
in thread Splitting into variables columned data without delimiters with a regexp ?

I was thinking about solutions with sprintf or split too

split also invokes the regex engine, and doesn't really lend itself to the task, so it's not going to help any.

I've no idea how sprintf could be used for this as its primary purpose is composing strings, not decomposing them.

The regex engine can decompose fix field data surprisingly efficiently, but it will never beat unpack that was designed for this express purpose:

cmpthese -1,{ a => q[ my $s='x'x1100; my@bits= unpack'(A6A5)*',$s; ], b => q[ my $s='x'x1100; my@bits= $s=~m[(.{6})(.{5})]g; ], };; Rate b a b 4516/s -- -6% a 4780/s 6% --

Not huge savings but they grow with size:

cmpthese -1,{ a => q[ my $s='x'x11000; my@bits= unpack'(A6A5)*',$s; ], b => q[ my $s='x'x11000; my@bits= $s=~m[(.{6})(.{5})]g; ], };; Rate b a b 427/s -- -10% a 471/s 11% --

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-18 05:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found