Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Decompose a String into Tuples (Faster and Compact Way)

by Tortue (Scribe)
on Oct 12, 2005 at 19:57 UTC ( [id://499659]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub decomp {
        @_ = split / /, shift;
        return [ map { join " ", (shift, shift, $_[0]) } (1..@_/2) ];
    }
    
  2. or download this
    sub decomp {
        my $n = 2; # for n+1-uples
        @_ = split / /, shift;
        return [ map { $_*=$n; "@_[$_..$_+$n]" } 0..@_/$n-1 ];
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-03-28 17:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found