Hello Li,

The `notall` function of `List::MoreUtils`
(https://metacpan.org/module/List::MoreUtils) can be made use of along
with Perl's `grep` function:

#!/usr/bin/env perl

use strict;
use warnings;

use List::MoreUtils qw( notall );

my @array = (
    'AB AB AB AB AB',
    'AB AC AB AB AB',
    'AB AC AD AB AB',
);

@array = grep {
    my @elems = split /\s/;  # Split into elements on whitespace
    notall { $elems[0] eq $_ } @elems;  # Check if every element is
equal to the first element
} @array;

Without using `List::MoreUtils`:

@array = grep {
    my $select = 0;
    for ( my @elems = split /\s/ ) {
        if ( $elems[0] ne $_ ) {
            $select = 1;
        }
    }
    $select;
} @array;


Regards,
Alan Haggai Alavi.
--
The difference makes the difference

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to