in reply to Creative use of pack/unpack

Here is the most creative use of pack I've come up with:

#!/usr/bin/perl -w use strict; my $password= "Not really"; hide( $password, "none of your business" ); print "password=($password), hide=(",hide($password),")\n"; $password= "No!"; print "password=($password), hide=(",hide($password),")\n"; # Prints: #password=(Not really), hide=(none of your business) #password=(No!), hide=(none of your business)
But the rest of the code (that uses pack and unpack) is the spoiler so I'll obscure it:

sub hide { my( $new )= 1<@_ ? pop : undef; my $secret; my( $p2, $rc, $f )= unpack "LLL", unpack "P12", pack "L", \$_[0]; if( 5 == unpack "C", pack "V", $f ) { my( $pv, $cur, $siz, $iv )= unpack "L4", unpack "P16", pack "L", $p2; $secret= unpack "P$iv", pack "L", $pv-$iv; } if( defined $new ) { $_[0]= $new . $_[0]; substr( $_[0], 0, length($new) )= ""; } return $secret; }

This allows you to store secret messages in scalars where no Perl code can find them (other than using pack/unpack or resorting to, for example, C code).

(updated)

        - tye (but my friends call me "Tye")