Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: shebang line - foreign to me

by zengargoyle (Deacon)
on Dec 27, 2002 at 05:05 UTC ( [id://222474]=note: print w/replies, xml ) Need Help??


in reply to shebang line - foreign to me

best practice would be to wrap up your script(s) in a module and patch them up when you install.

or mabye just an install.pl script whose usage is mentioned in your README and/or INSTALL help.

or possibly just mention that they may need to fix the line themselves. i can't say i've ever been really irate that somebody uses /usr/bin/perl even though i have to change it to something else.

Replies are listed 'Best First'.
Use ExtUtils::MakeMaker to install scripts
by IlyaM (Parson) on Dec 27, 2002 at 10:17 UTC
    Exactly. This is why for all Perl scripts I'm going to distrubute on other systems I use ExtUtils::MakeMaker which does such patching automatically.

    It is very simple:

    < Makefile.PL file > use ExtUtils::MakeMaker; WriteMakefile(NAME => 'Hello', VERSION => '1.00', EXE_FILES => ['hello']); < MANIFEST file > Makefile.PL hello < hello file > #!perl use strict; use warnings; print "Hello, world!\n";
    Once finished you can type perl Makefile.PL; make dist and get tarball ready to install with tar zxvf Hello-1.00.tar.gz; cd Hello-1.00; perl Makefile.PL; make; make install

    Update: Replaced 'script.pl' with 'hello' in 'MANIFEST'.

    --
    Ilya Martynov, ilya@iponweb.net
    CTO IPonWEB (UK) Ltd
    Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net
    Personal website - http://martynov.org

      Exactly. This is why for all Perl scripts I'm going to distrubute on other systems I use ExtUtils::MakeMaker which does such patching automatically.
      Either that's a recent feature (and therefore not portable), or hasn't been documented.

      Where did you find out about this?

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.

        Either that's a recent feature (and therefore not portable), or hasn't been documented.

        I think it was there at least since 5.005. There is some mentions of this feature in ExtUtils::MM_Unix (search for fixin) but it seems it is not documented anywhere properly.

        Where did you find out about this?

        From personal experience. I just noticed that ExtUtils::MakeMaker always replaces my shebang with something else :) For example on my Linux system it replaces existing shebang with

        #!/usr/bin/perl -w eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}' if 0; # not running under some shell
        On Win32 I noticed that ExtUtils::MakeMaker does another magic. It creates .bat file which wraps perl script and adds .pl extenstion to perl script when doing its installation. I found that at least on Unix, Unix-like systems and on Win32 systems ExtUtils::MakeMaker does the right thing.

        --
        Ilya Martynov, ilya@iponweb.net
        CTO IPonWEB (UK) Ltd
        Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net
        Personal website - http://martynov.org

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://222474]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 23:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found