Article View: comp.lang.perl.misc
Article #272Re: splice
From: nobull
Date: Tue, 14 Mar 2000 00:00
Date: Tue, 14 Mar 2000 00:00
24 lines
1534 bytes
1534 bytes
"Amri, Kuross [WOLL:4009-I:EXCH]" <kamri@nortelnetworks.com> writes:
> I have another dillemma. I am using a splice function to delete
> an old
> entry in an array after creating a new one. Pretty basic as far as edit
> functions go.
> However, to delete an old entry you need to know its position in
> the
> array. I don't know how to figure out its position so I can delete it.
Not with splice anyhow. You can with grep.
@list = grep { $_ ne $item_to_delete } @list, $item_to_add;
However you should consider using a hash rather than an array if the
list is likely to be long and if the order is not significant.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
Technical Details
Message-ID:
<u9g0ttga67.fsf@wcl-l.bham.ac.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<38CDC25C.3FD0874A@nortelnetworks.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1133f4,9530b6e516ce4505 X-Google-Attributes: gid1133f4,public X-Google-Thread: 112333,9530b6e516ce4505 X-Google-Attributes: gid112333,public X-Google-Thread: fa0ae,9530b6e516ce4505 X-Google-Attributes: gidfa0ae,public From: nobull@mail.com Subject: Re: splice Date: 2000/03/14 Message-ID: <u9g0ttga67.fsf@wcl-l.bham.ac.uk> X-Deja-AN: 597278336 References: <38CDC25C.3FD0874A@nortelnetworks.com> Followup-To: comp.lang.perl.misc X-Complaints-To: usenet@usenet.bham.ac.uk X-Trace: usenet.bham.ac.uk 953027024 25927 147.188.68.4 (14 Mar 2000 09:43:44 GMT) Organization: Just me, doing my own thing NNTP-Posting-Date: 14 Mar 2000 09:43:44 GMT Newsgroups: comp.lang.perl.misc,de.comp.lang.perl,fr.comp.lang.perl