Category: | Win32 Stuff |
Author/Contact Info | Soren Andersen <somian -AT- pobox *DOT* com> |
Description: | A work-around for the absence of a defined value in the built-in special variable $^O (platform, Operating System) in some Perls on Win 95/98. In present form, simply determines if the platform is Win32 or not. The usual `require "OS.pl";' statement is all that's needed. |
# ******************************************************** # OS.pl # for Perl scripts that need to know the OS # (c)2000,2003 Soren Andersen # This program is Free Software, it may be used, modified # and redistributed under the same terms as Perl itself. # L/M: Friday Aug 01 2003 # ******************************************************** sub IsNotWin { if ($^O and $^O !~ /WIN32/i) { return 1; } elsif ($^O and $^O =~ /WIN32/i) { return 0; } elsif (eval ('require ("Win32")') ) { return 0; } return 1; } 1; __END__ =head1 NAME OS.pl =head1 SYNOPSIS Here is one way to use this: BEGIN { require ("OS.pl"); if &IsNotWin { print STDERR "Sorry! This script does not run yet ". "on anything but 32-bit Windows, and ". "you are using $^O\n"; sleep(3); die; } } =head1 AUTHOR =over 8 Soren Andersen somian -AT- cpan -DOT- org =for html <BR><BR> =cut Colorized version left for historical authenticity :-) -- was not popular with the Monks. # ******************************************************** # OS.pl # for Perl scripts that need to know the OS # (c)2000,2003 Soren Andersen # This program is Free Software, it may be used, modified # and redistributed under the same terms as Perl itself. # L/M: Friday Aug 01 2003 # ******************************************************** sub IsNotWin { if ($^O and $^O !~ /WIN32/i) { return 1; } elsif ($^O and $^O =~ /WIN32/i) { return 0; } elsif (eval ('require ("Win32")') ) { return 0; } return 1; } 1; __END__ =head1 NAME OS.pl =head1 SYNOPSIS Here is one way to use this: BEGIN { require ("OS.pl"); if &IsNotWin { print STDERR "Sorry! This script does not run yet ". "on anything but 32-bit Windows, and ". "you are using $^O\n"; sleep(3); die; } } =head1 AUTHOR =over 8 Soren Andersen somian -AT- cpan -DOT- org =for html <BR><BR> =cut |
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: OS.pl
by Ovid (Cardinal) on Jun 29, 2000 at 00:07 UTC | |
by Anonymous Monk on Jun 29, 2000 at 02:22 UTC |
Back to
Code Catacombs