Re: Beginners question
[email protected] (Nicholas Clark) Wed, 15 Dec 1999 15:58:15 +0000
| Newsgroups | perl.riscos |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Dec 15, 1999 at 04:38:20PM +0100, Alex Bach Andersen wrote:
> Hi all,
>
> I've just got a copy of Learning Perl, and experience problems allready
> at the second example in the book.
>
> The Hello world script runs very nice, whereas the rest of the examples
> of Chapter one e.g:
>
>
> #!/usr/bin/perl -w
>
> print "What is your name? \n ";
> $name = <STDIN>;
> chomp ($name);
> print "Hello, $name!\n";
>
> Doesn't do what they seemed to be supposed to do. Is this due to
> limitations in !perl or RISC OS?
IIRC it's a bug (or at least misfeature) in the stdio implementation of
UnixLib. (however, you've got a trailing space after \n, which might confuse
things further (ie UnixLib wrong, not you))
It appears that standard stdio flushes stdout whenever stdin needs to re-read
from the terminal
(as a workaround, add
$| = 1;
as the second line to enable auto-flush mode)
Some-point soon I'm going to check that sfio ports cleanly, and make perl use
sfio rather than UnixLib stdio. (which does have a few other problems)
Nick (who has over a week off over new year which might get put to something
fun, where perl porting is classed as fun (well, more fun that work))