no. I'm not saying anything. I tend to like naming thnigs, however for 
clarity of thought.

On Thu, 3 Jan 2002, Mariana Aņez wrote:

> 
> Do you mean I should use name pipes (using open function)?
> 
> -----Original Message-----
> From: Matthew Lyon [mailto:[EMAIL PROTECTED]] 
> Sent: Wednesday, January 02, 2002 3:53 PM
> To: John W. Krahn
> Cc: [EMAIL PROTECTED]
> Subject: Re: Why can't this two programs be piping?
> 
> This goes beyond the scope of these scripts, but I've found some 
> autoflushes to be less than perfect in all situations... 
> I perfer to name pipes/handles and clamp them shut occasionally. That
> way 
> I can ensure flow (at least outward) in .pl scripts. This is especially 
> useful when a couple of different scripts or programs are dumping stuff 
> into the same file (say a logfile) and you need a 
> message-order-with-respect-to-time-perserved...
> 
> On Wed, 2 Jan 2002, John W. Krahn wrote:
> 
> > Mariana aņez wrote:
> > > 
> > > I wrote this two scripts (to do "./mynum | ./mycount" on linux
> shell):
> > > 
> > > mynum:
> > > 
> > > #*******************************************************************
> > > #         Write a number from 1 to oo
> > > #******************************************************************
> > > 
> > >   #!/usr/bin/perl
> > 
> > Because standard input and output are buffered you have to add this
> line
> > to get the results you want:
> > 
> > $| = 1;
> > 
> > >   my $i=1;
> > >   while ($i>0){
> > >      print "$i\n";
> > >      sleep 5;
> > >      $i++;
> > >      }
> > > 
> > > mycount:
> > > 
> > >
> #***********************************************************************
> > > ****# Read from standard input (STDIN) a number pulsing it with
> before
> > > number
> > > # and each 10 seconds print the result value on the screen
> > >
> #***********************************************************************
> > > ****
> > > 
> > > #!/usr/bin/perl
> > > 
> > > my $sum=0;
> > > my $first;
> > 
> > my $first = 0;
> > 
> > If you don't initialize $first you will get a warning when you compare
> > it to zero in your if statement.
> > 
> > > my $count;
> > > my $last;
> > > 
> > > local $SIG{'ALRM'}=\&on_count;
> > > 
> > >  alarm 10;
> > > 
> > > while (  <STDIN> ) {
> > >   my $num = <STDIN>;
> > 
> > You are reading every _second_ line from STDIN.  Is that really what
> you
> > want?
> > 
> > >   chop $num;
> > >   next if(!($num=~m/(^([0-9]+)$)/));
> > >   $sum=$sum+$num;
> > >  }
> > 
> > while ( <> ) {
> > # if you really only want every second line then uncomment the next
> line
> > #   next if $. % 2;
> >     chomp;
> >     next unless /^\d+$/;
> >     $sum += $_;
> >     }
> > 
> > 
> > > sub on_count{
> > >  if ($first==0)
> > >    {
> > >     $first=1;
> > >     $last=$sum;
> > >     print "NAN:$sum\n";
> > >     }
> > >    else{
> > > 
> > >     $count=$sum-$last;
> > >     $last=$sum;
> > >     print "Contador=$count\n";
> > >     }
> > > 
> > >   alarm 10;
> > > 
> > > }
> > 
> > 
> > 
> > John
> > 
> 
> 
> 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to