Manish Kumar
Manish Kumar

Reputation: 589

Running perl script by making it executable

I am learning perl and trying to execute this script :

 #!/bin/perl

$name ="Manish";
print $name;

I saved this program with test.pl name and change its mode to make it executable :

chmod u+x test.pl

When i did which perl i got /bin/perl where perl has been installed .

Problem :- When i am running script like

perl test.pl

its fine ..

but when i am running it as ./test.pl its showing

./test.pl[6]: =Manish:  not found

may be its interpreting that as a shell script.

Please help me on this.

Upvotes: 2

Views: 126

Answers (1)

chaos
chaos

Reputation: 9262

Remove the space character in front of the #! line.

#!/bin/perl

Not:

 #!/bin/perl

Upvotes: 8

Related Questions