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.
In reply to Re: Cross-Platform code
by ikegami
in thread Cross-Platform code
by GhodMode
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |