From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gary
Yang
Sent: 24 January 2008 19:17
To: [email protected]
Subject: Questions on porting Perl from Windows to Unix

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

First, it is probably better if you write your scripts so that you don't
need to ask, i.e. aim for platform independence. Where this is not
possible there is the special variable $^O (See 'perldoc perlvar' for
details). If you need more detailed info about your platform you will
need the Config module (See 'perldoc Config'). Also see the Activestate
documentation for windows specific help.

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

The #! notation us unix specific. Win32 achieves a similar effect by
associating file extensions with a specific executable, called file
association and managed with the assoc command, but I think that the
Activestate installation procedure sets up the necessary associations
for Perl, so you shouldn't need to. If you use the #! line for to
specify run time switches you can still do that as perl will parse that
as well (see 'perldoc perlrun').

HTH

-- 
Brian Raven 

=========================================
Atos Euronext Market Solutions Disclaimer
=========================================

The information contained in this e-mail is confidential and solely for the 
intended addressee(s). Unauthorised reproduction, disclosure, modification, 
and/or distribution of this email may be unlawful.
If you have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message do not 
necessarily reflect those of Atos Euronext Market Solutions.

Atos Euronext Market Solutions Limited - Registered in England & Wales with 
registration no. 3962327.  Registered office address at 25 Bank Street London 
E14 5NQ United Kingdom. 
Atos Euronext Market Solutions SAS - Registered in France with registration no. 
425 100 294.  Registered office address at 6/8 Boulevard Haussmann 75009 Paris 
France.

L'information contenue dans cet e-mail est confidentielle et uniquement 
destinee a la (aux) personnes a laquelle (auxquelle(s)) elle est adressee. 
Toute copie, publication ou diffusion de cet email est interdite. Si cet e-mail 
vous parvient par erreur, nous vous prions de bien vouloir prevenir 
l'expediteur immediatement et d'effacer le e-mail et annexes jointes de votre 
systeme. Le contenu de ce message electronique ne represente pas necessairement 
la position ou le point de vue d'Atos Euronext Market Solutions.
Atos Euronext Market Solutions Limited Société de droit anglais, enregistrée au 
Royaume Uni sous le numéro 3962327, dont le siège social se situe 25 Bank 
Street E14 5NQ Londres Royaume Uni.

Atos Euronext Market Solutions SAS, société par actions simplifiée, enregistré 
au registre dui commerce et des sociétés sous le numéro 425 100 294 RCS Paris 
et dont le siège social se situe 6/8 Boulevard Haussmann 75009 Paris France.
=========================================

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to