PDA

View Full Version : Making a Perl script an executable, I think.


Mojojojo77
5th December 2004, 06:51 PM
O.K., I just started learning Perl and am trying to do a "Hello , world" program. I'm using Perl, v5.8.6 on Fedora Core 2. The code I am doing is this...

!#/usr/local/bin/perl

print "Hello , world!\n";

chmod a+x helloword

And I am getting the "permission denied" message in the shell when I try to run it. So I am guessing it is the chmod line that is wrong. I've tried changing it around, but I either get the same message or the "no such file" message when I really screwed around with it. So do I have a syntax error here, or is something going wrong elsewere? Because I really do not know what else I can try.

ilja
5th December 2004, 06:56 PM
ok, this works :

perl helloworld


and this script works also:

#!/usr/bin/perl

print "Hello , world!\n";

foolish
5th December 2004, 07:00 PM
the perl executable is located in /usr/bin/perl
so it should say:

#!/usr/bin/perl
print "Hello , world!\n";


Just tested it here and it works. Good luck with your perl programming, judging by my experience, you'll need it.

Mojojojo77
5th December 2004, 07:09 PM
I thought that might be it to, but when I ask in the shell "which perl" it tells me /usr/local/bin/perl so wouldn't I get a no such file directory if I did it the other way?

ilja
5th December 2004, 07:18 PM
whereis perl
?

Mojojojo77
5th December 2004, 07:21 PM
[/B]/ usr / local / bin / perl

ilja
5th December 2004, 07:27 PM
strange

what does

ls /usr/bin/ |grep perl
return?

Mojojojo77
5th December 2004, 07:43 PM
find2perl
foomatic-perl-data
perl
perl5.8.3
perlbug
perlcc
perldoc
perlivp

ilja
5th December 2004, 07:56 PM
ok, it is there. So it is real strange.

crackers
5th December 2004, 08:00 PM
Do a ls -l on /usr/local/bin and let's see what's there...

Did you by chance install a non-RPM version of Perl?

Mojojojo77
5th December 2004, 08:07 PM
Yes, I made it with the newest stable.tar.gz from the CPAN site.

Mojojojo77
5th December 2004, 08:10 PM
O.k. here's what it says for that.

a2p dprofpp h2ph libnetcfg perlbug perlivp pod2html pod2text podselect pstruct xsubpp
c2ph enc2xs h2xs perl perlcc piconv pod2latex pod2usage prove s2p
cpan find2perl instmodsh perl5.8.6 perldoc pl2pm pod2man podchecker psed splain

crackers
5th December 2004, 10:38 PM
You need to uninstall the RPM(s) of the Perl packages that get installed, if you haven't already.

Secondly, I looked harder at your original post and you either have a typo in the post or your Perl script - the first line should look like this:

#!/usr/local/bin/perl

You had the "bang" (!) on the wrong side of the comment delimiter.

Tyoply Stan Travel Photos - Medina del Campo - Dailekh Instagram Photos