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

Hello all, Im new to perl and perl monks. Im reading perl in 24 hours by Clinton Pierce. My question is: My first program, #!usr/bin/perl print "Hello, World!\n"; When I bring up my ms dos and type in "perl hello" I get this message, Can't open perl script "Hello": Permission denied. Can somone please tell how I get permission. thanks
  • Comment on Can't open perl script: Permission denied

Replies are listed 'Best First'.
Re: Can't open perl script: Permission denied
by davidrw (Prior) on Jan 21, 2007 at 18:26 UTC
    welcome to PM and perl!

    You'll find that the Tutorials section here has a lot of good starting points, including this one that walks through making a print "Hello, World!\n" script: Perl Babysteps 1: Your First Simple Script

    Your problem most likely is that the file isn't named 'hello' or doesn't have the proper permissions .. this tutorial has pointers for that type of issue: The basics

    Also be sure to have a look at Writeup Formatting Tips in order to get the most out of your questions here (the easier/more standard they are formatted, they better/faster people will answer)
Re: Can't open perl script: Permission denied
by blazar (Canon) on Jan 21, 2007 at 18:56 UTC
    Hello all, Im new to perl and perl monks. Im reading perl in 24 hours by Clinton Pierce.

    Most books who promise you to learn X in Y hours, days, weeks, any, generally lie and most often are just crap. Now, IIRC this particular one is a notable exception.

    My question is: My first program, #!usr/bin/perl print "Hello, World!\n"; When I bring up my ms dos and type in "perl hello" I get this message, Can't open perl script "Hello": Permission denied. Can somone please tell how I get permission. thanks

    (BTW: use <code> tags for writing code here, even if it's very short like in this case.)

    That's strange, there should be no permission issues under Windows. Aren't you using cygwin by any chance? Whatever, if you have installed Activeperl, the installation program should have set the .pl association for you which means you can call your program hello.pl and run it like thus:

    C:\temp>hello.pl Hello, World

    Additionally, you can add .pl to the PATHEXT environment variable, which comes handy if you write some utility and put it somewhere in your PATH, so that you can call it utility.pl but you will run it without specifying the extension:

    utility argument1 argument2...

    Now, coming to your problem, how is you program actually called? Just hello? Isn't it by any chance hello.pl?

Re: Can't open perl script: Permission denied
by ysth (Canon) on Jan 21, 2007 at 19:09 UTC
    I don't know what your problem is, but apparently no one else does either. Your file is actually named Hello, or you'd be getting "No such file or directory", not "Permission denied". And links telling you to chmod +x the file are not going to be helpful on Windows. What does "type Hello" do? Is it possible Hello is a directory (aka folder) name?
Re: Can't open perl script: Permission denied
by CountZero (Bishop) on Jan 21, 2007 at 18:30 UTC
    Hello Chris21 and welcome to our Monastery!

    What version of Perl are you using and how was it installed?

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Can't open perl script: Permission denied
by SheridanCat (Pilgrim) on Jan 21, 2007 at 21:05 UTC
    When you type
    perl -v
    at the command prompt What do you see? You should see version information. Also, if you look at a directory listing, do you see your "hello" script file present? What happens if you type this at the command prompt:
    perl -e "print \"Hello World\n\""
    Just copy that and paste it in at the c:\> prompt
      Thanks to all for the help and support. Iv figured it out!! Im sure this site will get me through any dark times I have ahead with perl.
        Hi Chris21,

        I'm glad you've managed to sort out what was causing you difficulties. It certainly puzzled the Monks who tried to help you. Perhaps you could share with us what the problem actually was so that, if another monk comes along with similar symptoms, there is a better chance of providing a timely solution to their woes.

        Keep paying frequent visits to the Monastery in the future. It is a fantastic resource for all things Perl and will expose you to a wide range of other peoples problems to learn from.

        Cheers,

        JohnGG

        what was your solution as im having the same problem?
Re: Can't open perl script: Permission denied
by Argel (Prior) on Jan 22, 2007 at 23:18 UTC
    For anyone new to Perl on UNIX/Linux/BSD (or people just new to one of those platforms) the #!usr/bin/perl line is missing a leading slash. It should be:
    #!/usr/bin/perl
    It's not relevant to the OP but I thought I would mention it lest it confuse someone else later on.