Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Perl
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Features === The overall structure of Perl derives broadly from C. Perl is [[procedural programming|procedural]] in nature, with [[variable (programming)|variable]]s, [[expression (programming)|expressions]], [[assignment statement]]s, [[bracket|brace]]-delimited [[block (programming)|block]]s, [[control structure]]s, and [[subroutine]]s.<ref>{{Cite book|last=Nagpal|first=D.P.|title=Web Design Technology|publisher=S. Chand|year=2010|isbn=978-8121927635|location=India|pages=700|language=English}}</ref> Perl also takes features from shell programming. All variables are marked with leading [[sigil (computer programming)|sigils]], which allow variables to be [[Variable interpolation|interpolated]] directly into [[String (computer science)|strings]]. However, unlike the shell, Perl uses sigils on all accesses to variables, and unlike most other programming languages that use sigils, the sigil doesn't denote the type of the variable but the type of the expression. So for example, while an array is denoted by the sigil "@" (for example <code>@arrayname</code>), an individual member of the array is denoted by the scalar sigil "$" (for example <code>$arrayname[3]</code>). Perl also has many built-in functions that provide tools often used in shell programming (although many of these tools are implemented by programs external to the shell) such as [[Ascending order|sorting]], and calling [[operating system]] facilities.{{Citation needed|date=December 2020}} Perl takes [[associative array|hashes]] ("associative arrays") from [[AWK]] and [[regular expression]]s from [[sed]]. These simplify many parsing, text-handling, and data-management tasks. Shared with [[Lisp (programming language)|Lisp]] is the implicit [[Return statement|return]] of the last value in a block, and all statements are also expressions which can be used in larger expressions themselves.{{Citation needed|date=December 2020}} Perl 5 added features that support complex [[data structure]]s, [[first-class function]]s (that is, [[Closure (computer science)|closures]] as values), and an object-oriented programming model. These include [[reference (computer science)|references]], packages, class-based [[Dynamic dispatch|method dispatch]], and [[Scope (programming)|lexically scoped variables]], along with [[compiler directive]]s (for example, the <code>strict</code> [[Directive (programming)|pragma]]). A major additional feature introduced with Perl 5 was the ability to package code as reusable modules. Wall later stated that "The whole intent of Perl 5's module system was to encourage the growth of Perl culture rather than the Perl core."<ref>{{cite newsgroup |title=title unknown |date=1997-05-10 |message-id=199705101952.MAA00756@wall.org}}{{Dead link|date=November 2014}}</ref> All versions of Perl do automatic [[Type system|data-typing]] and automatic [[memory management]]. The interpreter knows the type and [[Computer data storage|storage]] requirements of every data object in the program; it allocates and frees storage for them as necessary using [[reference counting]] (so it cannot deallocate [[circular dependency|circular data structures]] without manual intervention). Legal [[type conversion]]s β for example, conversions from number to string β are done automatically at [[Run time (program lifecycle phase)|run time]]; illegal type conversions are fatal errors.{{Citation needed|date=December 2020}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)