There is a good tradition that learning a new programming language starts with writing a simple program that
displays the text Hello, world!
.
In the programming language Perl, there are several ways how to solve this problem.
The most common way to write Hello, world!
program in Perl is to create
file hello.pl
with the content:
$ perl hello.pl
Hello, world!
(If you don't have a computer with Perl, you can run this code in the browser https://PerlBanjo.com/5a5b1759f0 ).
Another quite popular method to output Hello, world!
— is to use Perl one-liner. The solution is not to create a text file with program,
but to write the whole program in the command line:
$ perl -e 'print "Hello, world!";'
Hello, world!
(And here is the link for this one-liner to run it in the browser https://PerlBanjo.com/62a99008d7 ).
Creating the text file with the code or using simple Perl one-liner is the most common way to write Hello, world!
program.
And this is the way how it should be done.
But in addition to these two standard methods, there are a lot of other ways to display text Hello, world!
with Perl.
Several examples are below. All of these programs display the text Hello, world!
using extremely obfuscated methods.
In the world of programming language Perl there is the art to display a line of text with some interesting tricks (Wikipedia ).
Here are some similar programs.
Here is how to output Hello, world!
using some crypted string:
▶ Run
$_='loH,oe! lrdlwdo';$_.=$1,print$2while s/(..)(.)//;
The following two programs are created with the Perl library Acme::EyeDrops .
A program that displays the text Hello, world!
using only punctuation marks and code use re 'eval';
:
▶ Run
use re 'eval';
''=~('('.'?'.'{'.('`'|'%').('['^'-').('`'|'!').('`'|',').'"'
.'#'.'!'.'/'.('['^'.').('['^'(').('['^')').'/'.('`'|('"')).(
'`'|')').('`'|'.').'/'.('['^'+').('`'|'%').('['^')').(('`')|
',').('!'^'+').('!'^'+').('['^'+').('['^')').('`'|')').('`'|
'.').('['^'/').('{'^'[')."'".('`'^'(').('`'|'%').('`'|',').(
'`'|',').('`'|'/').','.('{'^'[').('['^',').('`'|'/').(('[')^
')').('`'|',').('`'|'$').'!'."'".';'.('!'^'+').'"'.'}'.')');
Surprisingly, this drawing with the image of the camel is also a working Perl program that displays Hello, world!
:
▶ Run
use re 'eval';
''=~('('.'?'
.'{'.( '`'|'%').("\["^
'-').('`'| '!').('`'|',').'"'
.'#'."\!". "\/".( '['^'.').('['^'(').(
'['^')').'/'.(('`')| '"').('`'|')').(('`')|
'.').'/'.('['^"\+").( '`'|'%').('['^')').('`'
|',').('!'^('+')).( '!'^'+').('['^'+').(('[')^
')').('`'|')') .('`'|'.').('['^'/').('{'^'['
)."'".('`'^'(' ).('`'|'%').('`'|',').('`'|',').
('`'|'/').','.( '{'^'[').('['^',').('`'|'/').("\["^
')').('`'|','). ('`'|'$').'!'."'".';'.('!'^'+').('"').
'}'.')');$:='.' ^'~';$~='@'|'(';$^=')'^'[';$/='`'|'.';$,
='('^('}');$\= '`'|'!';$:=')'^'}';$~='*'|'`';$^='+'^'_';
$/='&'|'@';$,= '['&'~';$\=','^'|';$:='.'^'~';$~='@'|"\(";
$^=')'^'[';$/='`'|'.';$,='('^'}';$\='`'|'!';$:=')'^'}';$~=
'*'|'`';$^='+'^'_';$/='&'|'@';$,='['&'~';$\=','^'|';$:='.'^
'~';$~='@'|'(';$^=')'^'[';$/='`'|'.';$,='('^'}';$\='`'|'!'
;$:=')'^'}';$~='*'|'`';$^='+'^'_';$/='&'|'@';$,='['&'~';$\=
','^'|';$:='.'^'~';$~='@'|'(';$^=')'^'[';$/='`'|'.';$,='('^
'}';$\='`'|'!';$:=')'^'}';$~='*'|'`';$^='+'^'_';$/='&'|'@'
;$,='['&'~';$\=','^'|';$:='.'^'~';$~='@'|'(';$^="\)"^ '['
;$/='`'|'.';$,='('^'}';$\='`'|'!';$:=')'^'}';$~='*' |((
'`'));$^='+'^'_';$/='&'|'@';$,='['&'~';$\ =','^'|' ;$:
='.'^'~';$~='@'|'(';$^=')'^'[';$/='`'| '.';$,= '('
^'}'; $\='`'|'!';$:=')'^'}';$~="\*"| '`';$^= '+'
^'_';$/='&'|'@';$,='['&'~';$\ =(',')^ '|'
;$:='.'^ '~';$~='@' |"\("; $^=')' ^+
'[';$/= '`'|'.'; $,='(' ^"\}"; $\
=('`')| "\!";$:= "\)"^ "\}"; (
($~))= '*'|'`'; ($^) ='+'
^"\_"; $/=('&')| '@'; ($,)
='['& "\~";$\= ','^ '|';
($:)= '.'^'~' ;$~= '@'|
'('; $^=')' ^'[' ;$/=
'`'| '.' ;$,= '('^
'}'; $\= '`' |((
'!' )); $:= ')'
^(( '}' )); $~=
'*' |(( '`' ))
;( ($^))= ((
(( '+')) ))
^+ "\_";$/= ((
'&' ))|+ "\@"; $,
=(( '['))& '~'; $\=
','^ "\|";$:= '.' ^'~'
;($~)= ('@')|
"\(";$^= ')'^'['