User Input and Output

Download: mp4 ogv webm

Variable interpolation

examples/perl/variable_interpolation.pl

#!/usr/bin/perl
use strict;
use warnings;

my $name = "Foo";
print "Hello ", $name, " - how are you ?\n";


print "Hello $name - how are you ?\n";

More about strings and interpolation.

Read from the keyboard

examples/perl/read_from_stdin.pl

#!/usr/bin/perl
use strict;
use warnings;

print "Enter your name, please: ";
my $name = <STDIN>;
print "Hello $name - how are you ?\n";

chomp

examples/perl/read_from_stdin_chomp.pl

#!/usr/bin/perl
use strict;
use warnings;

print "Enter your name, please: ";
my $name = <STDIN>;
chomp $name;
print "Hello $name - how are you ?\n";