Any programming language tutorial has to start with showing the “Hello, world” program. So, here it is in Perl:
#!/usr/bin/perl print "Hello, world!\n";
Normally Perl treats a line starting with # as a comment and ignores it. However, the # and ! characters together at the start of the first line tell it how the file should be run. In this case the file should be passed to the perl interpreter, which lives in /usr/bin/perl.
The print function tells perl to display the given text without the quotation marks. The text inside the quotes is not interpreted as code and is called a string. Here "\n" simply means a newline.
Now, click on Run in the IDE and it will open a prompt window showing the result of the above code:
So, this was our first Perl code.← Previous Next →
© 2018 BreakInerview