Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (11)
As of 2014-12-26 09:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls