Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
  1. Seldomly when using a she-bang line (-T being an exception, and for quick and dirty hacking, -s), but from the command-line: -w, -p, -n, -a, -i, -l, -e, -0, -c, -D, -v, -V, -I, -M, -x belong to my favourites. Do I have the time to explain all of them?
  2. use strict is not a command - it's a statement. It compiles the module, and calls the import sub in it. This will twiddle some bits in $^H, which causes the compiler to check for certain things, and complain if the conditions aren't met. I don't know whether I should use it, but I can explain why I often do use it. (insert strictness mantra).
  3. It depends a little on the context. It could mean the following variable are scalars, arrays or hashes, but it could also mean that the following expression is used as a scalar, list, array or hash.
  4. All of them. But perhaps "whitespace" is the most important for readability (and hence, reusability). Although, technically, "whitespace" would mean the absence of any element of the Perl language.
  5. I believe that "suitable language" is more defined by the programmers going to do the project than the project itself most of the time, so my answer would be "if the programmers are Perl programmers".
  1. Because I happen to know it, and it often satisfies my needs.
  2. my declares a lexical variable (or a set of lexical variables), local creates a new (or a set of new) value for a non-lexical variable (which is not the same as a package variable).
  3. use is done at compile time, calls import if applicable, and can only be given a bare word as first argument. require is done at run-time, takes an expression (or a version) as argument, and doesn't call import.
  4. It depends on what I want to do.
  5. A mapping that maps strings to arbitrary scalars.
  6. IP addresses? In which format? Dotted quads? Hex? 32 bit integers? IPv4? IPv6? There are no simple regexes for e-mail addresses, unless you either wants lots of false positives, false negatives, or both. City-state-zipcode of which country? US? If so, what format zip codes? 5 digits? 5+4? Either? As for states, 2 letter states? 3 letter states? 2 or 3 letter states? Do you expect your programmers to remember all 50 abbreviations? There are a few extra areas that have "state codes" as well? Am I supposed to know them?
  7. -w tests whether a file (or filehandle) is writeable for the EUID, -T guesses if a file (or filehandle) is an ASCII file, and strict is a bare word that "use strict;" wouldn't approve off.
  8. There's no difference between for and foreach. And system does a fork, execs in the child, waits in the parent.
  9. The manual has all I need.
  10. You see, I wanted to write this program ....
  11. It depends. There's 2-arg open, 3-arg open, sysopen (either of which can be used with a filehandle, or a reference to a filehandle as first argument, and Perl will happely autovivify an undefined value into a reference to a filehandle for you as well), and modules like IO::File, IO::All, and Inline::Files. I typically use 2-arg open, 3-arg open and sometimes sysopen. All three with references to filehandles (usually autovivified handles) as first argument. Filehandles as first argument is asking for trouble.
  12. _A_ character in a string? As in, a single one? Say, the third character? substr($str, 2, 1, "x") if length($str) >= 3;
  13. Well, that would be either 0 or 1, and it will be 1 if, and only if, the string originally was at least 3 characters long.
  14. If the other programmers don't know Perl. If speed is crucial. If the target environment has limited resources (memory, disk, CPU). If the source cannot be distributed. If deployment is going to be a problem. If portability demands it. If it needs to run in an environment perl doesn't run in, or can't be installed into. If the customer demands a .NET solution. If there's a domain specific language far more suitable for the problem than a generic language like Perl. If low level memory access is a major part of the solution. If the moon is blue. If I feel like using Java for today. If it's better done using a Makefile.

In reply to Re: Interview Prepration by Anonymous Monk
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":

  • 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?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2021-07-26 02:20 GMT
Find Nodes?
    Voting Booth?

    No recent polls found