Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) 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:

I don't know how to use pack or unpack. Not one bit.

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?

Dan
"pack impaired Perl Hacker"


In reply to Confession of a Perl Hacker by dkubb

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 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? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2022-08-13 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?