I think I found that "perlvar", and I saw that $^O, but I didn't think it would give me what I want. After thinking about it, I guess it would work in most cases, but not in my specific case.
I have a PC that has Cygwin on it (and Perl comes with the Cygwin), and I also have ActivePerl on it. I brought up a Cygwin window, and wrote a little script like this:
#!/usr/bin/perl
#!C:/Perl/bin/perl
print "^O\n";
When I run it like that I get:
Cygwin
If switch the two comment lines (so #!C:/Perl... is the first line), I get:
MSWin32
What I really want to know is that if I am the running the script from a Cygwin window, regardless of which of those two builds of Perl runs the script, it will tell me I am running in a Cygwin environment. If I run the script from an XP CMD window, I want it to tell me I am running in a windows environment.
| [reply] |
#!/usr/bin/perl
#!C:/Perl/bin/perl
The Cygwin shell will look at the 'shebang' line to determine what interpreter to use to run your script. So it will either run the cygwin perl (/usr/bin/perl) or the Activestate one (C:/perl/bin/perl) depending on which you put first. However, if you run it from an XP CMD window, I don't think it pays any attention to the shebang line. It'll be run with whatever perl you use from the command line or whatever perl is associated with it in the registry.
Put differently -- $^O tells you what the executing perl was compiled for, not where it was launched from.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
| [reply] [d/l] [select] |
So, I guess you're saying that there is no way to determine "where it was launched from", correct?
| [reply] |