Perl to remove words between patterns

Hi,

I am using following code to remove words between start and end points.

$mystring = "The start text always precedes the end of the end text.";
if($mystring =~ s/start(.*)end/\0/) {
        print $1;
print "\n";
print $mystring;
}

But this is writing special chars in place of replaced characters. My requirement is i want to remove words between patterns.

O/P
text always precedes the end of the
The ^? text.
~

Hi,

Are you looking for something like this?

$ cat script.pl
use warnings;
use strict;

my $mystring = "The start text always precedes the end of the end text.";
print "$mystring\n" if $mystring =~ s/\bstart\b.*\bend\b//;
$ perl script.pl
The  text.

Regards,
Birei