> -----Original Message----- > From: Octavian Rasnita [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, February 13, 2002 2:48 PM > To: [EMAIL PROTECTED] > Subject: Reading a file > > > Hi all, > I would like to read a file line by line if possible, but the > file is not > text only, and I can't read it. > Do you have any idea what should I do to read it with Perl? > Thank you. > Teddy, > My dear email address is [EMAIL PROTECTED]
When you say you "can't read it", what do you mean? You get more or less than a line with each read? You read a line, but can't interpret the contents? How are "lines" defined in the file? If the lines are delimited by some character or sequence of characters, you can assign that delimiter to the $/ variable and perl will read line by line with the normal <FILE> operator. If lines are fixed-length with no delimiters, you can set $/ to a reference to an integer representing the record size. Or you can use the read() function to read a fixed number of bytes. If lines are determined more elaborately, you can always use read() to read as many bytes as you want. If you're on Windows, be sure to see the binmode() function. perldoc perlvar (documents $/) perldoc -f read perldoc -f binmode perldoc perlop (see section on I/O Operators) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
