Slightly off-topic: Your code block here:
$t = unpack('C', $foo);
if ($t == 0) { $v = unpack('C', substr($foo, 1)) }
elsif ($t == 1) { $v = unpack('S', substr($foo, 1)) }
elsif ($t == 2) { $v = unpack('L', substr($foo, 1)) }
elsif ($t == 3) { $v = unpack('Z*', substr($foo, 1)) }
could also be this:
my @unpack_types = qw( C S L Z* );
$t = unpack('C', $foo);
$v = unpack($unpack_types[$t], substr($foo, 1)); #Is $t always a num
+ber?
You would probably do the same thing later on, when you take another look at this code :) I know it's not much savings for only four types, but I don't know what you're working on -- you could have 12! :)
mhoward - at - hattmoward.org
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.