print "Howdy, world!\n";
*****
$phrase = "Howdy, world!\n";          # Set a variable.
print $phrase;                        # Print the variable.
*****
$answer = 42;               # an integer
$pi = 3.14159265;           # a "real" number
$avocados = 6.02e23;        # scientific notation
$pet = "Camel";             # string
$sign = "I love my $pet";   # string with interpolation
$cost = 'It costs $100';    # string without interpolation
$thence = $whence;          # another variable
$x = $moles * $avocados;    # an expression
$cwd = `pwd`;               # string output from a command
$exit = system("vi $x");    # numeric status of a command
$fido = new Camel "Fido";   # an object
*****
$camels = '123';
print $camels + 1, "\n";
*****
@home = ("couch", "chair", "table", "stove");
*****
($potato, $lift, $tennis, $pipe) = @home;
*****
($alpha,$omega) = ($omega,$alpha);
*****
$home[0] = "couch";
$home[1] = "chair";
$home[2] = "table";
$home[3] = "stove";
*****
%longday = ("Sun", "Sunday", "Mon", "Monday", "Tue", "Tuesday",
            "Wed", "Wednesday", "Thu", "Thursday", "Fri",
            "Friday", "Sat", "Saturday");
*****
%longday = (
    "Sun" => "Sunday",
    "Mon" => "Monday",
    "Tue" => "Tuesday",
    "Wed" => "Wednesday",
    "Thu" => "Thursday",
    "Fri" => "Friday",
    "Sat" => "Saturday",
);
*****
$wife{"Adam"} = "Eve";
*****
print "Adam's wife is ", $wife{'Adam'}, ".\n";
*****
$e = exp(1);   # 2.718281828459, or thereabouts
*****
Noel 25
Ben 76
Clementine 49
Norm 66
Chris 92
Doug 42
Carol 25
Ben 12
Clementine 0
Norm 66
*****
% perl -e 'print "Hello, world!\n";'
*****
% perl gradation
*****
#!/usr/bin/perl
*****
% gradation
*****
% ../bin/gradation
*****
#!/bin/sh -- # perl, to stop looping
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
    if 0;
*****
#!/usr/bin/perl -w
*****
open(SESAME, "filename");               # read from existing file
open(SESAME, "<filename");              #   (same thing, explicitly)
open(SESAME, ">filename");              # create file and write to it
open(SESAME, ">>filename");             # append to existing file
open(SESAME, "| output-pipe-command");  # set up an output filter
open(SESAME, "input-pipe-command |");   # set up an input filter
*****
print STDOUT "Enter a number: ";          # ask for a number
$number = <STDIN>;                        # input the number
print STDOUT "The number is $number\n";   # print the number
*****
chop($number = <STDIN>);    # input number and remove newline
*****
$number = <STDIN>;          # input number
chop($number);              # remove newline
*****
$a = 123;
$b = 456;
print $a + $b;     # prints 579
print $a . $b;     # prints 123456
*****
$a = 123;
$b = 3;
print $a * $b;     # prints 369
print $a x $b;     # prints 123123123
*****
print $a . ' is equal to ' . $b . "\n";    # dot operator
print $a, ' is equal to ', $b, "\n";       # list
print "$a is equal to $b\n";               # interpolation
*****
print "-" x $scrwid, "\n";
*****
$a = $b;
$a = $b + 5;
$a = $a * 3;
*****
$a *= 3;
*****
$line .= "\n";  # Append newline to $line.
$fill x= 80;    # Make string $fill into 80 repeats of itself.
$val ||= "2";   # Set $val to 2 if it isn't already set.
*****
chop($number = <STDIN>);
*****
$a = 5;        # $a is assigned 5
$b = ++$a;     # $b is assigned the incremented value of $a, 6
$c = $a--;     # $c is assigned 6, then $a is decremented to 5
*****
open(GRADES, "grades") or die "Can't open file grades: $!\n";
*****
-e "/usr/bin/perl" or warn "Perl is improperly installed\n";
-f "/vmunix" and print "Congrats, we seem to be running BSD Unix\n";
*****
if ($debug_level > 0) {
    # Something has gone wrong.  Tell the user.
    print "Debug: Danger, Will Robinson, danger!\n";
    print "Debug: Answer was '54', expected '42'.\n";
}
*****
if ($city eq "New York") {
    print "New York is northeast of Washington, D.C.\n";
}
elsif ($city eq "Chicago") {
    print "Chicago is northwest of Washington, D.C.\n";
}
elsif ($city eq "Miami") {
    print "Miami is south of Washington, D.C.  And much warmer!\n";
}
else {
    print "I don't know where $city is, sorry.\n";
}
*****
unless ($destination eq $home) {
    print "I'm not going home.\n";
}
*****
while ($tickets_sold < 10000) {
    $available = 10000 - $tickets_sold;
    print "$available tickets are available.  How many would you like: ";
    $purchase = <STDIN>;
    chomp($purchase);
    $tickets_sold += $purchase;
}
*****
print "This show is sold out, please come back later.\n";
*****
 while ($line = <GRADES>) {
*****
while (@ARGV) {
    process(shift @ARGV);
}
*****
for ($sold = 0; $sold < 10000; $sold += $purchase) {
    $available = 10000 - $sold;
    print "$available tickets are available.  How many would you like: ";
    $purchase = <STDIN>;
    chomp($purchase);
}
*****
foreach $user (@users) {
    if (-f "$home{$user}/.nexrc") {
        print "$user is cool... they use a perl-aware vi!\n";
    }
}
*****
foreach $key (sort keys %hash) {
*****
foreach $user (@users) {
    if ($user eq "root" or $user eq "lp") {
        next;
    }
    if ($user eq "special") {
        print "Found the special account.\n";
        # do some processing
        last;
    }
}
*****
LINE: while ($line = <ARTICLE>) {
    last LINE if $line eq "\n"; # stop on first blank line
    next LINE if /^#/;          # skip comment lines
    # your ad here
}
*****
while ($line = <FILE>) {
    if ($line =~ /http:/) {
        print $line;
    }
}
*****
while (<FILE>) {
    print if /http:/;
}
*****
while (<FILE>) {
    print if /http:/;
    print if /ftp:/;
    print if /mailto:/;
    # What next?
}
*****
$_ = "fred xxxxxxx barney";
s/x*//;
*****
/\bFred\b/
*****
next LINE if /^#/;
*****
s/(\S+)\s+(\S+)/$2 $1/
*****
@array = (1 + 2, 3 - 4, 5 * 6, 7 / 8);
*****
sort @guys, @gals, other();
*****
print reverse sort map {lc} keys %hash;
*****
