Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: [splice], explanation please?

by bart (Canon)
on Nov 16, 2002 at 10:52 UTC ( [id://213388]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    @a = ('a' .. 'i');               # 9 lower case letters
    print "Before: @a\n";            # prints: a b c d e f g h i
    ...
    
    print "After: @a\n";             # prints: a b c X Y Z f g h i
    print "Pulled out: @x\n";        # prints: d e
    
  2. or download this
    @x = splice @a, 3, 2, 'X', 'Y', 'Z';
    
  3. or download this
    @x = splice @a, 3, 2;
    
  4. or download this
    @x = splice @a, 3;
    
  5. or download this
    @x = splice @a, 3, -2;
    
  6. or download this
    Before: a b c d e f g h i
    After: a b c h i
    Pulled out: d e f g
    
  7. or download this
    @x = splice @a, 3, -2, @r;
    
  8. or download this
    @x = splice @a, -5, -1, @r;
    
  9. or download this
    @x = @a[2..5];
    
  10. or download this
    @x = @a[2, 3, 4, 5];
    
  11. or download this
    @x = ($a[2], $a[3], $a[4], $a[5]);
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 10:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found