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

Hello Perl community, This is my first post in your site.I am an amateur programmer in Perl language so i need your help with an issue that i am facing.I am writing a code in a txt file and i am saving it as a pl file.After that i try to run this program via cmd with the following code:perl filename.pl and i receive this message: Can't open perl script "bonjour.pl" no such file or directory. I checked both the existence of the file and the location of the file to match the directory. Please help!!!
  • Comment on Can't open perl script...no such file or directory

Replies are listed 'Best First'.
Re: Can't open perl script...no such file or directory
by robby_dobby (Hermit) on Jun 10, 2015 at 11:43 UTC
    Hello Thanasis1988,

    If you're doing this in notepad on Windows, you should know that all files (even if you give extensions, in this case a .pl) will save as bonjour.pl.txt. To confirm, open up your command prompt cmd and type dir. You should find the cause of your problem.

    As an aside, I suggest that you first get set up with a better development environment - get yourself a better text editor, say Notepad++ or Sublime Text. You'll thank yourself later in saving much of your productivity for better tasks :-)

    Have fun!

    EDIT:

    Borked links :-( Thanks Corion!

      Hi again, First of all i'd like to thank you for your quick response.I have the same problem when i am coding in Notepad and in Padre.So maybe there is another reason why i am having this problem.

        Please copy and paste the exact input you give and the exact error message you get. This helps us diagnose the problem much better than your description of what you think you see.

Re: Can't open perl script...no such file or directory
by Anonymous Monk on Jun 11, 2015 at 19:53 UTC
    Just an FYI, in general, if you'd like your files to be named explicitly, surround them in double quotes. On Windows, in Notepad (for example), saving a file by just providing a name, my_script, will save the file with an *actual* name of 'my_script.txt'. To have it named 'my_script.pl', tell the save dialog the full name and surround it in quotes: "my_script.pl". The application will then _not_ add its default extension.
Re: Can't open perl script...no such file or directory
by sandy105 (Scribe) on Jun 10, 2015 at 14:22 UTC

    good , that you figured out your problem .Just wanted to point out your script files will run fine with .txt or whatever .Its just convention to mark them as .pl or .perl and it is recommended to do so