Ooops.  Seems that I posted my question (how to break a script by
turning off warnings) just before my life got rather busy.  Sorry about
that.  Anyway ...

Keith C. Ivey writes:

> Bart Lateur <[EMAIL PROTECTED]> wrote:
> 
> > Not fun but...
> > 
> > Use
> > 
> >  local $^W;
> > 
> > near where the bulk of the warnings are coming from ...

Yes, I know that.  But that would involve looking at the
warning-producing script enough to determine where the warnings are
coming from; I was in the middle of debugging my own script, and didn't
want to get distracted and start trying to discover the source of
warnings in somebody else's script that I hadn't seen before.

> Or just initialize the variables and avoid the warnings.

That'd involve even more effort!

So what I did was simply remove the -w from the #! line, so that that
script's many warnings wouldn't be cluttering up the error log and
masking the more-interesting warnings from my own script.  Unfortunately
it turns out the -w was doing more than usual.

Somebody had edited that file on Windows then saved it on the FreeBSD
server; the top line of the script was actually:

  #! /usr/bin/perl -w^M

where ^M indicates a carriage return character.  Removing the -w, and
the space before the -w, therefore made it:

  #! /usr/bin/perl^M

except that I was editing this with 'Vim', which was clever enough to
notice that this was a Dos-format file and so didn't display the ^M.

And that breaks things, cos perl^M isn't something that BSD can execute.

So turning on the warnings was also protecting the command name from the
carriage return at the end of the line (Perl doesn't seem to mind it
though).

And it transpires that fiddling with somebody else's live script isn't a
good idea, even when it's a really small change and you're really sure
that it couldn't possibly break anything; who'd've thought?

Smylers

Reply via email to