Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Don't go all PerlMonks on me

by bobf (Monsignor)
on Apr 09, 2007 at 07:08 UTC ( [id://608933]=perlmeditation: print w/replies, xml ) Need Help??

I stopped by a colleague's office recently and asked how things were going. She explained that she was tasked to write a screen-scraper and that she was having trouble with a regex. I offered to help and asked to see the code, to which she replied

"OK, but don't go all PerlMonks on me."
I must admit I was a bit surprised and consequently I didn't hear much of what followed - it was something about white space and angle brackets.

...don't go all PerlMonks on me... The words echoed through my head. What did that mean? Was it a compliment? I do try to be helpful and she knows that much of my knowledge can be attributed to PerlMonks. Perhaps it was more of a playful jab. I am guilty of inflicting informal and unsolicited code reviews on her in similar circumstances in the past, and sometimes I lose sight of the immediate goal (just make it work) and instead suggest alternative designs that would provide additional flexibility and be more robust (see XY Problem).

As I regained focus I realized that she was looking at me expectantly. I studied the line in question, and then I looked at the surrounding code.

"Are you parsing an HTML table?"
"Yes."
"Is there an API that you can use instead of screen-scraping?"
"No - this is it."
"Hmmm." I paused, not wanting to push my luck. "It can be pretty tough to parse HTML with regular expressions. Are you familiar with any of the HTML parsers that are available on CPAN?" I almost cringed as I said it.
"No. Are they easy to use? I have to get this done before I leave today."
I had an opening. In the next few minutes I learned that she inherited the code from on-high and was told to make it work (which may explain why she wasn't as sensitive to the suggestion as I feared). After I explained some of the advantages of using a parser, I told her that if she could give me 20 minutes I'd whip up an example for her. She agreed.

I went back to my office and ripped the guts out of the script that she was working on. I replaced nearly 100 lines of code with the following:

use HTML::TableExtract; my $te = HTML::TableExtract->new(); $te->parse( $content ); foreach my $ts ( $te->tables() ) { foreach my $row ( $ts->rows() ) { print $outfh join ( "\t", map { defined $_ ? $_ : ''; } @$row +), "\n"; } }

I walked back to her office and asked her to open up my version of the script. She gasped. "It's so short!" I smiled. "Yup - and it works, too."

As I left her office I thought of those words: don't go all PerlMonks on me. I'm still not sure what that means, but I think I did... and I'm proud of it.

Thanks, PerlMonks, for helping me to help make someone else's job a little easier.

Replies are listed 'Best First'.
Re: Don't go all PerlMonks on me
by dana (Monk) on Apr 09, 2007 at 15:55 UTC

    Okay, to be honest, I am the female co-worker in question.

    As said, I inherited a piece of horrid code and was told to 'make it work'. I was leaving in one hour for a long weekend. I needed to make it work without a lot of time learning how to make it perfect -- I would have time for that when I returned from vacation. I have a small OCD problem -- I cannot let go of thinking about coding and solutions when a known problem is waiting and I didn't want to spend my weekend worrying/losing sleep over another person's code.

    To be frank, the following sums up my statement perfectly:
    Don't be pedantic. This is not a teachable moment.

    Most of the time I enjoy learning. I used to be a sys admin so CPAN and perl module installation are truly old hat to me. I always use warnings/strict. I'm not afraid to rip code apart. I don't mind being handed a broken piece of code and being asked to fix it -- provided it is not "fix it right this second before vacation".

    I appreciate help and enjoy learning from people who can improve my style, show me new modules, show me how to use existing modules, white board over various approaches, and challenges that advance my skills, all the while avoiding condescending comments - more precisely, I enjoy perlmonks.

    Thus, although I've been using perl for years, I'm relatively new to the site. I am a novice perlmonk (and fairly proud I made it all the way to novice level!!). :)

      Monks, meet dana. :-)

      Thanks for adding your perspective and detail to provide context. Thanks also for using what may not have been a particularly teachable moment for you to create one for me.

      For the record, dana and I are both very detail-oriented, and it is easy for us to spiral off into tangential discussions of coding practices and design without actually addressing the matter at hand. In this instance, her gentle smack upside my head flipped enough bits to allow me to address the immediate problem without overwhelming her with more information than she could process at the time. I need that on occasion. :-)

      Thanks again for keeping me in check, and welcome to PerlMonks. :-)

      FWIW, I strongly identified with both of you, having been the one under time pressure and needing focussed help, and at other times, the one trying to keep my help focussed. That's what made the story so good, and such a good example of how to provide effective help. Grateful thanks to you both for sharing with us.

      Most excellent, Madam! Thank you for sharing your half of the experience with us.

      cat >~/.sig </dev/interesting

      Then it reminds me of what I experienced about 4-5 year ago. A co-worker asked for help about something wrong with his code, regex, to be precise. When I looked at his screen, I wanted to explain about what was wrong with his regex and why it was wrong. Just as I started he stared at me and I stopped immediately. I think that was his "Don't be pedantic. This is not a teachable moment." Only that his statement, more or less, was "Don't explain, just tell me and I'll type" in such expressive way. So that's what we did.

      It was like I had a somekind of speech-synthesizer, and he typed whatever I said, well almost :-) "Go to line 24, move the cursor at the opening square bracket, add caret, move cursor over 3 characters to the right, remove that dollar, oh no, sorry, I mean the underscore, the underscore, yes, right. Now, press the ESC, then ZZ. OK, type perl -c add.cgi. Good." (Just FYI, we used vim, well I still do).

      Another case is when I was the one who felt the situation. So instead of explaining what was wrong, I said, "follow my instruction and just type what I say." Of course, IMHO, this is not the way for learning process. There's not much (if any at all) for the asker to gain lessons. It's just that in this particular circumstances, the number one and only goal is to have the problem solved.

      Update: Now that I have my quota again today, It's please to put ++ on bobf and dana for interesting thread :-)

        My favorite times when playing secretary, where I am simply typing something someone is telling me to type to add/fix/modify/optimize/you-name-it, are those inevitable moments when the person telling me to type says 'add x' meaning to type an x and I type '+x'. For some reason it always makes me laugh because it dawns on me that I'm not absorbing anything - I am simply putting someone else's brain dump into logical (or illogical) code.

        My goal is always to go back and learn from what they just told me to type, however all too often time gets away from me and I don't go back to analyze anything.

        White boarding, taking a little longer to understand what I'm being told, helps me to learn new skills and also is necessary for when I need to go back to the script for any reason.

      fairly proud I made it all the way to novice level

      The interesting thing is that you've made your way to Beadle since this node, really really quick :-) And yes, I ++'ed you :-)

        No, now she gained even further is a Monk with lots of XP's
