Dear Chuck Lawhorn

I am sorry to ask again  a small Question.

foreach $Item( @MainArray, @SubArray ) {
   $Hash{$Item}++;
  }

Does this block put every element of both arrays in to Values of the HASH?.
or
Does this block put every element of one array as keys  of the HASH? and
other Array elemnets as Values.If so which is key ,Which is Value.


I am sorry for asking previous Question again.

> $Hash{$Key}  is a value of a item in HASH,Right?. Then Why do we care
> about its value by comparing 1. how this is linked with task
> 
Please clarify this.

Thank you Very much

With Best Regards
Raju

> ----------
> From:         Chuck Lawhorn[SMTP:[EMAIL PROTECTED]]
> Sent:         Sunday, September 23, 2001 9:56 AM
> To:   Veeraraju_Mareddi
> Subject:      RE: Subtracting two arrays
> 
> Raju--
> 
> When you step through the two arrays, you increase the value of the array
> element corresponding to
> the value in the arrays. For example, the word 'two' appears in both
> arrays, so when we finish
> stepping through the two arrays, the value $Hash{'two'} will equa two.
> That's how we know the
> value 'two' is in both arrays and must be spliced from the main array. If
> the value of an array
> element is 1, we know it is either only in the main array or only in the
> sub array, therefore we
> will leave it alone.
> 
> The only time this is a problem is if the value 'two' were to appear twice
> in the Main array. If
> we are assured that each of the array values in the main array os unique,
> this will work fine.
> Philip's solution, however, was brilliant and much better than mine.
> 
> I hope this is clear. Please ask any other questions if I did not explain
> this well enough.
> 
> --Chuck
> 
> --- Veeraraju_Mareddi <[EMAIL PROTECTED]> wrote:
> > Dear Chuck Lawhorn
> > 
> > Its very pleasure to  get a reply from you.
> > 
> > I could not understand this .if( $Hash{$Key} > 1 ). What is this for?.
> > 
> > Thank you so much
> > 
> > Sincerely
> > Raju
> > 
> > 
> > 
> > > ----------
> > > From:     Chuck Lawhorn[SMTP:[EMAIL PROTECTED]]
> > > Sent:     Friday, September 21, 2001 8:11 PM
> > > To:       Veeraraju_Mareddi; [EMAIL PROTECTED]
> > > Subject:  Re: Subtracting two arrays
> > > 
> > > This short script should do what you want.
> > > 
> > > --------------------------------
> > > @MainArray = ( 'one', 'two', 'three', 'four' );
> > > @SubArray  = ( 'two', 'three' );
> > > 
> > > foreach $Item( @MainArray, @SubArray ) {
> > >   $Hash{$Item}++;
> > > }
> > > 
> > > foreach $Key ( keys %Hash ) {
> > >   if( $Hash{$Key} > 1 ) {
> > >     foreach $i (reverse( 0 .. $#MainArray )) {
> > >       splice( @MainArray, 1, $i ) if( $MainArray[$i] eq $Key);
> > >     }
> > >   }
> > > }
> > > 
> > > print join( ',', @MainArray ), "\n";
> > > 
> > > ------------------------------
> > > 
> > > The contents of @MainArray are now ('one', 'four').
> > > 
> > > Hope this helps,
> > > 
> > > --Chuck
> > > 
> > > --- Veeraraju_Mareddi <[EMAIL PROTECTED]> wrote:
> > > > Dear Group,
> > > > 
> > > > Is there any PERL Function for removing an array of items from
> another
> > > > array.
> > > > 
> > > > I have a main array of elements and one more array of  elements
> which is
> > > > subset of main array. I want to remove those items which are common
> in
> > > two
> > > > arrays from Main Array.Please tell me is there any of getting it
> done
> > > > 
> > > > Thanx and regards
> > > > Rajuveera
> > > > 
> > > > 
> > > > 
> > > > _______________________________________________
> > > > Perl-Win32-Admin mailing list
> > > > [EMAIL PROTECTED]
> > > > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
> > > 
> > > 
> > > __________________________________________________
> > > Terrorist Attacks on U.S. - How can you help?
> > > Donate cash, emergency relief information
> > > http://dailynews.yahoo.com/fc/US/Emergency_Information/
> > > _______________________________________________
> > > Perl-Win32-Admin mailing list
> > > [EMAIL PROTECTED]
> > > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin
> > > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with Yahoo!
> Messenger. http://im.yahoo.com
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to