Re: opening a file



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";
while (<INFILE>) {print;}
close INFILE;

This creates the handle INFILE for the named file in your current
directory and cycles through it line by line, printing each line. To
write the file to an out handle, do this:

open INFILE, "<nameoffile.txt";
open OUTFILE, ">nameofnewfile.txt";
while (<INFILE>) { print OUTFILE;}
close OUTFILE;
close INFILE;

CC.
.



Relevant Pages

  • [PATCH] Fix incompatibility with versions of Perl less than 5.6.0
    ... 5.6.0 also introduced the pragma 'use warnings'. ... foreach my $file { ... local *INFILE; ... local *OUTFILE; ...
    (Linux-Kernel)
  • Re: Quick n Dirty Unpacking of COMP-3?
    ... > First thing I do is look for FileAid jobs I have that do something ... it can reformat based on COBOL layouts. ... > OPEN INPUT INFILE OUTPUT OUTFILE. ...
    (comp.lang.cobol)
  • Re: Quick n Dirty Unpacking of COMP-3?
    ... > First thing I do is look for FileAid jobs I have that do something ... it can reformat based on COBOL layouts. ... > OPEN INPUT INFILE OUTPUT OUTFILE. ...
    (comp.lang.cobol)
  • Re: Layout Hell.: leave it
    ... LW>> files record layout; everything else in that program would not need ... and with the REPLACING clause for the output file; ... 000070 SELECT INFILE ... 000110 SELECT OUTFILE ...
    (comp.lang.cobol)
  • Re: Importing data into a table
    ... Use Open and Line Input# to filter the original text file into a temp ... dim inFile as integer ... dim outFile as integer ... dim readText as string ...
    (microsoft.public.access.modulesdaovba)