# Just get the first piece my ( $first_piece ) = ( $str =~ m{ \A ( [^*]* ) }x ); my $pos = length $first_piece;