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

Linked lists as arrays: inserting values

by radiantmatrix (Parson)
on Sep 25, 2006 at 15:19 UTC ( #574748=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub insert_array_elem {
       my ($ra, $elem, $index) = @_; # insert $elem before $ra->[$index]
    ...
         @$ra = @$ra[0..$index-1], $elem, @$ra[$index..@$ra-1];
       }
    }
    
  2. or download this
    # insert $elem before $index in @array
    splice(@array, $index, 0, $elem);
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://574748]
Approved by prasadbabu
help
Chatterbox?
[talexb]: It's seems quiet today.

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2016-12-06 18:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (114 votes). Check out past polls.