in reply to Re: while (<FP>) conditionals
in thread while (<FP>) conditionals

It does, thank you. I tried running your first test:
perl -we "my $s = qq[0\n]; printf qq[%s\n], ($s ? 'true' : 'fal +se');
All I ever got were the following errors:
syntax error at -e line 1, near "my =" Search pattern not terminated or ternary operator parsed as search pat +tern at -e line 1.
However, when I put it into a script and ran it, it worked fine. Also, your second test does not work for me:
#! perl use strict; use warnings; local $/ = \1; for ($_ = <DATA>; $_; $_ = <DATA>) { print "<$_>\n"; } __DATA__ 1 0 42
When I run it, I get the following:
<1> < >
But at this point, my question is answered. Now we're just toying around!

Replies are listed 'Best First'.
Re^3: while (<FP>) conditionals
by SuicideJunkie (Vicar) on Feb 05, 2014 at 15:31 UTC
    When typing code on the command line, you often have to escape some characters depending on your system.
    For example, the error message shows that: my $s = got munged by your shell into my  = before it was passed to perl.
      Another reason we should not use one-liners in replies if the OS is not specified.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      I escaped the two $s instances with backslashes and it worked fine. I'm still not sure why %s didn't need to be escaped. As you can probably tell, I'm not too well versed in the linux shell either...
Re^3: while (<FP>) conditionals
by Athanasius (Archbishop) on Feb 05, 2014 at 16:48 UTC
    Also, your second test does not work for me ... When I run it, I get the following:

    But that’s exactly what you should get! local $/ = \1; makes the diamond operator read one character at a time. The first character is 1, which is printed. The second character is a newline, which is also printed (I put the angle brackets in to show that a new line has been printed). The third character is 0, and because the C-style for-loop is not magic, this is “false” and the loop terminates without printing anything more.

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      OK, yes, I skipped over the 1-character point. It's actually only printing two things). Thanks, all straight now!