Help for this page

Select Code to Download


  1. or download this
    use strict;
    use warnings;
    ...
    my $lexpand = $slen < $length ? ($length - $slen)/2 : 0;
    $lexpand = $ipos < $lexpand ? $ipos : $lexpand;
    print +(substr $str,($ipos - $lexpand),$length),"\n";
    
  2. or download this
    "ABCDEFGHIJKLMNOP" "ABC" 7 => ABCDEFG
    "ABCDEFGHIJKLMNOP" "BC" 7 => ABCDEFG
    "ABCDEFGHIJKLMNOP" "MN" 7 => JKLMNOP