www.delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT sources DOT redhat DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT sources DOT redhat DOT com> |
List-Help: | <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs> |
Sender: | cygwin-owner AT sources DOT redhat DOT com |
Delivered-To: | mailing list cygwin AT sources DOT redhat DOT com |
Message-ID: | <AF19381B57F7D2118FC00000F8FA60EE02D4594C@dste02.itg.ti.com> |
From: | "Fay, Michael" <mfay AT ti DOT com> |
To: | "'cygwin AT sourceware DOT cygnus DOT com'" <cygwin AT sourceware DOT cygnus DOT com> |
Subject: | How should I write a UNIX/NT portable Perl script? |
Date: | Mon, 30 Oct 2000 20:04:36 -0600 |
MIME-Version: | 1.0 |
X-Mailer: | Internet Mail Service (5.5.2650.21) |
[My apologies if my attempted post of this on 10/26 actually went out; I didn't see it myself...] In the Cygwin/bash environment, is it possible to write a single Perl script such that 1. You invoke the script simply by naming it, without saying 'perl ...': script option: it would be ok if it had to be called via: script.pl or script.plx 2. The script uses the perl.exe that it finds in the $PATH, rather than hard-coding it on the first line. E.g. the following preamble inside the script works on UNIX but I'm having trouble making it work under bash/cygwin without saying 'perl script ...': eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}' && eval 'exec perl -w -S $0 $argv:q' if 0; The classic #!/usr/local/bin/perl -w is undesirable because I might want to switch perl's easily, e.g. by changing $PATH. Also, this script might run at many sites and there are a lot of UNIX system admin's I would have to ask to put perl in my favorite place. 3. The mechanism used to accomplish 1. and 2. works identically on UNIX and cygwin/Win9x/WinNT. That is, a single script works in both environments. -- I don't want to maintain two versions -- I don't want to have to write a wrapper every time I write a script (but perhaps a single generic wrapper would be ok). I would be interested to see how others cope with writing Perl scripts portably. Michael Fay Texas Instruments, Santa Barbara mfay AT ti DOT com -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |