Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • My question for Java developers is always the same: can you, without looking at the docs, write the code to open a file, read the first line from the file (delimited by a newline) and print said line? The answer is invariably "no, but ...".

    The counter-argument is that since they don't need to do this very often, there's no need to optimize this. When you're working in an "enterprise" environment, you're not constantly opening and reading files. Just to prove this point, I ran this on our codebase here

    • If you do need it, you stick it in a library. Something like:

      String line = FileUtil.slurpLines( path | file )[0];
      Or if you want it from the classpath, not just a file path:

      String line = new Resource( classpath-ref ).slurpLines()[0];
      File handling is one of my Java interview questions :-)