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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I'll try...

1. What arguments do you frequently use for the Perl interpreter and what do they mean?

Man... I use lots of them!!! I can't explain them all :-) I even gave a talk and wrote an award winning paper on them... But OK, I guess I'd go with -e for one-liners -n and -p for line processing, and probably with -i for inline processing (I would mention -w, but I "use warnings" instead)

2. What does the command ‘use strict’ do and why should you use it?

It enforces strictness! :-) You should use it because it will help you avoid pestering errors that nobody likes (forgotten my declarations being the most usual ones). I nowadays use it most for discipline. It's not that one my programs wouldn't work without it, but I prefer to be on the safe side. Also note that I don't use strict for one-liners.

3. What do the symbols $ @ and % mean when prefixing a variable?

They mean what's after them is supposed to be interpreted, respectively, as a scalar, an array or a hash.

4. What elements of the Perl language could you use to structure your code to allow for maximum re-use and maximum readability?

Are you refering to modules or am I getting something wrong? Are you talking about objects? Some good practices? I think the question should be rephrased...

5. What are the characteristics of a project that is well suited to Perl?

It's not the project that is well suited, it's the language that might be! And I don't feel confortable yet (with the current experience I have) answering to that :-) Sorry :-)

Second round :-)

1. Why do you program in Perl?

Because it's fun and fast (to code). I don't spend loads of time trying to figure why the code doesn't work when I could be spending it thinking about how to solve the problem. The community around it is also a big plus!

2. Explain the difference between my and local.

I'm not sure but I think I heard someone say it was kind of the same thing, internally... I may be wrong about this... But you do get the same effect, apart from some weird case I'm not thinking about right now...

3. Explain the difference between use and require.

"use" is at compile time, "require" is at run-time? It's weird how you code and code and only when somebody asks you something you start having questions about it :-)

4. What’s your favorite module and why?

CPAN::Mini, for now I have the CPAN on my laptop and no longer rely on internet access to install new modules. If you asked me for another one, it would be Data::Dumper

5. What is a hash?

Look... that is not a Perl question... but OK, I'll play along... Think of it as a table with two columns. You put keys in the left column and their corresponding values in the right one. And then I should tell you lots of stuff, like "You can't have a value with a key", "You can't have two values for the same key" and so on (No, you can't have two values for the same key, what you can have is a value that holds more stuff inside it).

6. Write a simple (common) regular expression to match an IP address, e-mail address, city-state-zipcode combination.

IP address: qr/(\d{1,3}\.){3}\d{1,3}/ # Yes, it accepts 0's at the beginning and that's probably wrong, but then again, I'm not actually at a job interview :-)

e-mail address: qr/\w+\@\w+\.\w+/ # once again, that's wrong; I would have to check on what's valid and what's not, because I really don't know :-)

city-state-zipcode: Being Portuguese, I really do not know what a city-state-zipcode combination looks like :-\

7. What purpose does each of the following serve: -w, strict, -T ?

-w uses warnings, strict has already been explained above and -T is tainted mode, which I usually don't use because I don't usually get information I don't trust.

8. What is the difference between for & foreach, exec & system?

for & foreach are now an alias to each other (Ok, one of them is implemented, but they're actually the same thing). As for exec & system, I don't use them much, so I'd have to check on documentation (and don't forget backticks, too)

9. Where do you go for Perl help?

I usually *give* Perl help, but when I need it (because I sometimes do too) I first ask some friends of mine, and then I come to perlmonks.

10. Name an instance where you used a CPAN module.

I use CPAN modules on a daily basis :-) I used LWP the other day to retrieve my yml files (kwalitee stuff)

11. How do you open a file for writing?

Usually with open (FILE, ">$file") or die "could not open file '$file' for writing ($!)";

12. How would you replace a char in string and how do you

$string =~ y/a/b/

13. store the number of replacements?

my $number = y/blah/blah/, but that's not really a good question, because many people don't know that, and that doesn't make them worse programmers.

14. When would you not use Perl for a project?

When Hell freezes over :-P

In reply to Re: Interview Prepration by cog
in thread Interview Prepration by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (4)
    As of 2020-10-20 07:17 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (209 votes). Check out past polls.