sandrider has asked for the wisdom of the Perl Monks concerning the following question:
Hi All,
I was told that I shouldn't use the C format of using for (i.e. for ($i=0;$i<10;$i++) for replacing the array's elements but use perl's for/foreach command. That works fine but I need to remove some cells/elements from an array, how do it using for/foreach?
my current code is like this:
foreach my $i (@a) { foreach my $j (@b) { if ($i eq $j) { undef $i; undef $j; last; } } }
I can't use delete and undef just removes the contents leaving my array with lots of empty 'spaces'. How can I remove the array's cell totally and not just the contents?
Thanks.
Desmond
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Removing array elements
by Zaxo (Archbishop) on Aug 24, 2005 at 00:31 UTC | |
by mrpeabody (Friar) on Aug 25, 2005 at 04:43 UTC | |
by Zaxo (Archbishop) on Aug 25, 2005 at 04:47 UTC | |
|
Re: Removing array elements
by pg (Canon) on Aug 24, 2005 at 01:17 UTC | |
|
Re: Removing array elements
by rjbs (Pilgrim) on Aug 24, 2005 at 00:40 UTC | |
|
Re: Removing array elements
by GrandFather (Saint) on Aug 24, 2005 at 00:24 UTC | |
|
Re: Removing array elements
by injunjoel (Priest) on Aug 24, 2005 at 06:29 UTC | |
|
Re: Removing array elements
by sandrider (Acolyte) on Aug 25, 2005 at 05:29 UTC | |
|
Re: Removing array elements
by anonymized user 468275 (Curate) on Aug 25, 2005 at 14:26 UTC |