Home  |  Linux  | Mysql  | PHP  | XML
From:Paul Johnson Date:Tue Mar  9 20:35:37 2010
Subject:Re: Can anybody explain me what this shebang line is doing?
On Mon, Mar 08, 2010 at 04:32:35PM +0100, Eric Veith1 wrote:
> YAPH <yet.another.perl.hacker@gmail.com> wrote on 03/05/2010 06:57:19 PM:
> > It was the shell construc, eval '....' if 0; (Will this ever
> > execute?)
> >
> > and the
> >
> > exec /bin/perl $0 ${1+"$@"};
> >
> > that threw me off.
>
> YAPH:
>
> Actually, the first constructs gets read and interpreted by both shell and
> perl. However, Perl doesn't execute it because of the "if 0" part, which
> the shell, in turn, never reads because of the "exec" within the eval'd
> string. It's actually pretty smart, but unnecessary since there easier
> ways.

I don't imagine there are many easier ways which actually work, since
those environment variables need to be set before perl starts.

So if you want to keep it all in one Perl file you'll need to check the
variables and if they are not as you want them you'll need to set them
and exec yourself. That's probably not easier.

Or you'll need to have two files, one shell and the other perl and call
the perl from the shell. I'm not sure I'd call that easier.

Or you'll need to ensure your environment is set up as it should be in
some other way. That's probably not easier either.

But I suppose it all hinges on what one considers easier ...

--
Paul Johnson - paul@pjcj.net
http://www.pjcj.net
Navigate in group perl.beginners at sever nntp.perl.org
Previous Next


Your recent visits
use with variable
Re: use with variable
Re: 1-line text file with numbers, need to add to them
Re: 1-line text file with numbers, need to add to them
Re: 1-line datafile, need data for another routine



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants