Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: split string using optimized code or perl one liner

by johngg (Canon)
on Feb 24, 2017 at 11:51 UTC ( [id://1182733]=note: print w/replies, xml ) Need Help??


in reply to Re^4: split string using optimized code or perl one liner
in thread split string using optimized code or perl one liner

Normally I would do map { pop } 1 .. @_ as in my un-golfed original to make it clear that I am iterating a set number of times, since @_ is taken in scalar context in the range operator. I used the shorter version for golf having seen BrowserUk use it here. Your point about fiddling with elements is pertinent, and the behaviour shouldn't be relied upon, but is probably not the cause of the problem in this case.

I am running 5.18.2 on Linux Mint 17 and adding the -an flags as mentioned by choroba and haukex (++ to them) gives the results expected:-

$ echo www.perlmonks.org.split.reduce.code.check | perl -lanF'(\.)' -E +'say sub{map pop,@_}->(@F)' check.code.reduce.split.org.perlmonks.www $

Note to self: start running multiple interpreter versions rather than being lazy and relying on whatever came with the Linux distro!

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-26 06:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found