Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

hi there,

my perlscript (working on winnt) contains the following section:
for(;ReadKey(-1) ne "x";) { a lot of code } exit;
but now i need to run it on a sparcstation20 with solaris 7 as os. i haven't got the possibilities to build the needed term:readkey module, so i changed my code:
for(;;) { ... }
so, now i have to finish the script with 'ctrl+c' and not with an 'x' - but thats no prob...
after starting the script and controlling the progress via system prompts, i had to realise, that the perl runtime stops right before the infinite loop! but it doesn't quit, it just seems to wait.
is this a solaris specific issue or is this a feature/bug of the installed sieperl-distribution? and, how can i solve this? (i don't like the idea of for($i=0;$i<1000000;$i++){...})
thx

Edited: ~Tue Sep 24 18:28:44 2002 (GMT) by footpad: Removed <BR> tags from <code> blocks, per Consideration.

Replies are listed 'Best First'.
Re: solaris 7 issue...
by blakem (Monsignor) on Sep 24, 2002 at 08:57 UTC
    I don't see why your infinite loop isn't working, but there are several other ways to write them:
    while(1) { ... }
    OR
    { ... redo }
    OR
    while() { ... }
    OR
    do { ... } while 1;
    OR
    do { ... } until 0;
    See if one of these does what you need...

    -Blake

      thx,
      i'm testing these possibilities, but until now, nothing seems to work. could it be, that this sieperl distribution sort of blocks infinite loops?
        No, it doesn't. Perhaps you have a bug in your program.

        Abigail

        ok, problem solved - 't was just a wrong setup of the io-stream at solaris 7 -> all my outputs where buffered, not printed...
Re: solaris 7 issue...
by helgi (Hermit) on Sep 24, 2002 at 10:26 UTC
    Anonymous Monk wrote: i haven't got the possibilities to build the needed term:readkey module,

    Of course you do, read the relevant part of the fine manual:

    perldoc -q "How do I keep my own module/library directory?"

    -- Regards,
    Helgi Briem
    helgi AT decode DOT is