Re: opening a file
- From: George <george@xxxxxxxxxxxxxxx>
- Date: Sat, 10 Jan 2009 03:08:41 -0700
On Thu, 08 Jan 2009 10:52:23 -0800, Jürgen Exner wrote:
cartercc <cartercc@xxxxxxxxx> wrote:
On Jan 7, 9:50 pm, George <geo...@xxxxxxxxxxxxxxx> wrote:
I thought I would use perl instead of fortran to parse a text file, what
with the new m// s/// capabilities at my fingertips.
Easy, easy, easy ...
open INFILE, "<nameoffile.txt";
Most people would suggest to use the three-argument form of open:
open INFILE, '<', 'nameoffile.txt';
Almost all people would strongly suggest to test for failure:
open INFILE, '<', 'nameoffile.txt' or
die "Cannot open nameoffile.txt because $!\n";
jue
Apparently, going out and getting drunk was exactly what this script
needed, as well as comments that helped.
open(50, '<eph4.txt');
DO:
{ my $line = readline(*50);
if(eof != 0) { exit }
print $line; # no 'write' here
redo DO } # no 'end' possible
close(50)
# perl faulk4.pl
C:\MinGW\source>perl faulk4.pl
Sun 18h 41m 55s -23░ 5.4' 0.983 10.215 52.155 Up
Mercury 20h 2m 16s -22░ 12.5' 1.102 22.537 37.668 Up
Venus 21h 55m 33s -14░ 16.3' 0.795 39.872 11.703 Up
Moon 21h 17m 19s -15░ 2.4' 62.4 ER 36.796 22.871 Up
Mars 18h 11m 59s -24░ 6.1' 2.431 4.552 56.184 Up
Jupiter 20h 3m 35s -20░ 49.4' 6.034 23.867 38.203 Up
Saturn 11h 32m 59s +5░ 8.6' 9.018 -47.333 157.471 Set
Uranus 23h 21m 30s -4░ 57.9' 20.421 48.328 -18.527 Up
Neptune 21h 39m 30s -14░ 22.8' 30.748 38.963 16.599 Up
C:\MinGW\source>
Tja.
--
George
It's clearly a budget. It's got a lot of numbers in it.
George W. Bush
Picture of the Day http://apod.nasa.gov/apod/
.
- Follow-Ups:
- Re: opening a file
- From: Mirco Wahab
- Re: opening a file
- From: Jürgen Exner
- Re: opening a file
- From: Tad J McClellan
- Re: opening a file
- References:
- opening a file
- From: George
- Re: opening a file
- From: cartercc
- Re: opening a file
- From: Jürgen Exner
- opening a file
- Prev by Date: Re: opening a file
- Next by Date: Re: Circular lists
- Previous by thread: Re: opening a file
- Next by thread: Re: opening a file
- Index(es):
Relevant Pages
|