O'Reilly logo

Sams Teach Yourself Perl in 21 Days, Second Edition by Rafe Colburn, Laura Lemay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Input from Files with while Loops and <>

Over the last three days, you've seen a number of examples that read input from the keyboard using <STDIN>. You've also used the standard input file handle in both a scalar and list context, so at this point you should know the difference between input in a scalar context (line by line) and input in a list context (read until end-of-file).

Getting input from the keyboard, however, is pretty tedious for any amount of input more than a few lines. That statistics script we worked on yesterday proves it—entering more than a couple of numbers into the script takes a long time, and if we want to just add to the existing data, we have to reenter it all each time.

Ideally, then, we'd store the data in a separate ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required