MOCKSTACKS
EN
Questions And Answers

More Tutorials









Perl Basics

Script names

While generally speaking you can name your script/program anything you want, there are a number of conventional extensions applied to portions of the Perl bestiary:
.pm - Perl modules
.pl - Perl libraries (and scripts on UNIX)
.plx - Perl scripts

Language properties


· Perl is an interpreted language – program code is interpreted at run time. Perl is unique among interpreted languages, though. Code is compiled by the interpreter before it is actually executed.
· Many Perl idioms read like English
· Free format language – whitespace between tokens is optional
· Comments are single-line, beginning with #
· Statements end with a semicolon (;)
· Only subroutines and functions need to be explicitly declared
· Blocks of statements are enclosed in curly braces {}
· A script has no “main()”

Invocation


On platforms such as UNIX, the first line of a Perl program should begin with
#!/usr/bin/perl

and the file should have executable permissions. Then typing the name of the script will cause it to be executed.
Unfortunately, Windows does not have a real equivalent of the UNIX “shebang” line. On
Windows 95/98, you will have to call the Perl interpreter with the script as an argument:
andgt; perl myscript.plx

On Windows NT, you can associate the .plx extension with the Perl interpreter:
>assoc .plx=Perl
> ftype Perl=c:\myperl\bin\perl.exe %1% %*
> set PATHEXT=%PATHEXT%;.plx

After taking these steps, you can execute your script from the command line as follows:
> myscript

The ActivePerl distribution includes a pl2bat utility for converting Perl scripts into batch files.
You can also run the interpreter by itself from the command line. This is often useful to
execute short snippets of code:
perl –e ‘code

Alternatively, you can run the interpreter in “debugging” mode to obtain a shell-like environment for testing code scraps:
perl –de 1


Conclusion

In this page (written and validated by ) you learned about Perl Basics . What's Next? If you are interested in completing Perl tutorial, your next topic will be learning about: Perl scalars lists and hashes.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.