From: Tad McClellan on 29 Dec 2009 21:29 Wanna-Be Sys Admin <sysadmin(a)example.com> wrote: > Peng Yu wrote: > >> Since my perl is installed in a nonstandard location, I have to use '/ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> usr/bin/env perl'. I also what to use it with '-w'. I'm wondering how >> to do it. >> >> Currently, I have the following error. >> >> $ head -n 1 ./main.pl >> #!/usr/bin/env perl -w >> $ ./main.pl >> /usr/bin/env: perl -w: No such file or directory > > just use "use warnings;" which offers some advantages. Keep the env the > same. Problem solved. Please re-read the problem statement... -- Tad McClellan email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
From: Ben Morrow on 29 Dec 2009 23:30 Quoth Tad McClellan <tadmc(a)seesig.invalid>: > Wanna-Be Sys Admin <sysadmin(a)example.com> wrote: > > Peng Yu wrote: > > > >> Since my perl is installed in a nonstandard location, I have to use '/ > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > >> usr/bin/env perl'. I also what to use it with '-w'. I'm wondering how > >> to do it. > >> > >> Currently, I have the following error. > >> > >> $ head -n 1 ./main.pl > >> #!/usr/bin/env perl -w > >> $ ./main.pl > >> /usr/bin/env: perl -w: No such file or directory > > > > just use "use warnings;" which offers some advantages. Keep the env the ^^^^^^^^^^^^^^^^ > > same. Problem solved. ^^^^^ ....that is, use #!/usr/bin/env perl use warnings; so that the kernel can pass 'perl' as a single argument to env(1) and it will work as expected. > Please re-read the problem statement... Please re-read the solution offered... :) (Not that I think this is a good solution. env(1) on the #! line is a security risk, since you don't know what's in the PATH; I've always found it a little disconcerting that python recommends #!/usr/bin/env python in the standard docs.) Ben
From: Dr.Ruud on 30 Dec 2009 06:13 RedGrittyBrick wrote: > Ilya Zakharevich wrote: >> `use warning' is useful in a module. It is mostly useless in >> a script. One should always use -w in scripts. > > Can anyone provide a reference to where Ilya (or anyone else) provides > an explanation of this assertion? > > It doesn't seem to be in accord with `perldoc perllexwarn`. Am I right > to assume there is some disagreement on this point? I prefer -w in scripts too, because it enforces warnings on the included code. The 'use warnings' is only lexical, that's all there is to it. -- Ruud
From: John W. Krahn on 30 Dec 2009 10:29 Dr.Ruud wrote: > RedGrittyBrick wrote: >> Ilya Zakharevich wrote: > >>> `use warning' is useful in a module. It is mostly useless in >>> a script. One should always use -w in scripts. >> >> Can anyone provide a reference to where Ilya (or anyone else) provides >> an explanation of this assertion? >> >> It doesn't seem to be in accord with `perldoc perllexwarn`. Am I right >> to assume there is some disagreement on this point? > > I prefer -w in scripts too, because it enforces warnings on the included > code. Then you probably want to use -W instead of -w. John -- The programmer is fighting against the two most destructive forces in the universe: entropy and human stupidity. -- Damian Conway
From: Peter J. Holzer on 30 Dec 2009 10:57 On 2009-12-30 11:13, Dr.Ruud <rvtol+usenet(a)xs4all.nl> wrote: > RedGrittyBrick wrote: >> Ilya Zakharevich wrote: >>> `use warning' is useful in a module. It is mostly useless in >>> a script. One should always use -w in scripts. >> >> Can anyone provide a reference to where Ilya (or anyone else) provides >> an explanation of this assertion? >> >> It doesn't seem to be in accord with `perldoc perllexwarn`. Am I right >> to assume there is some disagreement on this point? > > I prefer -w in scripts too, because it enforces warnings on the included > code. Which is why I disagree with Ilya and you. -w is mostly useless in a script and should never be used except maybe as a quick hack during debugging. > The 'use warnings' is only lexical, that's all there is to it. And I think this is a good thing. Getting lots of warnings in code I haven't written and cannot change[1][2] is not very helpful. And most modules use "use warnings" anyway, so it's usually redundant (and you probably should be wary of those that don't use it). I do think it was a good thing that -w was invented before "use warnings": It forced module maintainers to clean up their code. hp [1] Well, *I* can change it because I'm sysadmin on most of the systems where my code runs. But that's far from universal. [2] I remember the bad old days of C programming where you could choose between getting lots of warnings from system header files and turning off many useful warnings.
|
Next
|
Last
Pages: 1 2 Prev: FAQ 8.38 How do I timeout a slow event? Next: Errors during PersistentPerl Compilation |