print outbut being buffered...

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default print outbut being buffered...

    This is probably a stupid question, but does anyone know how to force
    the output of print to actually PRINT, without forcing me to use a \n?

    It's sort of futile to print a '.' every 60 seconds to indicate the
    app hasn't crashed if the line of periods doesn't show up on the
    screen until a half hour later....

    Thanks!

    Mike-
    Mornings: Evolution in action. Only the grumpy will survive.
    -----------------------------------------------------

    Please note - Due to the intense volume of spam, we have
    installed site-wide spam filters at catherders.com. If
    email from you bounces, try non-HTML, non-encoded,
    non-attachments.
    Michael W . Cocke Guest

  2. Similar Questions and Discussions

    1. FLVPlayback Percentage Buffered Possible?
      Hi, I am developing an application with the FLVPlayback component which so far, is great. I have cue points, total time, current time and all...
    2. buffered output?
      I have an odd problem... I have a perl script that execs another program: $cmd = "motuds t1.dat t2.dat t3.dat > out1"; exec $cmd; Motuds...
    3. Raw or Buffered device?
      "Art S. Kagel" <kagel@bloomberg.net> wrote in message news:<pan.2003.09.12.12.18.51.444282.10594@bloomberg.net>... This of course is abslutely...
    4. Database with buffered and unbuffered log.
      What is significance of Informix database buffered log or unbuffered log parameter.
    5. Buffered input/output.
      Hello, I am struggling with the following problem: Two unrelated programs communicate via two fifos (is this a good way of communicating between...
  3. #2

    Default Re: print outbut being buffered...

    "Michael W . Cocke" wrote:
    >
    > This is probably a stupid question, but does anyone know how to force
    > the output of print to actually PRINT, without forcing me to use a \n?
    >
    > It's sort of futile to print a '.' every 60 seconds to indicate the
    > app hasn't crashed if the line of periods doesn't show up on the
    > screen until a half hour later....
    Well, if you want to use print() you are going to have to turn on
    autoflush.

    $| = 1; # autoflush on
    for ( 1 .. 10 ) {
    print '. ';
    sleep 1;
    }
    print " done.\n";

    Another way to do it is to use syswrite instead which is not buffered.

    for ( 1 .. 10 ) {
    syswrite STDOUT, '. ';
    sleep 1;
    }
    print " done.\n";



    John
    --
    use Perl;
    program
    fulfillment
    John W. Krahn Guest

  4. #3

    Default Re: print outbut being buffered...


    On Jan 27, 2004, at 6:59 AM, Michael W.Cocke wrote:
    > This is probably a stupid question, but does anyone know how to force
    > the output of print to actually PRINT, without forcing me to use a \n?
    >
    did you try

    $| = 1;

    cf perldoc perlvar


    ciao
    drieux

    ---

    Drieux Guest

  5. #4

    Default Re: print outbut being buffered...

    "Michael W.Cocke" wrote:
    > This is probably a stupid question, but does anyone know how to force
    > the output of print to actually PRINT, without forcing me to use a \n?
    {
    local $| = 1;
    ...code for which you need output autoflushed
    }

    {
    local $| = 1;
    my $total = 0;
    for (1..10) {
    my $thousands = $_;
    for (1..10) {
    my $hundreds = ($thousands * 10) + $_;
    for (1..100) {
    $current = ($hundreds * 100) + $_;
    $current-- while $current;
    }
    print '.';
    }
    print "\b"x9, ' 'x9, "\b"x9;
    }
    print "\n";
    }

    Joseph

    R. Joseph Newton Guest

  6. #5

    Default Re: print outbut being buffered...

    On Thu, 29 Jan 2004 03:12:21 -0800, [email]krahnj@acm.org[/email] (John W. Krahn)
    wrote:
    >"Michael W . Cocke" wrote:
    >>
    >> This is probably a stupid question, but does anyone know how to force
    >> the output of print to actually PRINT, without forcing me to use a \n?
    >>
    >> It's sort of futile to print a '.' every 60 seconds to indicate the
    >> app hasn't crashed if the line of periods doesn't show up on the
    >> screen until a half hour later....
    >
    >Well, if you want to use print() you are going to have to turn on
    >autoflush.
    >
    [snipped]

    Thanks! That's what I wound up doing. I don't know why, but it took
    2 days for my message to post.. I appreciate the replies, but the
    question is long answered.

    Mike-

    Mornings: Evolution in action. Only the grumpy will survive.
    -----------------------------------------------------

    Please note - Due to the intense volume of spam, we have
    installed site-wide spam filters at catherders.com. If
    email from you bounces, try non-HTML, non-encoded,
    non-attachments.
    Michael W . Cocke Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139