in reply to Perl wrapper

And now without the extra file.

wrapper:

#!/bin/sh perl "$@"

script:

#!/bin/sh #!perl -w eval 'exec wrapper -x -S $0 ${1+"$@"}' if 0; 4; print("Hello, World\n");
$ script Useless use of a constant (4) in void context at script line 5. Hello, World

See perlrun.

Replies are listed 'Best First'.
Re^2: Perl wrapper
by weigand (Initiate) on Mar 16, 2011 at 17:29 UTC

    Thanks for the reply. That definitely solves the problem.

    I just wish there was an easier way. I basically have to tell everyone at my company that they need to cut and paste this little piece of code at the top of their perl scripts. The "/bin/sh" at the top may be a bit confusing to them also.

    Still, it's better than the alternative: Having to write a shell script every time you want to run a perl script (two files instead of one).

    I wish /bin/env would just allow me to pass command line arguments to perl. Why can't it? And is there something like /bin/env that would?

      just wish there was an easier way.

      We're constrained by your requirement to call the wrapper.

      I basically have to tell everyone at my company that they need to cut and paste this little piece of code at the top of their perl scripts.

      Still, it's better than the alternative: Having to write a shell script every time you want to run a perl script (two files instead of one).

      Neither are true. Both can be handled automatically during install.

      I wish /bin/env would just allow me to pass command line arguments to perl. Why can't it?

      Oh it does

      $ /usr/bin/env perl -v This is perl 5, vers...

      The issue (Upd: with the shebang ) is that the OS passes everything after the first whitespace as one argument (Upd: to the command being launched ).

        Linux doesn't let you do that with "#! /usr/bin/env perl -v". It tries to find a file called "perl -v". Other OS's don't do that. I use linux primarily, so I can't do that.

        And the rest of your response was too cryptic and brief to be of much use I'm afraid. But thanks for the reply anyway.