Re: Don't go all PerlMonks on me
by BrowserUk (Patriarch) on Apr 09, 2007 at 11:10 UTC

    From the sound of things, you did exactly what she asked for.

    • You didn't belittle her for not knowing what you know.
    • You didn't suggest a solution that involve changing the inputs to the problem, or changing the problem to suit a solution you knew.
    • You didn't preach to her about CPAN, or POD, or perldoc, or Supersearch.
    • You didn't berate her coding style, variable names, tab settings or editor choices.
    • You didn't assume that because you didn't understand her problem, that she was tackling the wrong one.

    You gave a working solution to her immediate problem, that along the way, demonstrated the power of the 'use CPAN' mantra,

    ... without going all PerlMonks on her.

    And you have left her to learn the lessons of your demonstration, in her own time and her own way. Nice one++.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Thanks for pointing these things out. Sometimes it's hard to perform a self-review, and it is good to get feedback from a neutral third party.

      On a more general note, I think these are great examples of how to answer a question that apply not just to PerlMonks but also to teaching in general. It's a great summary of some of the points made in threads such as On Answering Questions, How to answer questions, and brian's Guide to Answering Questions, and I will link to this and refer others to it in the future.

Re: Don't go all PerlMonks on me
by toma (Vicar) on Apr 09, 2007 at 09:27 UTC
    It could mean a lot of things. Assigning too much meaning to passing statements is a bad idea. However, I can't resist speculating:

    Don't tell me to use strict and warnings.
    Don't tell me to figure out a new module.
    If we need a new module, you install it and take care of all the details.
    Don't tell me to write a simple test program. I want to spend all my time working on broken code.
    Don't be pedantic. This is not a teachable moment.
    You can work on it, but only if you just fix it and then go away quietly.

    It should work perfectly the first time! - toma
      Nice list. Of the six choices, I'm betting on some combination of
      Don't be pedantic.
      This is not a teachable moment.
      If we need a new module, you install it and take care of all the details.
      Don't tell me to figure out a new module.

      There are times when you can think about the best way to do a job and learn something new in the process, and there are times when you need to just get something fixed so you can go back to whatever needed your urgent attention before this irritating problem interrupted.

      Obviously, I'm much happier when I can think and learn, and make code better, but all too often the stacked-up urgencies don't allow that. I'd say that to "go all PerlMonks" means to get into the think-learn-and-improve mode, and out of the ASAP mode. (And we all know of examples where the think-learn-and-improve mode is the faster of the two, but it's tough to tell if that's going to be true going into a specific problem.)

      You hit the nail on the head. In retrospect, I think it was a combination of the following two things:

      Don't be pedantic. This is not a teachable moment.
      Don't tell me to figure out a new module.
      with emphasis on the former. In the end, the code worked and she could go on vacation with a clear conscience. She may have learned something, but to be honest I think I learned more. This reminded me that not every moment is "a teachable moment" and no matter how much I may want to, doing so may only succeed in limiting the number of teachable moments in the future.

