Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Deleteing array elements

by ciderpunx (Vicar)
on Jul 23, 2009 at 07:18 UTC ( [id://782585]=note: print w/replies, xml ) Need Help??


in reply to Re: Deleteing array elements
in thread Deleteing array elements

Once you've got your array set up as described by Corion, use splice
my @a=('a','b','c','d'); splice @a, 2, 1; print join ",", @a;
--
Linux, perl, punk rock, cider: charlieharvey.org.uk.

Replies are listed 'Best First'.
Re^3: Deleteing array elements
by hobbs (Monk) on Jul 23, 2009 at 09:36 UTC
    I prefer to write splice @a, 2, 1, (); it doesn't do anything different, but it makes things clear as well as making things parallel with substr (substr and splice act differently with three arguments, but they act the same with four). Am I the only one?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2025-12-08 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (87 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.