Measures Concepts
GitHub icon

Perl

Perl - Programming language

< >

Perl is a programming language created in 1987 by Larry Wall.

#10on 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
Comments
# This is a comment in perl
=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
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 · Search · Add Language · Features · Creators · Resources · About · Blog · Acknowledgements · Queries · Stats · Sponsor · Day 605 · feedback@pldb.io · Logout