Peter Payne wrote:
> my %h_array2 = map { $_, 1 } @ar_array2;
>
> for ( my $i = 0; $i < scalar( @ar_array1 ); $i++ )
> {
> if ( exists( $h_array2{ $ar_array1[$i] } ) )
> {
> print( " Element \""
> . $ar_array1[$i]
> . "\" exists in array2!\n" );
> }
> }
>
> Ooh ooh my head hurts, ooh that was SOOO hard, oh oh oh why did
> I ever become a programmer?? I never expected to have to THINK
> for myself.. cruel world..
>
> svenne <bobsmith@[no-thankyou-very-much]jippii.fi> wrote:
>> this is trivvial question but how do you compare existense of elements
>> intwo arrays?, that is I want to compare two arrays and check the
>> existense of the first array's elements in the second array,
>>
>> one line of code if possible...
>>
>> any advice much appreciated, thank you.
>> /G
so basically
my %h_array2 = map { $_, 1 } @ar_array2;
for ( my $i = 0; $i < scalar( @ar_array1 ); $i++ )
{
if ( exists( $h_array2{ $ar_array1[$i] } ) ){
return true;
}
return false;
}
....is what I need, thank you for replying, *S*
have a great day!
--
--
www.gh-webinteractive.com