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:
#!/usr/bin/perl
use strict;
use warnings;
my $packed = pack 'a*', "A string\n\t";
{
local $\ = "#\n";
print unpack 'A*', $packed;
print unpack 'a*', $packed;
}
__END__
produces:
A string#
A string
#
Which surprised me.
Jonathan
More information about the london.pm
mailing list