in reply to substring extraction

I have a hard time understanding your question. Why would you want to "extract" a known substring from another: you already have it! Maybe you meant "remove"? If that's the case, then the simplest thing IMO is to use a regular expression:

$string =~ s/\Q$substring//;
Alternatively, you can use substr, index, and length:
my $offset = index( $string, $substring ); substr( $string, $offset, length $substring, '' ) if $offset > -1;

the lowliest monk

Replies are listed 'Best First'.
Re^2: substring extraction
by ishnid (Monk) on Jul 20, 2005 at 23:28 UTC
    The way that I understood the question was that if you consider the string to be broken up into `words' by the spaces, the OP requires all words apart from the first two and the last two.