unpack and trailing whitespace in strings

Jonathan McKeown jonathan at hst.org.za
Thu May 25 14:56:24 BST 2006

perlfunc says unpack 'A*' strips trailing spaces and nulls.

It appears (in 5.8.6 and 5.8.7 at least) to strip all trailing whitespace:

use strict;
use warnings;

my $packed = pack 'a*', "A string\n\t";
  local $\ = "#\n";
  print unpack 'A*', $packed;
  print unpack 'a*', $packed;


A string#
A string

Which surprised me.


More information about the london.pm mailing list