Re: Don't go all PerlMonks on me
by McDarren (Abbot) on Apr 09, 2007 at 07:35 UTC
    Great little anecdote, I love it :)

    I'm one of four people in my office that write Perl code, but I'm the only one that is a regular at PM. Because of this (I believe), the others often come to me for advice. And I've had lots of similar little episodes. One in particular I remember was when of my cow-orkers wrote a script that jumped through all sorts of convoluted hoops attempting to parse and update a DNS zone file. When he eventually gave up and came to me for advice, I asked him why he simply didn't just use Net::DNS? ;)

    Although I've never heard those exact words ("going all PerlMonks"), I've had plenty of looks that tell me that's exactly what they are thinking at the time ;)

    Were you tempted to ask her exactly what she meant by that comment? It would be interesting to hear her answer.

    Cheers,
    Darren :)

Re: Don't go all PerlMonks on me
by syphilis (Archbishop) on Apr 09, 2007 at 07:49 UTC
    Given that, in replacing her code with your code, you did precisely what any well-informed monk would do, I would say that you did go all perlmonks on her ... but she didn't realise it ... in fact, it even impressed her !!

    (I think she was probably just asking you to not be critical and judgemental.)

    Cheers,
    Rob
Re: Don't go all PerlMonks on me
by Limbic~Region (Chancellor) on Apr 09, 2007 at 12:34 UTC
    bobf,
    In the summer of 2006, I came down with a severe case of mononucleosis which went undiagnosed for several weeks and landed me in the hospital for three days. The folks at work got me a "Get Well Soon" picture frame in which each wrote something. Some of the more comical and appropriate messages were:
    sickness > /dev/null and "I'm sure there has been a drop in PerlMonks traffic. Get back and fi +x that!"
    Since all of these coworkers, like myself, are not programmers by trade - it is interesting to see that in a troubled times they knew just what would make me feel better. What does all this have to do with "Don't go all PerlMonks on me"? I suppose it is a testament to how zealous and evangelical we can be without realizing it.

    Cheers - L~R

