|No such thing as a small change|
Re: Why is the size even bigger after pack?by flexvault (Parson)
|on Nov 03, 2011 at 13:01 UTC||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 ):
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'!
"Well done is better than well said." - Benjamin Franklin