Topic: "Reading file in Perl" (page 1 of 1)

1
Author Post
CommComm
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
Hi all.

I try to read a binary file in perl with something like
while(($var = getc(FILE01)) ne "" )
...
or
while (!eof(FILE01)) {
$c = getc(FILE01);
...

But when i get a "1A" character (SUP) I' m stuck because the reading ends.

A solution would be to read lines and split them, but perhaps somebody knows something easier or more tricky.

TIA

Edited by CommComm on 03.10.2004 12:34:04
private message
quangntenemy
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
Hi,

I think for a text file you should read line by line like this:
open (FILE, "filename") || die "couldn't open the file!";

while ($line = <FILE>) {
  # do something with $line
}

close(FILE);
private message EMail Website
CommComm
groupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmastergroupmaster
Sorry.. I meant binary file..., reading byte by byte...
private message

Topic: "Reading file in Perl" (page 1 of 1)

1