linux4:/home/thomas/learning # perl -e No code specified for -e. linux4:/home/thomas/learning # perl -e '#execute um' linux4:/home/thomas/learning # linux4:/home/thomas/learning # perl -e 'print "hello world" #execute um' hello worldlinux4:/home/thomas/learning # hello worldlinux4:/home/thomas/learning # perl -e 'print "hello world\n"' hello world linux4:/home/thomas/learning # linux4:/home/thomas/learning # perl -e "print qq(hello world\n) #same, but dos compatible quoting (dos no like um single quotes)" hello world linux4:/home/thomas/learning # perl -ne '#read um from the console and execute um (but nothing to execute here)' a << Type this into the console and hit return b c << End the console input with ctrl-d!) linux4:/home/thomas/learning # perl -pe '#read um and print um' a << This gets typed into the console a << This gets printed out b b c c linux4:/home/thomas/learning # perl -pe '$_ = "a\n" #read um, reset $_, and print um' a a b a c a linux4:/home/thomas/learning # perl -ne 'print $_ #read um and print um by executing um' a a b b c c linux4:/home/thomas/learning # perl -ne 'print #read um and print um by executing um with the default variable to print' a a b b c c linux4:/home/thomas/learning # perl -pe 's/b/a/ #substitute um, just um first b' aa aa bb ab cc cc linux4:/home/thomas/learning # perl -pe '$_ =~ s/b/a/ #Same as the first s/// example but more verbose, explicitly giving the default arguments to s///' aa aa bb ab cc cc linux4:/home/thomas/learning # perl -ne 's/b/a/; print #Same thing using -n instead of -p' aa aa bb ab cc cc linux4:/home/thomas/learning # perl -ne '$_ =~ s/b/a/; print $_ #Same thing more verbosely' aa aa bb ab cc cc linux4:/home/thomas/learning # perl -pe 's/b/a/g #substitute um, all um bs' aa aa bb aa cc cc linux4:/home/thomas/learning # perl -pe 's/./a/g #substitute um, all um, all um um!' aa aa bb aa cc aa all um um aaaaaaaaa linux4:/home/thomas/learning # perl -ane 'print "$F[0]$F[4]\n" #autosplit mode, print the first and fifth fields (zero-indexed)' a b c d e ae f g h j i j k l m fi linux4:/home/thomas/learning # perl -ape '$_ = "$F[0]$F[4]\n" #same thing using -p' a b c d e ae linux4:/home/thomas/learning # perl -ane 'print "$G[0]$G[4]\n" #no magic unless you name the array @F' a b c d e linux4:/home/thomas/learning # perl -ape '$_ = join (" ", @F)' a b c d e a b c d e