
mhx
Enthusiast
/ Moderator
Aug 30, 2001, 9:52 AM
Post #4 of 5
(2062 views)
|
Say you've got two strings $s1 and $s2, then you can use for example:
#!/bin/perl -w use strict; my $s1 = 'foo bar'; my $s2 = 'Hello World'; my $bin = pack 'na*na*', length $s1, $s1, length $s2, $s2; # now do something with $bin my($u1,$u2) = unpack 'n/an/a', $bin; print "[$u1]\n[$u2]\n"; This will work for strings of up to 65535 characters. 'n' is always a big endian unsigned 2-byte integer. Hope this helps. -- Marcus
s$$ab21b8d15c3d97bd6317286d$;$"=547269736;split'i',join$,,map{chr(($*+= ($">>=1)&1?-hex:hex)+0140)}/./g;$"=chr$";s;.;\u$&;for@_[0,2];print"@_,"
|