in reply to Cross-Platform code
1) Instead of changing the #! line, you could have OS-specific .pl's which initialize variables to OS-specific values, the uses do to execute the common code.
2) You shouldn't need to use $sep. For that, we have core modules File::Spec and File::Basename.
applic_linux.pl --------------- #!/usr/bin/perl our $logdir = "/home/ghodmode/logs"; do 'applic.pl'; applic_win32.pl --------------- #!c:\perl\bin\perl our $logdir = "c:\\xampp\\xampp\\webapp\\logs"; do 'applic.pl'; applic.pl --------- use strict; use warnings; BEGIN { our $logdir; die(...) unless defined $logdir; } use File::Spec (); my $logfile = File::Spec->catfile($logdir, 'error_log.txt'); ...
Better yet would be to use a config file to hold the name of the log dir. That would be both OS-independant and more useful.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Cross-Platform code
by wolv (Pilgrim) on Feb 06, 2006 at 10:03 UTC |