in reply to Character Input

open S, "foo" or die "Can't open foo: $!"; my $buffer; while (read S, $buffer, 1) { print $buffer, "\n"; } close S or die "Can't close foo: $!";
Though you may want to read in slightly larger increments than one character at a time, as that's relatively slow.

How large is your file? Perhaps reading in 4k bytes at a time might work out for you?

Replies are listed 'Best First'.
RE: Re: Character Input
by jerji (Novice) on Mar 28, 2000 at 03:04 UTC

    It is worth noting that speed will probably not be a problem with this since Perl's stdio is buffered by default.

    That is, the first call to read() will cause Perl to stash away its own buffer, preventing you from needing to maintain your own.

    If you want to do it this way, sysread() would be a better choice, as this is Perl's interface to the read() syscall.