I was musing over The Name Game, which is a string-processing algorithm as well as a song.
According to the instructions, I have written this script:
$N = $ARGV[0];
$n = $N =~ /^[AEIOU]/ ? $N : substr( $N, 1 );
@a = qw( b f m ) if $N !~ /^[BFM]/;
$n = lc( $n =~ /^[BFM]/ ? substr( $n, 1 ) : $n );
printf( "%s, %s, bo-%s%s, Banana-fana fo-%s%s, Fee-fi-mo-%s%s, %s!",
( $N, $N, $a[0], $n, $a[1], $n, $a[2], $n, $N ) );
I'm sure other Monks can improve on that?
Edit: based on the input below, this is a revised version:
$N = $ARGV[0];
$n = $N =~ /^[AEIOU]/ ? $N : substr( $N, 1 );
foreach (qw( b f m )) { push( @a, ( $N =~ /^[$_]/i ? '' : $_ ) ) }
$n = lc( $n =~ /^[BFM]/ ? substr( $n, 1 ) : $n );
printf( "%s, %s, bo-%s%s, Banana-fana fo-%s%s, Fee-fi-mo-%s%s, %s!\n",
( $N, $N, $a[0], $n, $a[1], $n, $a[2], $n, $N ) );