Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Linked lists as arrays: inserting values

by radiantmatrix (Parson)
on Sep 25, 2006 at 15:19 UTC ( [id://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
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-24 00:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found