fluticasone has asked for the wisdom of the Perl Monks concerning the following question:

Mr. fliticasone
Ok. Monks, this is tricky becuase it involves some math; I have an alpha numeric string which needs to find the next alpha numeric string; off hand certain alpha numerical characters are not available or validation box does not take those alpha characters. I know I could employ math to solve it but, would you know another method to find its numbers and letters on alpha characters, sort of like the lotto which tries to find its next of king. The alpha string is twenty five characters long, not using all alphabet letters or numbers 0-9. Pls Hint. splice @buffer, 0, 0, (splice @buffer, $start_index);

Replies are listed 'Best First'.
Re: Find The Next Number
by moritz (Cardinal) on Jun 16, 2012 at 06:07 UTC

    By which rules should the next number be found? Or should it be random?

    Also I'm rather confused by statements like

    The alpha string is twenty five characters long, not using all alphabet letters or numbers 0-9. Pls Hint.

    If it doesn't contain alphabet letters, why do you call it "alpha string"? And if it's not made out of letters or numbers, what is it made of? punctuation? white space?

Re: Find The Next Number
by AnomalousMonk (Archbishop) on Jun 16, 2012 at 19:58 UTC
Re: Find The Next Number
by cheekuperl (Monk) on Jun 16, 2012 at 06:10 UTC
    whoa!
    Let me see if I got it right:
    You have a 25 char alnum string like:
    abcdef1234abcdef1234abcde
    Now, you need to find the next alnum string which IS/could be
    bcdefg2345bcdefg2345bcdef
    Wat say? Is that the requirement?
Re: Find The Next Number
by cheekuperl (Monk) on Jun 16, 2012 at 06:57 UTC
    Check which one is closer to your requirements:
    $str="abcz123def456"; print "\nFirst interpret"; @arr=($str=~m/([a-zA-Z]+|[0-9]+)/g); $nextstr= join("", map {++$_} @arr); print "\nString: $str"; print "\nNext: $nextstr"; print "\n\nSecond interpret"; @arr=split(//,$str); $nextstr=join("",map{++$_;$_=substr($_,-1,1);} @arr); print "\nString: $str"; print "\nNext: $nextstr";
    ----------- OUTPUT ----------------------
    First interpret String: abcz123def456 Next: abda124deg457 Second interpret String: abcz123def456 Next: bcda234efg567
Re: Find The Next Number
by frozenwithjoy (Priest) on Jun 16, 2012 at 06:09 UTC
    Could you please give some concrete examples?