#!/usr/bin/perl use strict; use warnings; while () { chomp; my @a = split; my %h; @h{@a} = @a; my $same = keys %h == 1; print "@a - elements are ", $same ? "the same\n" : "different\n"; } __DATA__ A A A A A B C A A B C