Question:
Running Perl scripts under Linux. Can you help?
Joseph
2009-09-08 13:27:34 UTC
I'm running Mandriva Linux (2008) (on a VMWare virtual machine).
I'm having trouble running Perl scripts on this setup.
Before you jump and the answer and tell me to include the Perl shebang (#! /usr/bin/perl), please know that I've already included it and it isn't working. The only way I could find to run Perl scripts is to type:
perl script.pl
But I don't want this. I want to be able to invoke my script directly, like so:
script.pl
If I type:
script.pl
I get the following error:
bash: script.pl : No such command

Does the virtual machine have anything to do with this? How can I set up my Perl scripts so they can be invoked directly?
Three answers:
martinthurn
2009-09-10 06:17:17 UTC
Two things you need to fix.

1. In Linux, the current directory is NOT in the path by default. You need to add . to the path, or invoke the program as ./program.pl

2. You need to chmod a+x program.pl
jerry t
2009-09-09 12:01:39 UTC
Since you say you can run the script in /bin but not if you move it to another directory; it makes me think you do not have your path set properly.

A guess would be to include /bin early in your path, or wherever perl is located.

Here are some links about path if you need them

Good luck
anonymous
2016-10-05 07:12:06 UTC
As a beginner, i think of C is your maximum suitable decision. 4 reliable motives: (one million) The c programming language isn't merchandise-oriented. This a great deal simplifies issues for you. (2) C is a sturdy procedural language which will prepare you a great deal approximately ordinary prograqmming suggestions, consisting of shape, bypass administration, the passing of administration by calling a function ( or a potential), parameter-passing, source-code compiliation, and maximum OF ALL, syntax. (3) With C, you could write courses that don't count on lots of complicated frameworks. in case you have some pre-written application applications which you extremely want to apply on your software, you in elementary terms incorporate the right library making use of an incorporate assertion. development merchandise code is plenty extra straightforward in C than maximum different languages, (4) awareness of C leands itselt somewhat conveniently to the learn of Java interior the destiny. The suggestions you learn by beginning with C are necessary. in case you learn the ordinary suggestions in the back of issues like software shape, records varieties, progression, compiliation, development, and packaging from the start of your occupation..... you would be "way beforehand of the interest" in comparison to those that attempt to strengthen their understanding, yet have an inadequate draw close of those ordinary suggestions.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...