Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Inserting an element into an array after a certain element

by Roy Johnson (Monsignor)
on Mar 31, 2005 at 20:04 UTC ( [id://443952]=note: print w/replies, xml ) Need Help??


in reply to Re: Inserting an element into an array after a certain element
in thread Inserting an element into an array after a certain element

I still don't think you should insert if the elment you specify isn't there.
sub insert_after_first { my ($element, $insert, @array) = @_; my $hit; map {($_, ($_ eq $element and !$hit++) ? $insert : ())} @arr; }

Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-25 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found