A Simple Perl Script

The script in Listing 11.1 uses most of the techniques covered thus far in the chapter, as well as a few that haven’t been covered (and that’s about all it does). This script is available on the included Disc 3 as simpledemo.pl.

Listing 11.1. Simple Demo Perl Script (simpledemo.pl)
#!/usr/bin/env perl # <STDIN> is an I/O handle referring to the standard input. In this context, # we're using it to read in text input from a prompt. The chomp operator removes # any trailing newline/return characters from the end of the input. print "Please enter your name: "; chomp ($name = <STDIN>); srand; # Initialize the random number generator @namelist = ("Bob","Jane","Frank"); @colorlist = ("green","red","blue","yellow"); foreach $testname ...

Get FreeBSD6 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.