Sample Perl Script
CHAPTER 2: SAMPLE PERL SCRIPT
Sample Script
welcome
_______
#!/usr/bin/perl
# Perl comments begin with a #. Anything from the # to
# the end of the line is a Perl comment.
# The first line of a Perl script should be as shown above.
# This is the best way to invoke a Perl script.
# Perl script to read in a name and print a welcome message.
print ("Enter your name: "); # Prompt for name
$name = <STDIN>; # Read input line
chop ($name); # Remove LF
print ("Hello, $name. Welcome to Perl.\n"); # Welcome!
Bob Tarr
University of Maryland, Baltimore County
tarr@umbc.edu