| Store | Cart

Re: Questions on porting Perl from Unix to Windows

From: Sébastien Aperghis-Tramoni <madd...@free.fr>
Thu, 24 Jan 2008 22:41:26 +0100
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?

The usual way is to check $^O

     my $is_win32 = $^O =~ /Win32/i;


>  if ($usingUNIX)>     {>     $directory = `ls`;   #UNIX version.>     $copyCommand = `cp`;   #UNIX version.>     }> else>     {>     $directory = `dir`;  #Win32 version.>     $copyCommand = `COPY`;  #Win32 version.>     }

Unless you really want to manipulate commands, this code should be  
rewritten in real Perl, using opendir()/readdir() to list files and  
File::Copy to copy files.


-- 
Sébastien Aperghis-Tramoni

Close the world, txEn eht nepO.

Recent Messages in this Thread
Gary Yang Jan 24, 2008 07:15 pm
Frank Merrow Jan 24, 2008 08:04 pm
Frank Merrow Jan 24, 2008 08:10 pm
Frank Merrow Jan 25, 2008 01:10 am
Sébastien Aperghis-Tramoni Jan 24, 2008 09:41 pm
Messages in this thread