#!/usr/bin/perl
print "Hello World\n";
Those are 2 lines for the Hello World application.
My question is: How can I know the first line should be #!/usr/bin/perl ?
Well, open the terminal, then run which perl
It will show you the location of the Perl interpreter.
To run the code, just type perl hello.pl in terminal.
Now, I want to make the file 'executable'. Go to the directory where I saved the file, then run:
chmod +x hello.pl
./hello.pl
+x is used to put executable attribute to the file.
What about ./hello.pl? Why do we need ./ ? Why don't just type hello.pl?
For the complete explanation, see this website http://www.linfo.org/dot_slash.html
When we execute the file, we need to put the absolute path. The easiest way to put the absolute path is by using ./
./ refers to the current directory.
No comments:
Post a Comment