The problem with your original code is probably that the require Expect is failing so it never gets to the require Win32::Setupsup. For an easy fix, put the two in separate evals.

Or you can say:

use if $^O=~/Win/, "Win32::Setupsup"; use if $^O!~/Win/, "Expect";
IIRC, if.pm is in every perl version > 5.6.1 except 5.8.0, and is also available from cpan.

Update: I noticed a couple of posts saying /^Win/, which is wrong:

$ fgrep osname= hints/*.sh */config* hints/epix.sh:osname='epix2' hints/linux.sh:# The DR2 of MkLinux (osname=linux,archname=ppc-linux) +may need hints/mpeix.sh:osname='mpeix' hints/os400.sh: osname=aix hints/qnx.sh: *) osname='nto' Cross/config.sh-arm-linux:osname='linux' NetWare/config.wc:osname='NetWare' Porting/config.sh:osname='dec_osf' epoc/config.sh:osname='epoc' plan9/config_sh.sample:osname='plan9' win32/config.bc:osname='MSWin32' win32/config.gc:osname='MSWin32' win32/config.vc:osname='MSWin32' win32/config.vc64:osname='MSWin32' wince/config.ce:osname='MSWin32'
It is MSWin32 (even on 64-bit windows, I think).

In reply to Re: How can I include a module for Windows only?? by ysth
in thread How can I include a module for Windows only?? by pijush

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.