37 users online (0 members and 37 guests)  


  Results 1 to 3 of 3

Related

  1. CSS 3.0 animation features    Forum: CSS Forum
    Replies: 0
  2. basic animation    Forum: Javascript Forum
    Replies: 1
  3. problems with animation    Forum: Graphics Forum
    Replies: 1
  4. Animation problem    Forum: Graphics Forum
    Replies: 1
  1. #1
    phoenix's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    1

    HELP!Animation with perl

    Hi!
    How to implement animation in perl in commnad line.
    I need to view strings in one line only, not in new lines, and with some delay. I tried \r with sleep function but it didn't help. It seems that sleep function works only with \n.
    so
    print "hello1\n";
    sleep 1;
    print "hello2\n";
    works, but
    print "hello1\r";
    sleep 1;
    print "hello1\r";
    don't.

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: HELP!Animation with perl

    if i understand what you are trying to do, the best bet is to use javascript, but you may use perl to put javascript in it, try this:
    Code:
    #!usr/bin/perl
    print "Content-type:text/html\n\n";
    print '<html>
    <head>
    <script type="text/javascript">
    function timer(t){
    document.getElementById("timer").innerHTML = "Count to 10: " + t + " of 10";
    }
    </script>
    </head>
    <body>
    <div id="timer">&nbsp;</div>';
    
    for ($i = 1; $i <= 10; $i++) {
    print "<img src=\"\" onerror=\"timer($i); this.outerHTML = ''\">";
    sleep 1;
    }
    print '</body></html>';

  3. #3
    fireartist's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    3

    Re: HELP!Animation with perl

    When you say command line, I presume this is non-CGI, right?

    Try the (http://search.cpan.org/~jstowe/Term-Screen-1.03/Screen.pm) Term::Screen module, in particular the clreol() method.
    From the docs: Clear to the end of the line - cursor doesn't move.

    Also of use might be the (http://search.cpan.org/~kbaucom/Term-Animation-2.1/lib/Term/Animation.pm) Term::Animatiom module.

    See also (http://search.cpan.org/~jhi/Time-HiRes-1.73/HiRes.pm) Time::HiRes for sleeping less than a whole second.
    Last edited by HTML; 03-09-2012 at 10:18 AM.



Tags for this Thread