I have a simple Hello World perl script.
#!/usr/bin/perl print 'Hello world.';
It works fine if I run it via
perl <file_name>, but it fails I run it via
My understanding of the first line is that it invokes the perl shell (similar to #!/usr/bin/bash will invoke a bash shell). So what exeactly is the difference between the two commands?
I found this thread http://ubuntuforums.org/showthread.php?t=1133334 that states
sh <file_name> "In that case, you don't run Perl at all, but the shell, which will call the program 'print'." IF that's the case is the #! just being interpreted as a comment. If so, is it needed at all?
(I am aware that I can chmod +x the file and run it dirrectly, but I just want to know the difference between the two methods I was using)