in reply to Rewrite a Regular Expression to be easier to understand

When faced with a complex regex, it is often better to generate it automatically:
my $test = 'vacation.msg'; my @alt; foreach my $pos (1..length $test) { push @alt, substr $test, $pos; # prefix truncated push @alt, substr $test, 0, length($test) - $pos; # suffix truncate +d } my $regex = join '|', $test, @alt; $vacation_str = s/$regex//;
You will have to alter the upper limit of the loop to determine how short of a string you want to stop at.

Update: fixed a typo.

-Mark