Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I just had a look and all the tests are passing for me on windows.

    If you drop the following into Color.pm it should enable color display on windows (assuming Win32::Console::ANSI is installed).

    use constant IS_WIN32 => ( $^O =~ /^(MS)?Win32$/ );

    my $NO_COLOR;

    BEGIN {
            $NO_COLOR = 0;
            if( IS_WIN32 ) {
                    eval 'use Win32::Console::ANSI;use Term::ANSIColor';
                    $NO_COLOR = $@ if $@;
            }
            else {
                    eval 'use Term::ANSIColor';
                    $NO_COLOR = $@ if $@;
            }
    }
    • That would certainly be a nice bonus for Windows users. Are you sure that $^O sometimes returns MSWin32? I thought it was always Win32. If this is documented somewhere, I'd love to read that.

      • I'm not really sure. Tbh I just copied and pasted it from else where (Perl.pm and Source.pm)

        My activestate perl does.

        G:\Documents and Settings\link>perl -e"print $^O . \"\n\";"
        MSWin32

        As for docs , perldoc perlvar says

        In Windows platforms, $^O is not very helpful: since it is always MSWin32 , it doesn't tell the difference between 95/98/ME/NT/2000/XP/CE/.NET. Use Win32::GetOSName() or Win32::GetOSVersion() (see Win32 and perlport) to distinguish between the variants.
        • Thanks. By the way, your one-liner can be simplified with the 'l' (el) switch which forces a newline after every print:

          perl -le "print $^O"

          That's very handy when I'm writing quick utilities.