Jabir Ahmed wrote:
> Hello 

Hello,

> I need to know the best way to get a missing element
> from an array.
> 
> i have an array @a of size containing values 1 to 101 
> with one value missing.
> 
> eg: @a=qw( 1 2 3 4 5 6 8 9 10 .... 101);
> 
> (the array is not sorted and its only to make it
> easier to understand)
> 
> now i need to find out the missing value i.e 7 .

$ perl -le'
my @x = 1 .. 101;
my @y = ( 1 .. 53, 55 .. 101 );

my %z;
@z{ @x } = ();
delete @z{ @y };
print for keys %z;
'
54



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to