Re: Running the same perl script on Win32 and Unix



jeffhua@xxxxxxx wrote:

I don't want to maintain two scripts, and it seems I cann't do
something like this on the top of the script:
if ($platform eq 'WINDOWS') {
use Win32::Process;
}

Anyone can help?


Hi,it seems that you want to put them in BEGIN block.ie,

BEGIN {
use vars qw/$OS/;
$OS = $^O eq 'linux' ? 'Linux' : 'others';
}

Can you please explain in what way that would at all solve the OP's
problem? Can you please also explain why you're using the depreciated
'vars' pragma?

Paul Lalli

.



Relevant Pages

  • Re: Efficiently searching multiple files
    ... J> sub scripts_dir { ... J> my($lines, $leaf, $header, $header2); ... don't declare vars before you need them. ... foreach my $scripts { ...
    (comp.lang.perl.misc)
  • Re: How to make global vars?
    ... > I'm trying to figure out how to use/make simple global vars. ... > seperate file that does the connection and call it in the other scripts; ... > use strict; ... perldoc strict ...
    (comp.lang.perl.misc)
  • Re: Env variables in ooRexx & XP?
    ... But subsequent scripts might not get such a change if started from ... has an ooRexx interface for its scripting needs. ... I can hard-code my desired "environment vars" in a common script, ...
    (comp.lang.rexx)
  • Re: Take three form variables and write to an "settings-file"
    ... Paul Lalli wrote: ... >>textfields and put them in an local file on the webserver. ... >>This information is later on used in shell scripts running on the server. ... > Have you ever done any CGI programming with Perl? ...
    (comp.lang.perl.misc)
  • Re: JScript download stops others?
    ... until all the scripts are loaded and parsed. ... but Cache-Control and Pragma are: ... Cache-Control: no-cache ... Unsolicited commercial email will be read at a cost of $500 per message. ...
    (microsoft.public.scripting.jscript)