Top 1,000 Features Creators Resources Extensions Blog Explorer Download
GitHub icon

Perl

< >

Perl is an open source programming language created in 1987 by Larry Wall.

#8on PLDB 37Years Old 170kRepos

Try now: Riju Β· TIO

Perl is a family of high-level, general-purpose, interpreted, dynamic programming languages. The languages in this family include Perl 5 and Perl 6. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language". Read more on Wikipedia...


Example from Riju:
print("Hello, world!\n");
Example from hello-world:
#!/usr/bin/perl print "Hello World\n";
# Hello world in perl print "Hello World!\n";
Example from Linguist:
#!/usr/local/bin/perl print "Perl\n"
Example from Wikipedia:
#!/usr/bin/perl use strict; use warnings; use IO::Handle; my ( $remaining, $total ); $remaining = $total = shift(@ARGV); STDOUT->autoflush(1); while ( $remaining ) { printf ( "Remaining %s/%s \r", $remaining--, $total ); sleep 1; } print "\n";
__DATA__ else lock qw __END__ elsif lt qx __FILE__ eq m s __LINE__ exp ne sub __PACKAGE__ for no tr and foreach or unless cmp ge package until continue gt q while CORE if qq xor do le qr y

Language features

Feature Supported Token Example
Scientific Notation βœ“
Binary Literals βœ“
# 0b[01]+(_[01]+)*
Integers βœ“
# \d+(_\d+)*
Floats βœ“
# (?i)(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?
Hexadecimals βœ“
# 0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*
Octals βœ“
# 0_?[0-7]+(_[0-7]+)*
Conditionals βœ“
While Loops βœ“
Print() Debugging βœ“ print
Range Operator βœ“
# https://users.cs.cf.ac.uk/Dave.Marshall/PERL/node38.html
@array = (1..10);
Operator Overloading βœ“
Multiple Inheritance βœ“
File Imports βœ“
use Digest::MD5 'md5_hex';
Directives βœ“
# In Perl, the keyword "use", which imports modules, can also be used to specify directives, such as use strict; or use utf8;
use utf8;
Here Document βœ“
Line Comments βœ“ #
# A comment
MultiLine Comments βœ“ =begin =cut
=begin comment
This is all part of multiline comment.
You can use as many lines as you like
These comments will be ignored by the
compiler until the next =cut is encountered.
=cut
Comments βœ“
# A comment
Partial Application βœ“
sub first-and-last ( $first, $last ) {
   say "Name is $first $last";
}
my &surname-smith = &first-and-last.assuming( *, 'Smith' );
&surname-smith.( 'Joe' ); # OUTPUT: «Name is Joe Smith␀»
Regular Expression Syntax Sugar βœ“
print "Hello World".match(/\w/)
Strings βœ“
"hello world"
Case Insensitive Identifiers X
Semantic Indentation X

View source

- Build the next great programming language Β· About Β· Acknowledgements Β· Published by Breck's Lab