Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Showing Sample Source Code without Modules

by Belgarion (Chaplain)
on Dec 02, 2005 at 15:58 UTC ( #513621=perlmeditation: print w/replies, xml ) Need Help??

I recently had my first real Perl programming interview. I've used Perl for years in my consulting business, but the clients did not care what language I programmed in. However, this position is for an actual Perl programmer, so they wanted to see a sample of my work. Not a problem I thought, I've done lots of Perl programming.

But wait! There's a couple of requirements to this sample code

  1. Must be at least around1 100 lines long
  2. Must not contain many modules uses

Ummm....

Now I was stuck. Any Perl scripts I've written which do not require a module or two are just toy scripts under 25 lines in length. Everything else worth programming, I feel, can use a module or more. For example, if I'm programming a web application I'm likely reaching for CGI::Application, Class::DBI, and Template Toolkit to start unless it's extremely simple (more a script, and less an application.)

How would my fellow monks handle this situation? Unless you've written a module as example work, how do you show your Perl programming skills without relying on external modules, but still have an application that's around 100 lines in length?


1 Clarified that the interviewer was requesting around 100 lines. Not much less, and not much more.

  • Comment on Showing Sample Source Code without Modules

Replies are listed 'Best First'.
Re: Showing Sample Source Code without Modules
by dragonchild (Archbishop) on Dec 02, 2005 at 16:52 UTC
    Whenever I've been asked this question in interviews, I point to my CPAN modules. This may not be feasible for you, but it's definitely something to consider. A number of people here (including myself) have been asking for help with their CPAN modules ... getting your name as a co-author with the ability to say "I wrote that 100 line subroutine in its entirety, plus these tests over here" shows not only that you can write code, but that you can write code as part of a team.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

      Thank you for the suggestion! I had not considered helping out on a module. I've sent patches to various modules in the past, but probably not enough to be considered a co-author. I'll have to investigate what modules I think I can help with. Thank you again.

Re: Showing Sample Source Code without Modules
by gwhite (Friar) on Dec 02, 2005 at 16:26 UTC

    I think the key here is that they want to see that you know how to program and are not just calling prewritten subroutines. I would use your "best code" regardless of the modules called and make sure that _your_ logic is properly documented.

    g_White

      Thank you for your insight. I was concerned that if I showed them one module (maybe a CGI::Application derived class for example) that was part of a larger system that there would be no context as to the intent of the code in the bigger scheme.

      I could have shown them my custom written CGI::Application base class that I use as the starting point for my web applications, but it contains a lot of use ClassName statements since it loads most of the modules I'll need in the rest of the application. It also does implement new base code and helper functions, but I thought it would seem out of context since it doesn't do anything on it's own.

      I think you are right though. Show the best code regardless of context and hope for the best. Thank you again.

Re: Showing Sample Source Code without Modules
by bageler (Hermit) on Dec 02, 2005 at 17:05 UTC
    I usually send a few of things when I'm asked for code samples. A web app, a Tk app, a library or two, and some obfu or poetry just for kicks.
Re: Showing Sample Source Code without Modules
by Anonymous Monk on Dec 02, 2005 at 20:38 UTC
    How would my fellow monks handle this situation? Unless you've written a module as example work, how do you show your Perl programming skills without relying on external modules, but still have an application that's around 100 lines in length?

    Take an hour or two, write a little 100 line app. Document it, make it pretty and elegant, submit it to the interviewer.

    Where's the problem?

      Well, in this case I had to send the sample immediately after the conclusion of the interview. Basically, I had to have something already prepared. I admit I should have had "sample" code ready, but as I said this was my first Perl specific interview. Inexperience in this matter caused me to be caught off guard. Hence my desire to seek opinions from those more experienced in these situations. Thank you for your help.

        Your case reminded me of my personal case, when I was new to Perl programming. I never used to use any external modules in my code. Just because I was Not aware of CPAN and I wanted to develop everything myself (I realized later that it is Not a practical thing to do, you enjoy but your Boss suffers because of delay of submitting assignment).
        If you don't use any module then the code automatically becomes lengthy, it would surely cross 100 lines. To give you a suggestion, please write a code to convert a text file from one format to other format (e.g. one XML dtd to other XML dtd). This assignment would involves pure regular expressions and would Not need any external module
        I have written RTF to text converter without using any external modules, it is 1147 loc, I took lot of time to understand RTF format and develope the code (After writing the code I came to know that there is something similar available in CPAN :-))
Re: Showing Sample Source Code without Modules
by jonadab (Parson) on Dec 03, 2005 at 20:32 UTC
    1. Must be at least 100 lines long 2. Must not contain many modules uses

    I thought you said they were looking for a Perl programmer. They won't likely get a very good Perl programmer with those requirements. I'd submit an essay explaining why why Perl code over 100 lines that doesn't use modules is a sign of inexperience and poor design.

      If you did that in response to a request from me, you wouldn't get the job. There's nothing worse for me, as a hiring manager, than when an applicant tries to second guess me, or thinks he knows better than me what I want.

      xoxo,
      Andy

        But if this is what you want, a decent perl programmer probably wouldn't want to work for you.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2021-06-14 03:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (60 votes). Check out past polls.

    Notices?