You had me at Hello, World...
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{ @p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord ($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&& close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
# This is a comment # So is this my $but_this = 'is not';
$> perldoc $> perldoc perldoc
print "Something"; =head2 This is a POD section This is POD content =cut # POD ended
use strict; use warnings; use Statistics::Descriptive;
#!/usr/bin/perl use strict; use warnings; print "Hello, World"; __END__
$> perldoc strict
#!/usr/bin/perl use strict; use warnings; print "Hello, World"; __END__
$> perldoc warnings
$> cat input.tsv | perl foo.pl $> cat input.tsv | perl foo.pl > output.tsv $> cat input.tsv | perl foo.pl | output.tsv $> cat input.tsv > perl foo.pl $> cat input.tsv | perl fool.pl | perl bar.pl | most $> perl foo.pl < input.tsv $> perl foo.pl < input.tsv > output.tsv $> perl foo.pl < input.tsv | sort | most
$> perl foo.pl 2> errors.txt $> perl foo.pl 1> output.tsv $> perl foo.pl > output.tsv $> perl foo.pl 2>&1 | most $> perl foo.pl &> both.txt $> perl bar.pl >> output.tsv $> perl bar.pl 2>> errors.txt
$> perl badfoo.pl 2> warnings.txt $> splain -h Unknown option: h Usage: /home/sapo/software/bin/splain [-v] [-p] [-f splainpod] $> perldoc splain $> cat warnings.txt | splain -p $> splain -p < warnings.txt $> perl badfoo.pl 2>&1 | splain -p
$> perldoc -f print
print "Hello, World"; # :- # Hello, World$> print STDOUT "Hello, World"; # :- # Hello, World$> print STDERR "Hello, World"; # :- # Hello, World$>
print "Hello, World "; # :- # Hello, World # $> print "Hello, World\n"; # :- # Hello, World # $> print "Hello,", "World", "\n"; # :- # Hello,World # $> print "Hello, ", "World", "\n"; # :- # Hello, World # $>
print "Hello,\tWorld\n"; # :- # Hello, World # $>
print "Hello, World\n"; # :- # Hello, World # $> print 'Hello, World\n'; # :- # Hello, World\n$>
print "Hello, " Venky "\n"; # :- # #%@#%$#@%$ # $> print "Hello, \"Venky\"\n"; # :- # Hello, "Venky" # $> print "Hello, \'Venky\'\n"; # :- # Hello, 'Venky' # $> print qq{Hello, "Venky"\n}; # :- # Hello, "Venky" # $> print qq/Hello, {Venky}\n/; # :- # Hello, {Venky} # $>
#!/usr/bin/perl use strict; use warnings; # declare our variables my $first_number = 1; my $second_number = 12; # compute some stuff my $sum = $first_number + $second_number; my $difference = $first_number - $second_number; my $product = $first_number * $second_number; my $power = $first_number**$second_number; my $reminder = $first_number % $second_number; # print the operands print "First Number = $first_number\n"; print "Second Number = $second_number\n"; # print some values print "sum = $sum, difference = $difference\n"; print "product = $product, ratio = ", $first_number / $second_number, "\n"; print "power = $power, reminder = $first_number % $second_number\n"; __END__
print 2 + 5, ',', 2 - 5, ',', 2 * 5, ',', 2 / 5, ',', 5 % 2, ',', 2**5, 2 x 5, "\n"; # :- # 7,-3,10,0.4,1,32,22222 # $>
$> perldoc perl $> perldoc perlop
print( ( 2 + 2 ) / 2 ) * 2;
my $foo = 5; print "The value of the 'foo' variable is $foo\n"; # :- # The value of the 'foo' variable is 5 # $>
# post-increment my $foo = 1; print $foo, ',', $foo++, ',', $foo, "\n"; # :- # 1,1,2 # $> # pre-increment my $foo = 1; print $foo, ',', ++$foo, ',', $foo, "\n"; # :- # 1,2,2 # $> my $foo = 1; # $foo = $foo + 3 $foo += 3; #4 # $foo = $foo - 1 $foo -= 1; #3 $foo *= 2; #6 $foo /= 2; #3 $foo %= 2; #1
my $bar; #undef my $foo = 'tim5'; #initialized my $baz = '5toady'; print $bar; # :- # #^$%@#$#$ # $> my $sum = $bar + 3; # :- # #$%@#%#@$%@# # $> print $foo + 3, "\n"; # numerical value of $foo is 0 # :- # 3 # $> print $foo + $baz, "\n"; # numerical value of $baz is 5 # :- # 5 # $>
#!/usr/bin/perl use strict; use warnings; my $foo = 5; print "foo outside the scopes is $foo\n"; { print "foo at the beginning of the first scope is $foo\n"; my $foo = 10; print "foo in the first scope is $foo\n"; { print "foo at the beginning of the second scope is $foo\n"; # will throw error! $bar doesn't exist here! # print "bar at the end of the first scope is $bar\n"; my $bar = 20; print "bar in the second scope is $bar\n"; } print "foo at the end of the first scope is $foo\n"; # will throw error! $bar doesn't exist here! # print "bar at the end of the first scope is $bar\n"; } print "foo outside the end of the scopes is $foo\n"; __END__ # :- # foo outside the scopes is 5 # foo at the beginning of the first scope is 5 # foo in the first scope is 10 # foo at the beginning of the second scope is 10 # bar in the second scope is 20 # foo at the end of the first scope is 10 # foo outside the end of the scopes is 5 # $>
#!/usr/bin/perl use strict; use warnings; print "Enter something\n"; my $foo = <STDIN>; print "You entered '$foo'\n"; __END__ # :- # Enter something # ->My name is Venky # You entered 'My name is Venky # ' # $>
#!/usr/bin/perl use strict; use warnings; print "Enter something\n"; my $foo = <STDIN>; chomp $foo; print "You entered '$foo'\n"; __END__ # :- # Enter something # ->My name is Venky # You entered 'My name is Venky' # $>
chomp( my $foo = <STDIN> ); # another my $foo = <STDIN>; chomp $foo; # another my $foo = <STDIN>; print "You entered '", chomp $foo, "'\n";
#!/usr/bin/perl use strict; use warnings; # declare our variables chomp( my $first_number = <STDIN> ); chomp( my $second_number = <STDIN> ); # compute some stuff my $sum = $first_number + $second_number; my $difference = $first_number - $second_number; my $product = $first_number * $second_number; my $power = $first_number**$second_number; my $reminder = $first_number % $second_number; # print the operands print "First Number = $first_number\n"; print "Second Number = $second_number\n"; # print some values print "sum = $sum, difference = $difference\n"; print "product = $product, ratio = ", $first_number / $second_number, "\n"; print "power = $power, reminder = $first_number % $second_number\n"; __END__