#!/usr/bin/perl -w use strict; use warnings; sub is_incremental { my ($word) = @_; my @letters = split //, $word; my $prev = ord(shift @letters); foreach my $letter (@letters) { my $next = ord(lc $letter); if ($next <= $prev) { return 0; } $prev = $next; } return 1; } my $s = "This is abc and bcf and xyz and ijklmn"; foreach my $word (split /\s+/, $s) { if (is_incremental($word)) { print "Word [$word] is 'incremental'\n"; } }