in reply to Pattern Matching Query
Regexes aren't always the answer. This solution uses substr and the magical autoincrement properties of strings.
#!/usr/bin/perl -w use strict; while (<DATA>) { 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
Update: Argh! Or either of the previous answers would probably be better :(
--"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|