How to print question
am 17.04.2008 16:47:15 von 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.
thanks
Mike
Re: How to print question
am 17.04.2008 16:59:50 von 1usa
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 <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
Re: How to print question
am 17.04.2008 17:02:21 von Ben Morrow
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
Re: How to print question
am 17.04.2008 17:21:01 von mmccaws2
On Apr 17, 8:02=A0am, Ben Morrow wrote:
> Quoth mmccaws2 :
>
> > I can't quite recall the printing term so please bear with me. =A0 When
> > you want your user to know that something is happening the app often
> > will print to the screen saying something like "load ...". =A0I want to
> > create the same sort of script that produce a "." or similar symbol
> > for each fraction of second that goes by. =A0If I knew the 'key' words
> > I'd search for it.
>
> print? Which part of the program are you having a problem with?
> Something like
>
> =A0 =A0 use Time::HiRes qw/sleep/;
>
> =A0 =A0 $| =3D 1;
>
> =A0 =A0 print 'loading';
>
> =A0 =A0 for (1..100) {
> =A0 =A0 =A0 =A0 sleep 0.1;
> =A0 =A0 =A0 =A0 print '.';
> =A0 =A0 }
>
> =A0 =A0 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 "$| =3D 1;"
for?
Mike
Re: How to print question
am 17.04.2008 17:34:47 von jurgenex
mmccaws2 wrote:
>Your code is almost exactly what I had. But what is the "$| = 1;"
>for?
See "perldoc perlvar"
jue
Re: How to print question
am 17.04.2008 17:35:08 von steveo
mmccaws2 wrote:
>Your code is almost exactly what I had. But what is the "$| = 1;"
>for?
perldoc perlvar | grep '$|'
--
Steven O'Neill steveo@panix.com
Brooklyn, NY http://www.panix.com/~steveo
Re: How to print question
am 17.04.2008 18:19:35 von mmccaws2
On Apr 17, 8:35=A0am, ste...@panix.com (Steven M. O'Neill) wrote:
> mmccaws2 =A0 wrote:
> >Your code is almost exactly what I had. =A0But what is the "$| =3D 1;"
> >for?
>
> =A0 =A0 perldoc perlvar | grep '$|'
>
> --
> Steven O'Neill =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0ste...@panix.com
> Brooklyn, NY =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0http://www.pan=
ix.com/~steveo
Thanks everyone The missing link was the $| =3D 1;
Mike
Re: How to print question
am 20.04.2008 08:42:25 von Joe Smith
mmccaws2 wrote:
> produce a "." or similar symbol for each fraction of second that goes by.
I had something like that, then decided to show progress once a second
(instead of per 100 or per 1000 items).
-Joe
my($progress_time,$count);
sub wanted {
$directories{$File::Find::name} = 1 if -d $_;
return unless -f _; # Skip symlinks and such
push @files,$File::Find::name;
++$count;
if ($verbose) { # Once a second, output number of files found
my $now = time;
$progress_time ||= $now;
print " $count" if $now > $progress_time;
$progress_time = $now;
}
}