Hey Andy:
Use the Perl standard OS constant, $^O, when you want to know what OS
you're on. Here are some values that are returned: Windows => mswin32,
AIX => aix, Linux => linux. Your version of UNIX will return a
different value. By the way you'll want to use '\\' when creating
Windows directory paths and '/' when creating UNIX/Linux paths.
I add the shebang line to all of my perl scripts. I write a lot of
scripts that are used on both Windows and UNIX/Linux so it's useful to
include it in my standard template. Hope that helps.
Bo
On Thu, 2008-01-24 at 11:16 -0800, Gary Yang wrote:
> Hi All,
>
> I need to port my Perl script from Unix to Windows. Can someone tell
> me how to figure out which platform I am on? i.e. I need to know which
> Perl command can help me determin the platform. Once I know the
> platform, I'll code my script as the example bellow. But, how to
> figure out I am on Windows or Unix?
>
> if ($usingUNIX)
> {
> $directory = `ls`; #UNIX version.
> $copyCommand = `cp`; #UNIX version.
> }
> else
> {
> $directory = `dir`; #Win32 version.
> $copyCommand = `COPY`; #Win32 version.
> }
>
>
> Second question:
> The UNIX #!/usr/bin/perl notation does not work with Perl scripts on
> Windows. How should I code if it is Unix I place "#!/usr/bin/perl" at
> the very first line of the script? But, I do not place it at the first
> line of code if it is not Unix? How should I do it?
>
> Your answers are greatly appreciated.
>
>
> Thanks,
>
>
> Gary
>
>
>
> ______________________________________________________________________
> Looking for last minute shopping deals? Find them fast with Yahoo!
> Search.
> _______________________________________________
> Perl-Win32-Users mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs