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

Re: (Golf) Strings-to-Array

by MrNobo1024 (Hermit)
on Mar 29, 2001 at 03:50 UTC ( #68003=note: print w/replies, xml ) Need Help??


in reply to (Golf) Strings-to-Array

sub s2a{my@q;$d=0,map$q[$d++].=$_,/./sg for@_;@q}

Replies are listed 'Best First'.
Re: Re: (Golf) Strings-to-Array
by japhy (Canon) on Mar 29, 2001 at 04:21 UTC
    Ooh, very nice. But it clobbers a global $d. Here's my remedy:
    # 41 chars sub s2a {my@q;map{my$d;map$q[$d++].=$_,/./sg}@_;@q}
    It uses map() in void context, but who cares?

    japhy -- Perl and Regex Hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://68003]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2017-07-22 08:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (337 votes). Check out past polls.