in reply to Detecting packed data

While there can not be a is_packed function you can write a is_not_string function.
sub is_not_string { my $a = shift; my $packed; for (split(//,$a)) { $packed = 1 if (ord($_) == 0); $packed = 1 if (ord($_) > 127); } return $packed; }
Unicode might make the much harder. Update: did not think of "\n" and "\t". Thanks Zaxo
-- gam3
A picture is worth a thousand words, but takes 200K.

Replies are listed 'Best First'.
Re^2: Detecting packed data
by Zaxo (Archbishop) on Apr 10, 2005 at 20:24 UTC

    Your function might be replaced by matching the character class for control characters, /\p{IsC}/ (unicode character class, just for fun). That doesn't have anything to do with whether a string contains packed data.

    Neither does it have anything do do with whether a scalar is a string. Many text strings contain "\n" or "\t".

    After Compline,
    Zaxo