From: Charles A. <cha...@al...> - 2008-01-24 19:53:08
|
http://perldoc.perl.org/perlvar.html#$OSNAME $^O or "use English" and $OSNAME will tell you a little more than what =20 you're trying to do. What you're trying kind of reminds me of how =20 Javascript'ers figure out the browser or XHR call they need. As far as the shebang line (#!...), you're right, that doesn't work in =20 Windows. But, you can always run your Perl code from the command line =20 by explicitly calling perl. Example: "%> perl myscript.pl". That =20 works no matter the OS you're using. Under Windows, you can optionally associate files with .pl extensions =20 with the perl.exe executable. That shouldn't be too hard to figure =20 out in your windows explorer: just double click a .pl file. Windows =20 associations also work from the command line. Although, if you're =20 running your scripts as cgi scripts under apache on Windows, you can =20 do both the shebang line or windows file extension associations. Just =20 check out your apache configuration file.... Just to let you know, your question was posted to mailing list for the =20 Win32-GUI module, so it wasn't really topical for this mailing list. =20 If you have any other questions regarding running Perl under windows =20 or unix, they would be better addressed in a different mailing list. =20 Activestate hosts a bunch like perl-win32-users or perl-unix-users. =20 See: http://aspn.activestate.com/ASPN/Perl/Mail/ Thanks, Charles Alderman Quoting Gary Yang <gar...@ya...>: > Hi All, > > I need to port my Perl script from Unix to Windows. Can someone =20 > tell me how to figure out which platform I am on? i.e. I need to =20 > know which Perl command can help me determin the platform. Once I =20 > know the platform, I'll code my script as the example bellow. But, =20 > how to figure out I am on Windows or Unix? > > if ($usingUNIX) > { > $directory =3D `ls`; #UNIX version. > $copyCommand =3D `cp`; #UNIX version. > } > else > { > $directory =3D `dir`; #Win32 version. > $copyCommand =3D `COPY`; #Win32 version. > } > > > Second question: > The UNIX #!/usr/bin/perl notation does not work with Perl scripts =20 > on Windows. How should I code if it is Unix I place =20 > "#!/usr/bin/perl" at the very first line of the script? But, I do =20 > not place it at the first line of code if it is not Unix? How should =20 > I do it? > > Your answers are greatly appreciated. > > > Thanks, > > > Gary > > > > > --------------------------------- > Looking for last minute shopping deals? Find them fast with Yahoo! Search= . |