|
|
<STDIN> |
|
| You're probably wondering what use perl is if you can't get input... or you're wondering how many of those jawbreakers you could fit in your mouth. At any rate I'll explain how to get user input and hope you don't choke. | |
| If try to assign the value <STDIN> to a variable, the computer will wait for the program's user to type something in and hit enter. After your user hits enter, the information that he typed is stored in that same variable you tried assigning <STDIN> to. | |
Example |
|
|
$usersaid = <STDIN>; print("$usersaid"); |
|
| This will get whatever the user typed and spew it right back at him. |
Writing to a File |
| Here is an example of overwriting a file |
|
open(FNAME,">test.txt"); for($i = 0; $i < 600; $i++){ print FNAME "\nThis is line $i, enjoy!"; } close(FNAME) |