there is a string, say $ss, that is contained in a longer string, say $ls.
for example $ss = "jumps over" and $ls = "the cow jumps over the moon"

how do you suggest obtaining a string from $ls that is $n characters to
the both left and right of $ss?

for example and using the above, say $n = 4
so the results would be "cow jumps ove" (notice 4 characters to both the
left and right of the target text $ss.
---------------------

use strict;
my $ss = "jumps";
my $ls = "the cow jumps over the moon";
my $n = 4;

$ls =~ /$ss/;
print "'". substr($`,0-$n) . $& . substr($', 0, $n) . "'";

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to