$str =~ s/^((?:...)+).{0,2}$/$1/;
UPDATE: Corrected typo noticed by kcott.
In reply to Re^3: Seeking with 'x' in unpack and out of bounds reads
by BillKSmith
in thread Seeking with 'x' in unpack and out of bounds reads
by mxb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |