Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I read this yesterday, and couldn't understand the question.

This is a guess, but maybe the Title should have been "How do I compress a string variable in perl?"

To compress strings and save memory/disk, you can use the core modules IO::Compress::Gzip and IO::Compress::Gunzip The examples are good, so I don't think you need a code sample. In working with HTML, I have gotten 10x to 20x string reductions. For caching data, that's great!

But what can you do with 'pack/unpack'? -- Lots of great things. These commands greatly reduce the complexity of transferring binary data from big-endian to little-endian machines and vice-versa. And how would you work with 'sockets'/'DNS' etc. without them.

But I just found a new use (for me). I do a lot of work with public/private encryption keys. If the data gets corrupted, you need to generate new keys. Even worse, what if the keys have been changed on purpose.

What I do now is the following ( non-verified code sample ):

use String::CRC32; ## you can use 64 bit as well, but then need to ch +ange pack/unpack functions ## May need to install from CPAN, but has installe +d on all systems I use my $keys = pack( "N N",length( $PublicKey ), length( $PrivateKey ) ) . + $PublicKey . $PrivateKey; my $crc = crc32($keys); my $record = pack("N N", $crc , length($keys) ) . $keys;

Keep a copy of this file on a non Internet connected computer and before the business day starts, the data is verified for accuracy of the keys.

I for one, am glad perl has 'pack/unpack'!

Thank you

"Well done is better than well said." - Benjamin Franklin


In reply to Re: Why is the size even bigger after pack? by flexvault
in thread Why is the size even bigger after pack? by PerlOnTheWay

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-24 03:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found