Results 1 to 6 of 6

Thread: perl - unbuffered output

  1. #1

    perl - unbuffered output

    i need to be able to print to the terminal, but not a line at a time, like just 3 letters and no new line

    i know i gotta unbuffer the output somehow. but how?

    thanks sooo much!

    :-D

  2. #2

    Re:perl - unbuffered output

    flush maybe? I know C, Python and O'Caml have flush.

  3. #3

    Re:perl - unbuffered output

    [quote author=gorn link=board=9;threadid=4214;start=0#41661 date=1026865819]i need to be able to print to the terminal, but not a line at a time, like just 3 letters and no new line

    i know i gotta unbuffer the output somehow. but how?

    thanks sooo much![/quote]

    so you're writing perl code, and you need a way to print some text, without the linebreak, so that you can print more text to the same line later on?

    Easy. Don't put the "\n" at the end of the string that you're printing.

  4. #4

    Re:perl - unbuffered output

    [quote author=Feztaa link=board=9;threadid=4214;start=0#42018 date=1027065179]
    Easy. Don't put the "\n" at the end of the string that you're printing.
    [/quote]

    Code:
    [vince@vincent: ~/prog/test]% cat pr.pl 
    #!/usr/bin/env perl
    
    print "Hello!";
    [vince@vincent: ~/prog/test]% ./pr.pl 
    [vince@vincent: ~/prog/test]%
    This is the problem, he has to flush the buffer

  5. #5

    Re:perl - unbuffered output

    Code:
    feztaa@feztron:/home/feztaa$ cat wtf.pl 
    #!/usr/bin/env perl
    
    print "Hello!";
    feztaa@feztron:/home/feztaa$ ./wtf.pl 
    Hello!feztaa@feztron:/home/feztaa$
    At first I thought your guys' shells were just moving your prompts back to the beginning of the line, hiding the output (which they probably are), but then I tried this:

    Code:
    feztaa@feztron:/home/feztaa$ cat wtf.pl 
    #!/usr/bin/env perl
    
    print "Hell";
    sleep 1;
    print "o!\n";
    feztaa@feztron:/home/feztaa$ ./wtf.pl 
    Hello!
    feztaa@feztron:/home/feztaa$
    And when the text all popped up at once, I understood what you meant. The only times I've ever needed to print different stuff to the same line, buffering the output was totally acceptable (processing inside a forloop, where the line can be printed all at once, but I can only know what parts of the line are at any given time). I have no idea how to unbuffer it, but can I ask what it is that you're doing that requires unbuffered output, gorn?

  6. #6

    Re:perl - unbuffered output

    actually i stopped working on it, but i might try again. making a gui for this thing... hard to explain i'll show it to you if i ever finish, but i figured out what i need:
    Code:
    $| = 1;
    print "hell";
    sleep 1;
    print "o\n";
    works as it should.

Similar Threads

  1. Trying to figure out the output of the 'last' command
    By tech291083 in forum Redhat / Fedora
    Replies: 1
    Last Post: 05-14-2007, 12:28 PM
  2. What is the output of this program?
    By t048 in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 10-13-2002, 08:30 PM
  3. perl question from a perl newb
    By tolstoy in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 09-06-2002, 01:16 AM
  4. Moving output on screen?
    By GotAnyGrapes? in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 07-19-2002, 09:15 AM
  5. Anyone know how to output pretty colors?
    By morphman in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 05-24-2002, 02:13 PM

Bookmarks

Posting Permissions

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