T.S. Ravi Shankar wrote: > Hi all : > > I see these lines at the very beginning lines of a perl program. > Could anyone explain what this is doing ?? > > eval '(exit $?0)' && eval 'exec perl $PERL_OPTIONS $0 ${1+"$@"}' > & eval 'exec perl $PERL_OPTIONS $0 $argv:q' > if 0; > > In what way "eval" help here in traping the errors ?? Where does > $PERL_OPTIONS get value ??
It's a bit of trickery used to allow scripts to work correctly on ancient (?) systems that don't support the #! line, but instead pass the perl script to the Unix shell. If sh sees the first line there, it will bascially feed the script to Perl. If Perl sees that bit, the "if 0" qualifier at the end causes it to ingore all the exec stuff, and the rest of the script executes. The evals are shell evals, not Perl evals (although the line is legal syntax for perl, so the script will pass the compile phase). I'm not exactly sure what the first eval is doing. The last two evals are for Bourne shell and C shell, I think. $PERL_OPTIONS would be evaluated by the shell, so it would refer to an environment variable (documented in perldoc perlrun). I don't know how relevant that stuff is in this day and age. Maybe one of the gurus can weigh in... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]