Hey all,

On Windows (2012 server, running perl 5.22.1), I get expected results using use if ...;:

use if $^O !~ /MSWin/, "Proc::Daemon"; use if $^O =~ /MSWin/, "Win32::Daemon"; print "$INC{'Win32/Daemon.pm'}\n"; exit; __END__ C:/berrybrew/5.22.1_64/perl/vendor/lib/Win32/Daemon.pm

But on Ubuntu, running v5.22.1:

use if $^O !~ /MSWin/, 'Proc::Daemon'; use if $^O =~ /MSWin/, 'Win32::Daemon'; print "$INC{'Proc/Daemon.pm'}\n"; exit; __END__ Too few arguments to 'use if' (some code returning an empty list in li +st context?) at /home/ubuntu/perl5/perlbrew/perls/perl-5.22.1/lib/5.2 +2.1/if.pm line 7. BEGIN failed--compilation aborted at /home/ubuntu/perl5/perlbrew/perls +/perl-5.22.1/bin/bbtester line 6.

I can't really find anything about this being a known problem. Proc::Daemon is properly installed (as I can use it in a module without the conditional use):

perl -MProc::Daemon -E 'say $Proc::Daemon::VERSION' 0.23

Can anyone spot anything I'm doing wrong, or is this something that just doesn't work reliably?

Update: I just realized that this was my 1,000th post here on PerlMonks :)


In reply to Problem with ``use if COND, Some::Module'' on Linux by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.