use if $^O == "WINMS32", Term::ANSIColor => qw(:constants);
That's not quite right.
The condition you want is
$^O eq 'MSWin32'
The condition you've used will generally evaluate as true on
all systems because, in numeric context, both $^O and "WINMS32" are generally 0.
If you
use warnings you should receive 2 warnings - one about the non-numeric nature of "WINMS32" and one about the non-numeric nature of $^O ("MSWin32").
Also, on perl-5.26.0 at least, I find that if I
use strict then I also need to place quotes around
Term::ANSIColor.
This is contrary to the
if documentation which states:
<quote>
The use of => above provides necessary quoting of MODULE . If you don't use the fat comma (eg you don't have any ARGUMENTS), then you'll need to quote the MODULE.
</quote>
I'll submit a bug report about this oversight in the "if" documentation.
UPDATE: Bug report submitted.
I personally prefer to use "require" to load modules in this type of situation:
if($^O eq 'MSWin32') {
require Term::ANSIColor;
Term::ANSIColor->import(":constants");
}
Cheers,
Rob
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.