Re: Don't go all PerlMonks on me
by wfsp (Abbot) on Apr 09, 2007 at 07:55 UTC
    But oh how lucky she was there weren't two perlmonks to give advice. "Don't go all perlmonks on me" would have had a completely different meaning. :-)

    (btw, dreadful choice of HTML parser) ;-)

      btw, dreadful choice of HTML parser
      LOL! If we had more time (see dana's reply) I might have suggested HTML::Parser, but quite frankly I chose it for simplicity. It not only would have taken me longer to get something working with HTML::Parser, but it probably would have been harder for her to understand (handlers, etc).

Re: Don't go all PerlMonks on me
by perrin (Chancellor) on Apr 09, 2007 at 14:48 UTC
    Good story. It makes an interesting point too: one person's basic sanity is another person's gold-plating. While I never write a program without strict and warnings because I find it harder, some people think those pragmas are a waste of time for a one-off program. This is something you have to be conscious of when trying to help others who may not share your views.
        While I never write a program without strict and warnings because I find it harder, some people think those pragmas are a waste of time for a one-off program.

      This quote should be framed.

      I talked to two people about code craft recently; one asked why I would use strict in a script, and another asked if it was really necessary to close a file.

      About using strict, I said it made about as much sense as wearing a seat belt -- skip it at your own risk. About not explicitly closing filehandles, I said that I always 1. open the file (and always with or die afterwards), 2. close the file, and 3. go back up to just after the open statement and do whatever it was I was going to do with the file.

      Being lazy can be a good thing, but too much laziness can be a bad thing. It can be embarrassing spending 20 minutes chasing down a problem in a one-liner that you could have solved right away if you'd just used strict.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Re: Don't go all PerlMonks on me
by gloryhack (Deacon) on Apr 09, 2007 at 09:32 UTC
    I'm really very curious to know what she meant, and I'm hoping you'll ask her and post a followup to let us all know what she says.

    My guess is that she just wanted a solution without any additional education.

Re: Don't go all PerlMonks on me
by cog (Parson) on Apr 09, 2007 at 09:46 UTC
    My guess: "Don't tell me to join PerlMonks and post my question there!"

    Or: "Don't tell me 'If you were on PerlMonks...'"

      I actually joined perlmonks a bit back and had already posted a question (Connecting to remote db with DBI) so my comment really wasn't an attempt to avoid any learning opportunity or chance to socialize at the Monastery.

      My problem was a very short timeline, a much needed vacation, and hand-me-down garbage code. Please see Re: Don't go all PerlMonks on me for more details. Although if I were not already on perlmonks, I probably would have baulked given the circumstances!!! :)

Re: Don't go all PerlMonks on me
by Cap'n Steve (Friar) on Apr 11, 2007 at 06:15 UTC
    I can sympathize with her. On Perlmonks, all code is assumed to be written in a perfect world. You have to phrase your question very carefully and even if you preface it with "I know this is a bad idea, but let's pretend it has to be done this way.", you'll still get several replies saying that's the wrong way to do it. Don't get me wrong, it's still the best programming resource I've seen, but it sure helps if you know "the rules".
Re: Don't go all PerlMonks on me
by Anonymous Monk on Apr 10, 2007 at 16:34 UTC
    Just as a counterexample, I have used the "Don't go all PerlMonks expression" to describe to someone that I don't want them writing entire programs in unreadable obfuscated regexen :)

      You bring up an excellent point. While the help is amazing and my code is much more concise it is tougher to "read"!! Asking for help from bobf means trying to understand when he says 'toss it into blah blah blah module and there you go'....to which my comeback is usually 'HUH'??? He is much more articulate than I. :)

        the help is amazing and my code is much more concise
        Thanks! I think "amazing" is a bit more than I deserve, though. :-) No, I did not pay her to say that.

        it is tougher to "read"
        Well, I hope I never help so much that you don't understand what the code is doing - that's certainly not the intention.

        Code readability is in the eye of the beholder, and striking an effective balance between concise idioms and step-by-step explicity is an art that is best appreciated at a given point in time (since that balance will likely change over time, especially when just starting to learn Perl and getting more comfortable with common Perl idioms). See threads such as What is code readability? and Should I leave behind beautiful code or readable code? for more discussion and debate on this topic.

        For the record, I don't think I've ever told you to toss something into either Acme::BlahBlahBlah or Yada::Yada::Yada. ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://608933]
Approved by McDarren
Front-paged by McDarren
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-03-28 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found