in reply to string processing and regexp alternation...

pushing and poping strings can be done with substr:

my( $first_char, $rest)= (substr( $string, 0, 1), substr( $string, 1)) +; my( $last_char, $rest)= (substr( $string, -1), substr( $string, 0, -1) +);

or if you really want to use push and pop:

my @char= split //, $string; my $first_char= shift @char; my $rest= join "", @char; my @char= split //, $string; my $last_char= pop @char; my $rest= join "", @char;

Note that using thi is slower than using substr.