Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: What is -w?

by Anonymous Monk
on Apr 28, 2016 at 07:18 UTC ( [id://1161736]=note: print w/replies, xml ) Need Help??


in reply to What is -w?

Read about it and all switches in perlrun

Replies are listed 'Best First'.
Re^2: What is -w?
by htmanning (Friar) on Apr 28, 2016 at 07:27 UTC
    Thanks. It enables warnings, which is what I suspected. The question is why a script wouldn't run without it if all it does is print warnings. I get all kinds of warnings in the logs with this script even though none of them seem to be serious or pan out. Most of them say I have a variable that is only used once, even though it is used in another required file. Thanks for the pointer. I'm still stumped as to why the script would return an error just because I wasn't printing warnings.

      Most likely you are trying to run the script on a Unixish machine but the file uses Windows-style \r\n line endings.

      If that is the case, the kernel will look at the file, see that it starts with #! and it will then read the line and try to execute the first word on that line as the interpreter. Likely, parsing for words only means "space or newline", so the kernel will see:

      /usr/bin/perl\r

      as the program to execute. There is no such program. Once you add -w to the command line, the kernel will see:

      /usr/bin/perl -w\r

      and use /usr/bin/perl as the program and -w\r as the first parameter to it. This starts Perl.

      In any case, it is good to run with the -w switch always as this allows Perl to tell you about problematic things in your code.

        Thanks for the great explanation. I am on Ubuntu and all my other scripts work just fine. No line ending issues. I'm wondering if I have some weird routine or something, but I can't find it. Most of the warnings end up being wrong and it's just creating a massive log file. Anyway,I guess I have no choice because it will not run without it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1161736]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-23 21:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found