Académique Documents
Professionnel Documents
Culture Documents
Page 1 of 4
PERL – Cross platform development tips
Introduction
This document is intended for PERL development, where development is done
on one environment and deployment is to be done on different environment. Here
Perl refers to Perl batch programs not in reference to web development in Perl CGI.
Though Perl is interpreted and termed as platform independent, Perl programs
cannot be used as it is in different environments, mainly where Perl enables user to
access OS specific functionalities. This document may give Idea about type of
problems faced when development environment is different from deployment
environment, but will not be sufficient to get complete picture of it as this is written
from experiences from PERL development on windows and deployment on UNIX
system only.
Perl normally used for calling modules/jobs/programs which are developed using
some tools and not able to achieve complete functionality as a system. E.g. in data-
warehousing environment ETL tools are preferred for actual data transportation but
triggering of these jobs on some event needs some other interface. Because of this
Perl normally need to use OS specific commands and hence create problems in cross
platform development.
Page 2 of 4
PERL – Cross platform development tips
In case of splitting file name from complete path use variable to hold value of
separator ( \ or / ). Refer same from include file.
2. File transfer
ftp or rcp are most commonly used methods for transferring files from
different machines on network. rcp being specific to Unix can not be used
when development on different platform. It cannot be tested if development is
on windows.
ftp is in different network layer and independent of OS, so ftp commands like
cd, lcd, get ,put are independent of OS. But the command interface with OS is
different. Though it is accessible from OS command prompt with command
ftp, options / flags in Unix and windows are very much different. Also path
and filenames within ftp commands becomes OS specific as described in
earlier bullet point.
Page 3 of 4
PERL – Cross platform development tips
4. Sending Mail
Unix mail command may be the simplest way to send mails through scripts
but Perl Mail module can be useful if scripts need to be OS independent.
5. Other OS commands
There are lot of simple options in Unix scripts for doing small things. But if we
need to have scripts OS independent, there are options in Perl for each of
them, may not be as straightforward as shell command but definitely achive
the functionality.
wc –l can be replaced by a perl routine to open file and just scan thru to count
lines.
There is pattern matching in perl to replace grep in Unix.
Commands for Opening, closing, deleting file, checking existence of file in perl
are already OS independent.
Page 4 of 4