in reply to Re: Logic expression evaluation not working. What am I doing wrong?
in thread Logic expression evaluation not working. What am I doing wrong?


"The expression !1 evaluates to ''" I tried the following:
#!/usr/bin/perl use strict; use warnings; printf "%b\n", !1;
which output the following:
0
on my Linux machine. So, not sure under what circumstances, like you say that it outputs '' empty string.
Can you elaborate a bit for novices like myself please?
TIA.

Replies are listed 'Best First'.
Re^3: Logic expression evaluation not working. What am I doing wrong?
by AnomalousMonk (Archbishop) on Jan 04, 2016 at 05:05 UTC

    I was thinking of the following contexts | examples:

    c:\@Work\Perl>perl -wMstrict -le "print '>', !1, '<';" >< c:\@Work\Perl>perl -wMstrict -le "print '>', !1 && 1, '<';" ><
    In numeric contexts such as that supplied by the  %b printf format specifier, !1 will, I think, always evaluate to numeric 0 — but it would be best to do some research on this!


    Give a man a fish:  <%-{-{-{-<