Most likely, the OSTYPE environment variable is simply not set, and hence you get an undefined value for it. You can check that by using:
my $OSTY; if (not exists $ENV{OSTYPE}) { warn "Couldn't determine OSTYPE"; $OSTY = "<unknown>"; } else { $OSTY = $ENV{OSTYPE} };
More likely though, you might want to inspect the $^O variable, which returns you the type of operating system:
print "Running under $^O";
You could combine the two techniques, and fall back if $ENV{OSTYPE} is unavailable:
my $OSTY; if (not exists $ENV{OSTYPE}) { warn "Couldn't determine OSTYPE from environment - using $^O"; $OSTY = $^O; } else { $OSTY = $ENV{OSTYPE} };
In reply to Re: reading env variable in cygwin using perl
by Corion
in thread reading env variable in cygwin using perl
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |