How to print question

Discussion in 'Perl Misc' started by mmccaws2, Apr 17, 2008.

  1. mmccaws2

    mmccaws2 Guest

    I can't quite recall the printing term so please bear with me. When
    you want your user to know that something is happening the app often
    will print to the screen saying something like "load ...". I want to
    create the same sort of script that produce a "." or similar symbol
    for each fraction of second that goes by. If I knew the 'key' words
    I'd search for it.

    thanks

    Mike
    mmccaws2, Apr 17, 2008
    #1
    1. Advertising

  2. mmccaws2 <> wrote in
    news:77a33807-b21d-4cd4-818f-23d53a67bbd5@
    2g2000hsn.googlegroups.com:

    > I can't quite recall the printing term so please bear with me.
    > When you want your user to know that something is happening the
    > app often will print to the screen saying something like "load
    > ...". I want to create the same sort of script that produce a "."
    > or similar symbol for each fraction of second that goes by.


    Why? Does your user not have a watch or something?

    > If I knew the 'key' words I'd search for it.


    I would be much more interested in knowing how much 'progress' is
    being made.

    For example, I once wrote a script to generate 1536 png files after
    some data processing. It ran in about 20 minutes.

    ### pseudo code

    {
    my $progress = 0;
    while ( $datasets->next ) {
    # process data set
    ++ $progress;
    print STDERR '.' unless $progress % 100;
    }
    }

    ###

    so that a dot was printed every time 100 data sets were completed.

    In this throaway script, I used STDERR because STDOUT actually had
    other important output going to it.

    Sinan

    --
    A. Sinan Unur <>
    (remove .invalid and reverse each component for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://www.rehabitation.com/clpmisc/
    A. Sinan Unur, Apr 17, 2008
    #2
    1. Advertising

  3. mmccaws2

    Ben Morrow Guest

    Quoth mmccaws2 <>:
    > I can't quite recall the printing term so please bear with me. When
    > you want your user to know that something is happening the app often
    > will print to the screen saying something like "load ...". I want to
    > create the same sort of script that produce a "." or similar symbol
    > for each fraction of second that goes by. If I knew the 'key' words
    > I'd search for it.


    print? Which part of the program are you having a problem with?
    Something like

    use Time::HiRes qw/sleep/;

    $| = 1;

    print 'loading';

    for (1..100) {
    sleep 0.1;
    print '.';
    }

    print "\n";

    works, but presumably you don't *just* want to mark the passage of time.

    Ben
    Ben Morrow, Apr 17, 2008
    #3
  4. mmccaws2

    mmccaws2 Guest

    On Apr 17, 8:02 am, Ben Morrow <> wrote:
    > Quoth mmccaws2 <>:
    >
    > > I can't quite recall the printing term so please bear with me.   When
    > > you want your user to know that something is happening the app often
    > > will print to the screen saying something like "load ...".  I want to
    > > create the same sort of script that produce a "." or similar symbol
    > > for each fraction of second that goes by.  If I knew the 'key' words
    > > I'd search for it.

    >
    > print? Which part of the program are you having a problem with?
    > Something like
    >
    >     use Time::HiRes qw/sleep/;
    >
    >     $| = 1;
    >
    >     print 'loading';
    >
    >     for (1..100) {
    >         sleep 0.1;
    >         print '.';
    >     }
    >
    >     print "\n";
    >
    > works, but presumably you don't *just* want to mark the passage of time.
    >
    > Ben


    Your code is almost exactly what I had. But what is the "$| = 1;"
    for?

    Mike
    mmccaws2, Apr 17, 2008
    #4
  5. mmccaws2 <> wrote:
    >Your code is almost exactly what I had. But what is the "$| = 1;"
    >for?


    See "perldoc perlvar"

    jue
    Jürgen Exner, Apr 17, 2008
    #5
  6. mmccaws2 <> wrote:
    >Your code is almost exactly what I had. But what is the "$| = 1;"
    >for?


    perldoc perlvar | grep '$|'

    --
    Steven O'Neill
    Brooklyn, NY http://www.panix.com/~steveo
    Steven M. O'Neill, Apr 17, 2008
    #6
  7. mmccaws2

    mmccaws2 Guest

    On Apr 17, 8:35 am, (Steven M. O'Neill) wrote:
    > mmccaws2  <> wrote:
    > >Your code is almost exactly what I had.  But what is the "$| = 1;"
    > >for?

    >
    >     perldoc perlvar | grep '$|'
    >
    > --
    > Steven O'Neill                                 
    > Brooklyn, NY                        http://www.panix.com/~steveo


    Thanks everyone The missing link was the $| = 1;

    Mike
    mmccaws2, Apr 17, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bad_Kid
    Replies:
    3
    Views:
    3,944
    Shawn H. Mesiatowsky
    Apr 7, 2005
  2. Bryan Shaw

    Lock Print Screen and File Print

    Bryan Shaw, Apr 19, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,946
    Kevin Spencer
    Apr 20, 2005
  3. EDom
    Replies:
    0
    Views:
    440
  4. keto
    Replies:
    0
    Views:
    931
  5. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    348
    David Cournapeau
    Dec 30, 2008
Loading...

Share This Page