0

I am new to Unix. I am trying to Run a Perl script on Fedora 14 machine.

I wrote the script and saved it in a file called PerlOne.pl and changed its permission to 755. This is what it has

#!/usr/bin/perl
print "hello";

I tried to run it so I got

/usr/bin/perl : bad interpreter no such file or directory.

So I checked if I already have perl by typing

perl -v

I got

perl: command not found 

Is it possible that Fedora comes with no perl? or am I doing something wrong? if yes, then how can I install perl?

Any help would be appreciated =)

migrated from stackoverflow.com Oct 18 '12 at 15:56

This question came from our site for professional and enthusiast programmers.

  • What's the results of: which perl? – Steve Oct 18 '12 at 14:15
  • I wonder what will yum --showduplicates list perl show. – raina77ow Oct 18 '12 at 14:23
5

Run: yum list all | grep perl

If it doesn't show perl then you haven't got it installed.

So, install it using: yum install perl. You may need to run it as root.

  • 1
    It didn't show perl. How to run it as root ? – RonaDona Oct 18 '12 at 14:29
  • If you are part sudoer list then: sudo yum install perl will work. Otherwise, sudo su - give root password then run yum install perl. – P.P. Oct 18 '12 at 14:31
  • 1
    It's better practice to only use sudo, so I'd use the first option. – reinierpost Oct 18 '12 at 14:32
  • great! how to get out of root ? – RonaDona Oct 18 '12 at 14:34
  • By the way, for making a user a sudoer on Fedora, see unix.stackexchange.com/questions/4405/… – mattdm Nov 17 '12 at 15:26
2

Try searching Perl with :

find / -path '*bin/perl'

And copy-paste here the output of echo $PATH, I suspect it to be wrong.

EDIT seems like some Fedora distros don't put perl by default, see http://forums.fedoraforum.org/showthread.php?t=254537

  • It's not in /usr/bin, there should be at least a symlink in there. So it's more likely to not be installed rather than the PATH being wrong. – Benj Oct 18 '12 at 14:21
  • See my edited post – Gilles Quenot Oct 18 '12 at 14:22
  • /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/fedora/.local/bin:/home/fedora/bin – RonaDona Oct 18 '12 at 14:25
  • yep. Installed it and it works now – RonaDona Oct 18 '12 at 14:40
2

You can determine whether Perl is installed on your system by using the package manager that your system uses to install and keep track of software. In RedHat distros, the package manager is RPM.

So... To list all installed packages that have perl in their name, try:

rpm -ql | grep -i perl

(I'm suggesting using grep because IIRC rpm's internal queries are case sensitive.) If you see no results, then Perl probably isn't installed.

To install it, you'll probably use YUM:

  • Yes you're right. It wasn't installed. Thanks mate – RonaDona Oct 18 '12 at 14:40
2

Try:

find / -type f -name '*perl*' 2>/dev/null

This is a wider search scope than that proposed by Gilles Quenot, but it will only return files (not directories) and also remove any "Permission denied" errors from the output so it is clearer.

Look for the result found under a '/bin/...' or '/sbin/...' directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy