Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Perl Script only runs with -w switch

by NailBombJoe (Novice)
on Nov 21, 2002 at 18:56 UTC ( #214870=perlquestion: print w/replies, xml ) Need Help??

NailBombJoe has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Perl Script only runs with -w switch
by dws (Chancellor) on Nov 21, 2002 at 19:34 UTC
    I'm going nutz trying to figure out what the problem is.

    And we'll go nuts trying to read your mind. Give us more info. Try working up a small example that demonstrates the problem, and post the code. To get small, take a script that's failing, and remove as much as you can.

    Here's a wild guess: You FTP'd the scripts from your FreeBSD system to a Win32 box, then FTP'd them to the RedHat server. Along the way, the scripts picked up Win32 line endings (\r\n), which you neglected to removed as you moved the files to RedHat (i.e., by transfering in binary mode). This would leave you with shebang lines that either look like:   #!/usr/bin/perl -w\r which works, or   #!/usr/bin/perl\r which doesn't, because the OS is unable to locate an executable named "/usr/bin/perl\r".

      You guessed right about how I transfered the script, although I used SSH. I don't see a \r or \n on the first line when I view the script with vi which I am guessing means I wouldn't be able to see them after the file goes through this transfer process. What would be the best way to fix this problem? Joseph Wagner Network Manager
        I don't see a \r or \n on the first line when I view the script with vi

        What about a ^M ?

        -Nitrox

Re: Perl Script only runs with -w switch
by BrowserUk (Patriarch) on Nov 21, 2002 at 18:59 UTC

    It could be that . on line 63!


    Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
    Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
    Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
    Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

      I'm of the opinion that it's the following line
      ## mess with anyone who ports this script die("mwahahaha!") if $^O eq 'linux' and !$^W;

      _________
      broquaint

      Look again. The problem clearly lies on that one line where it does that stuff... you know... with the underscore and the dollar sign? Yea, right in that general area.

      *edit*
      1. If it only runs with the -w switch, isn't that better?! I think that's how all perl code should be. I'd even go so far as to say Acme::Code::Police should be a required module.
      2. You might want to post the code or at least post a link to it or something. If the script is really really long, you might consider using nopaste.

Re: Perl Script only runs with -w switch
by BrowserUk (Patriarch) on Nov 21, 2002 at 21:11 UTC

    An indication of in what way it doesn't work would have been a good idea.

    You might also have made some attempt to isolate where the code was failing and posted that rather than 100k of script.


    Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
    Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
    Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
    Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2023-12-09 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (38 votes). Check out past polls.

    Notices?