| Prev | Perl Notes |
Next |
You can read in one or more lines from external files as necessary.
To read all the data from an external file:
|
open(FILE, "<../myfile.txt") || &ErrorMessage; @ARRAY = <FILE>; close(FILE); foreach $LINE (@ARRAY) { print $LINE; } sub ErrorMessage { print "Could not open file. It either does not exist or the permissions are wrong\n"; exit; } |
Here's an even simpler method:
|
open(FILE, "<../myfile.txt") || die "Could not open file $!"; while ($line=<FILE>) { print $line; } close(FILE); |
| Prev | Home | Next |