in reply to Rewrite a Regular Expression to be easier to understand
You will have to alter the upper limit of the loop to determine how short of a string you want to stop at.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//;
Update: fixed a typo.
-Mark
|
|---|