[VPM] testing two refs for same target
Peter Scott
Peter at PSDT.com
Sat Jul 5 00:48:18 CDT 2003
At 10:20 PM 7/4/2003 -0700, Darren Duncan wrote:
> >This is the safe way to do it. You could also use grep.
> >
> > @list = grep {$_ ne $wanted_item}, @list
> >
> >but be warned: that will remove everything that is equal to
> >$wanted_item, not just the first one as yours does.
>
>Hello Michael, thanks for your answers. In the above example, it does
>look like your solution is much shorter than mine, and that it would
>work. In some ways, your solution is better, and I will probably use it
>for that. This is because (although I would have to verify it), a user
>may declare more than once that one node is the child of another, meaning
>a reference to the child would appear in the list of the parent's children
>more than once.
In which case the hash solution wouldn't work. Strange sort of inheritance
relationship you've got going there...
>If I was severing the link (which I was), then I would actually want to
>remove all occurances. One reason that I used the solution I did, aside
>from not thinking of the one you provided, is that it may be faster, since
>it doesn't go through the whole list every time. On the other hand, maybe
>it isn't faster. But I think I may go with your solution anyway. --
>Darren Duncan
--
Peter Scott
peter at psdt.com
http://www.perldebugged.com
More information about the Victoria-pm
mailing list