Slash Boxes
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

use Perl Log In

Log In

[ Create a new account ] (8643)
  (email not shown publicly)

Journal of (8643)

Tuesday July 14, 2009
05:40 AM

say deadlock

[ #39287 ]

Imagine you have to teach a bit of Perl. The first thing you'd probably say is "say". Yes, I hope you'd prefer to use 5.10 for teaching and at the first lesson wouldn't mention that there exist another 5x version which is not fully compatible with 5.10.

You can start teaching from print "Hello\n", having to explain the meaning of slash-n only, but it is rather boring to use "print" when you have working "say". But to run a programme with "say" you have to either use version or feature pragma, or use Modern::Perl. These are much more things to explain now.

Thus if you would like to demonstrate the brilliant short name "say", you have to bring with it odd and long instructions just to turn "say" on.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • perl6 -e 'say "Hello, World"'
    perl -E 'say "Hello, World"'

    OK, beat me for it ;-)

    (I know that -E is not great because then you have to explain why it's available in the one-liner, and not in "normal" programs by default).
    • I thought about that during the day. These examples are good, and in fact I think that they may be used as the first examples of Perl code.

      They slightly break the idea of showing pure Perl code, but it is better in that you don't need even a file to save the programme in. Just run it from the command line.

  • perl -Mcommon::sense -le 'say "hi andy!"' # credits for digging out this module goes to daxim :)
  • Why not go the other way and do a hello world with as many builtins as possible. ^.^