From: Gary Yang <[EMAIL PROTECTED]>
> 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? 

perldoc perlvar
 look for $^O

Most often you do not need to do that though

> if ($usingUNIX)
>     {
>     $directory = `ls`;   #UNIX version.

glob(), <*.txt> or opendir() and readdir() under any OS.

>     $copyCommand = `cp`;   #UNIX version.

use File::Copy; under any OS

>     }
> 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? 

What do you mean "does not work"? Unless you use a unixish shell, 
Windows does not give a damn about the line and find the perl 
executable using the file extension mapping. And perl does scan that 
line and uses whatever parameters that are specified there so even
#!/usr/bin/perl -w
works just as well under Windows.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery

_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to