------=_NextPart_000_001C_01C8AD61.66B637F0
Content-Type: text/plain;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Hi,
In the script below, I have an array @[EMAIL PROTECTED]
with its elements consisting =
of numbers like this :-
my @[EMAIL PROTECTED]
=3D (
'1 2 3', '1 2 4', '1 2 7', '1 2 8', '1 2 9', '1 6 7',
'1 7 12', '2 6 7', '4 5 10', '4 5 15'
);
Out of the above list, I wish to generate a seperate array so that among =
their elements, there should not be any 2 numbers that can match and so =
the output should be :- 1 2 3 =20
1 6 7
4 5 10
I therefore have written the script below and have tested the script to =
be working. What is the easier way to write this script?
Thanks
##### start of script ##############
use strict;
use warnings;
my @[EMAIL PROTECTED]
=3D (
'1 2 3', '1 2 4', '1 2 7', '1 2 8', '1 2 9', '1 6 7',
'1 7 12', '2 6 7', '4 5 10', '4 5 15'
);
my $numbers_wanted =3D 2;
my @[EMAIL PROTECTED]
=3D ();
my $marker =3D scalar @[EMAIL PROTECTED]
$splice_counter =3D 0;
my @[EMAIL PROTECTED]
=3D ();
while ($marker) {
$splice_counter =3D 0;
push @[EMAIL PROTECTED]
splice @[EMAIL PROTECTED]
0, 1;
my @[EMAIL PROTECTED]
=3D split / /, $datawanted[-1];
my $temp_datas_iterator =3D scalar @[EMAIL PROTECTED]
- 1;
foreach ( 0 .. $temp_datas_iterator ) {
my $counter =3D 0;
my @[EMAIL PROTECTED]
=3D split / /, $datas[ $_ - $splice_counter ];
foreach (@[EMAIL PROTECTED]
) {
my $a =3D $_;
foreach (@[EMAIL PROTECTED]
) {
if ( $a =3D=3D $_ ) {
$counter++;
}
}
}
if ( $counter >=3D $numbers_wanted ) {
splice @[EMAIL PROTECTED]
$_ - $splice_counter, 1;
$splice_counter++;
}
}
$marker =3D scalar @[EMAIL PROTECTED]
(@[EMAIL PROTECTED]
) {
print "$_\n";
}
------=_NextPart_000_001C_01C8AD61.66B637F0--


|