in reply to Algorithm for "Incrementing" strings

++ operator can be applied to strings and then skip vowels:
use strict; use warnings; sub consinc { my $str = shift; my %vowels = ( 'a' => 1, 'e' => 1, 'i' => 1, 'o' => 1, 'u' => 1, ); do { $str++; } while (exists $vowels{substr($str, -1 , 1)}); return $str; } my $str = $ARGV[0]; print "$str - " . consinc($str) . "\n";
update

'if' can do:

$str++ if exists $vowels{substr($str, -1 , 1)};

Replies are listed 'Best First'.
Re^2: Algorithm for "Incrementing" strings
by ibm1620 (Hermit) on Feb 11, 2015 at 18:32 UTC
    True, although the more digits $val has, the longer your do loop will have to spin to get past 'XAAAAAAAAAAAA' and up to 'XBBBBBBBBBBBB', won't it?
      If we always skip vowels then we never have vowels in the string. Should we replace vowels in the string in the very beginning?

        Ok, change 'XAAAAAAAAAAAA' to 'WZZZZZZZZZZZZ': perl -E '$a="WZZZZZZZ"; $a++; say $a' => 'XAAAAAAA'

        --MidLifeXis