Your skill will accomplish
what the force of many cannot
Confession of a Perl Hackerby dkubb (Deacon)
|on Jan 22, 2001 at 16:42 UTC||Need Help??|
My name is Dan, I am a perl hacker, and I have a problem.
I hack away at perl for sometimes 10, 12, even 14 hours a day, partly on the job, partly on my own time. Alot of my time revolves around perl. Though, that's not my problem, I'll get to that in a sec.
Just for the record, I love perl. Not like, love it.
I own almost all the O'Reilly books, OO Perl, have a TPJ subscription (for now anyway), Advanced Perl - even Mastering Algorithms with Perl, and yes, I've read it.. well, most of it anyway. I try to soak up as much knowledge as I can.
I've built web-based interfaces to databases, created database abstraction layers, done OO with multiple inheritance just for fun, built and designed enterprise-level business systems. On the job I even lead a team of 7 other perl programmers and sys-admins.
I've recently submitted by first CPAN module, something I've been pushing towards for a while now.
That's what makes it so hard to admit my problem. The longer I go, the harder it is. Now.. this is really embarrassing.. I've got a confession to make:
It's not that I've never tried, mind you. I have. I've looked in every book I own, and some that I don't, searching for good explanations of pack or unpack. Most of them are copies of the perldoc perlfunc. They all have the same table with two columns: templates and short descriptions. I'm not sure if these incomplete explanations are because the authors don't understand it well enough to explain it. Or that it's so readily apparent, and that everyone must know how to use it, so why bother to explain it. I hope it's not the latter.
Is it just me? Does anyone else have this problem too?
What I need to learn this is a good pointer to a tutorial, but I've found none, anywhere. Excluding that, if anyone has some good real-world examples, I would be all ears.
For example, I've heard that you can use unpack to split strings. I can do this with regexs, split, or substr, so understand the concept. The best way for me to learn would be to see the most common way, using other perl-ish methods, then the equivalent using pack/unpack. Something like:
"You can split strings using regexs:"
#splits string with regex
"Or using split:"
#splits string with split
"Or even using unpack:"
#magical unpack string split
"Why you would want to use it is because it's faster/cooler/shorter/better"
My goal is to learn pack/unpack over the next few weeks, enough to help write a small mini-faq here. It's one of those gaps in my perl knowledge that is bugging me, and I suspect I'm not alone.
Would any monks be kind enough to post their examples and explanations of using pack/unpack, so that similarly "pack impaired" monks can become enlightened as well?