#!/usr/bin/perl -w
use strict;

# If you want to delete the elements of array X which are duplicated in
# array Y, try this (as long as your arrays are shorter than several hundreds
# of thousands of items)

use vars qw( $a $b ); # you should do this, see perldoc perlop

my(@X) = qw/1 2 3 4 5 6 7 8 9 A B C D E F G/;
my(@Y) = qw/1 3 5 7 9 D E F G/;

my($cmp) = { 1=>{ map { $_ => $_ } @X }, 2=>{ map { $_ => $_ } @Y } };

map { delete $cmp->{1}{$_} if exists($cmp->{2}{$_}) } keys %{ $cmp->{1} };

@X = sort { uc($a) cmp uc($b) } keys %{ $cmp->{1} };

print(qq[@X\n]);


# Note: this won't preserve the order of the items in @X.  The items
# will instead be sorted alphabetically.  Do what you want with them
# after that.  Here we just print them out.