Interacting with the User

Several different ways exist by which a Perl program can interact with the user. Parameters can be passed to the program, or input can come from the command line.

Supplying Script Input as a Parameter

Many programs allow parameters to be passed when the programs are instantiated. The programs must be smart enough to know what to do with these parameters. The same is true for any routine called in Perl. Fortunately, Perl has a built-in array that captures any parameters passed to it from the command line. That array is the @argv array. As in any language, the elements of the array are numbered starting with zero (0). Therefore, if two parameters were passed to the program, the first value would be the 0 element of the ...

Get Practical UNIX 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.