Re: Remove elements in an array from a different array

2002-08-22 Thread Ramprasad A Padmanabhan
There is a CPAN module Set::Array . I know it may be a little painful to learn and CPAN modules for such a small application but in the long run It helps especially if you are repititively going to use these functions Priss wrote: > Hello, > > I am very new to Perl, wonder if someone can help m

Re: Remove elements in an array from a different array

2002-08-21 Thread david
@h{@arr1}=(); delete @h{@arr2}; print join("\n",keys %h),"\n"; david Priss wrote: > Hello, > > I am very new to Perl, wonder if someone can help me > with this... if I have: > > @arr1 = qw (one two three four five); > @arr2 = qw (two four); > > How can I remove all elements from @arr2 from @

RE: Remove elements in an array from a different array

2002-08-21 Thread Shishir K. Singh
>use hashes. >my %HASH; >$HASH{$_}++ foreach @arr1; >delete $HASH{$_} foreach @arr2; >@arr1 = keys %HASH; > @arr1 now has ( one three five ); Perhaps If you want to maintain the order in the array, you might use it this way: my %HASH; my %hORD; my $count = 0; $HASH{$_} = ($count++) for @arr1

RE: Remove elements in an array from a different array

2002-08-21 Thread Nikola Janceski
See inline comment: > -Original Message- > From: Nikola Janceski [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 21, 2002 8:58 AM > To: 'Priss'; [EMAIL PROTECTED] > Subject: RE: Remove elements in an array from a different array > > >

Re: Remove elements in an array from a different array

2002-08-21 Thread Sudarshan Raghavan
On Wed, 21 Aug 2002, Priss wrote: > Hello, > > I am very new to Perl, wonder if someone can help me > with this... if I have: > > @arr1 = qw (one two three four five); > @arr2 = qw (two four); This is a faq, perldoc -q intersection Although for this kind of operations a hash might be better op

RE: Remove elements in an array from a different array

2002-08-21 Thread Nikola Janceski
use hashes. my %HASH; $HASH{$_}++ foreach @arr1; delete $HASH{$_} foreach @arr2; @arr1 = keys %HASH; @arr1 now has ( one three five ); > -Original Message- > From: Priss [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 21, 2002 8:54 AM > To: [EMAIL PROTECTED] > Subject: Remove elem