Jeny
Jeny

Reputation: 19

How to run perl program using cmd

i installed active perl in d: and i save my pl file in desktop. how can i run perl file. whenever i run the perl program , the error is Can't open perl script "hello.pl": No such file or directory.. please help me

Upvotes: 0

Views: 15819

Answers (3)

Thomas K
Thomas K

Reputation: 40340

Your command prompt probably doesn't start pointing at your desktop. Look at the path it gives you ("C:\Users\yourusername>", maybe?). You can either use cd at the terminal to change to the Desktop directory, or move the script to the path where the command prompt starts.

Use dir (Windows) or ls (Linux/Mac) to see what files are in the current directory at the prompt.

Upvotes: 2

RedGrittyBrick
RedGrittyBrick

Reputation: 4002

What is the first line of your perl script? Try setting it to #!perl

Usually the association of .pl to perl.exe is taken care of for you when you install Activestate Perl or Strawberry Perl.

If this is not the case, you need to associate the .pl extension with the perl.exe program. To do this you can use Windows Explorer (Tools menu, Folder Options, File Types) or you can open a command prompt window and used the assoc and ftype commands - you'll need to find the full path to perl.exe.

If you add the path of perl.exe to %PATH then you can just type perl myscript.pl foo bar

Upvotes: 0

Related Questions