Reputation: 1
I am super new to Perl and really struggling to even get started on my local computer. I have success using other computers but would like to start working on my own laptop. Using my Mac terminal, I am attempting to use the shebang line, and it is finding no such file or directory. Below is my script:
#!/usr/bin/perl
In return, I get:
#/usr/bin/perl
zsh: no such file or directory: #/usr/bin/perl
I know this is basic, but I would really appreciate the help.
Upvotes: 0
Views: 2620
Reputation: 132720
In your error message, you don't have the bang in your shebang: #/usr/bin/perl
.
Did you type in your program or cut and paste? Re-tying often corrects errors that we don't notice.
Upvotes: 0
Reputation: 4285
I don't really understand how you write "I want to use my shebang line".
Typicaly you would write a file with a text editor, and it would contain a shebang line. And the shebang would contain the # and the ! (bang). So for instance, create a file called hello.pl
with this contents:
#!/usr/bin/perl
print "Hello World!\n";
Then if you would make the file executable, and execute it, the shell will run it using the interpreter you specified in the shebang. So in your shell:
$ chmod +x hello.pl
$ ./hello.pl
Hello World!
$
Please note that you can also not have a shebang, and still execute the file like this:
$ perl hello.pl
Hello World!
$
Upvotes: 3