Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Perl
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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!
=== Syntax === Perl has been referred to as "[[wikt:line noise|line noise]]" and a "write-only language" by its critics. [[Randal L. Schwartz]] in the first edition of the book ''[[Learning Perl]]'',<ref>{{cite journal |title=Developer Update|volume=2 |journal=Dr. Dobb's Developer Update |publisher=Miller-Freeman |year=1995 |page=15}}</ref> in the first chapter states: {{qi|Yes, sometimes Perl looks like line noise to the uninitiated, but to the seasoned Perl programmer, it looks like [[checksum]]med line noise with a mission in life.<ref name="LP">{{cite book |title=Learning Perl |last=Schwartz |first=Randal L. |author-link=Randal L. Schwartz |publisher=O'Reilly & Associates |year=1993 |title-link=Learning Perl |bibcode=1993lepe.book.....S}}</ref>|i=yes}} He also stated that the accusation that Perl is a [[write-only language]] could be avoided by coding with "proper care".<ref name="LP"/> The Perl overview document ''{{Not a typo|perlintro}}'' states that the names of built-in "magic" scalar [[Variable (computer science)|variables]] "look like punctuation or line noise".<ref>{{cite web |url=http://perldoc.perl.org/perlintro.html |title=perlintro |work=Perl 5 version 18.0 documentation |publisher=Perl 5 Porters and perldoc.perl.org |access-date=2013-06-30 |archive-url=https://web.archive.org/web/20110109121845/http://perldoc.perl.org/perlintro.html |archive-date=January 9, 2011 |url-status=dead}}</ref> However, the English module provides both long and short English alternatives. ''{{Not a typo|perlstyle}}'' document states that line noise in [[regular expression]]s could be mitigated using the <code>/x</code> modifier to add whitespace.<ref>{{cite web |url=http://perldoc.perl.org/perlstyle.html |title=perlstyle |work=Perl 5 version 18.0 documentation |publisher=Perl 5 Porters and perldoc.perl.org |access-date=2013-06-30 |archive-url=https://web.archive.org/web/20130626010707/http://perldoc.perl.org/perlstyle.html |archive-date=June 26, 2013 |url-status=dead}}</ref> According to the ''Perl 6 FAQ'',<ref name="P6FAQ">{{cite web |url=http://www.perl6.org/archive/faq.html |title=Perl 6 FAQ |publisher=Perl 6 Project |access-date=2013-06-30 |archive-date=July 1, 2013 |archive-url=https://web.archive.org/web/20130701183900/http://www.perl6.org/archive/faq.html |url-status=dead}}</ref> Perl 6 was designed to mitigate "the usual suspects" that elicit the "line noise" claim from Perl 5 critics, including the removal of "the majority of the punctuation variables" and the sanitization of the regex syntax. The ''Perl 6 FAQ'' also states that what is sometimes referred to as Perl's line noise is "the actual syntax of the language" just as [[gerund]]s and [[Preposition and postposition|prepositions]] are a part of the [[English language]].<ref name="P6FAQ"/> In a December 2012 blog posting, despite claiming that "Rakudo Perl 6 has failed and will continue to fail unless it gets some adult supervision", [[chromatic (programmer)|chromatic]] stated that the design of Perl 6 has a "well-defined grammar", an {{qi|improved type system, a unified object system with an intelligent [[metamodel]], metaoperators, and a clearer system of context that provides for such niceties as pervasive laziness.<ref name="chromatic-blog">{{cite web |url=http://www.modernperlbooks.com/mt/2012/12/the-implementation-of-perl-5-versus-perl-6.html |title=The Implementation of Perl 5 versus Perl 6 |author1=chromatic |author1-link=chromatic (programmer) |date=2012-12-31 |access-date=2013-06-30 |archive-date=July 29, 2013 |archive-url=https://web.archive.org/web/20130729214209/http://www.modernperlbooks.com/mt/2012/12/the-implementation-of-perl-5-versus-perl-6.html |url-status=live}}</ref>|i=yes}} He also stated that {{qi|Perl 6 has a coherence and a consistency that Perl 5 lacks.<ref name="chromatic-blog"/>|i=yes}} In Perl, one could write the [["Hello, World!" program]] as: <syntaxhighlight lang="perl"> print "Hello, World!\n"; </syntaxhighlight> Here is a more complex Perl program, that counts down seconds from a given starting value: <syntaxhighlight lang="perl"> #!/usr/bin/env perl use strict; use warnings; my ( $remaining, $total ); $remaining=$total=shift(@ARGV); STDOUT->autoflush(1); while ( $remaining ) { printf ( "Remaining %s/%s \r", $remaining--, $total ); sleep 1; } print "\n"; </syntaxhighlight> The Perl interpreter can also be used for [[One-liner program|one-off scripts]] on the [[command line]]. The following example (as invoked from an sh-compatible shell, such as [[Bash (Unix shell)|Bash]]) translates the string "Bob" in all files ending with .txt in the current directory to "Robert": <syntaxhighlight lang="console"> $ perl -i.bak -lp -e 's/Bob/Robert/g' *.txt </syntaxhighlight>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Perl
(section)
Add topic