#!/usr/bin/perl -w use strict; while () { chomp; my $card = substr $_, 0, 1; my $run = 1; foreach my $x (1 .. 4) { ++$card ne substr $_, $x, 1 and $run = 0, last; } print "$_ - ", $run ? 'yep' : 'nope', "\n"; } __DATA__ abcde abcef fghij acghm