Try while () { <-- change
my $num = $_; <-- change chop $num; next if(!($num=~m/(^([0-9]+)$)/)); $sum=$sum+$num; Agustin Rivera Webmaster, Pollstar.com http://www.pollstar.com ----- Original Message ----- From: "Mariana Aņez" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, January 02, 2002 3:21 PM Subject: Why can't this two programs be piping? > > I wrote this two scripts (to do "./mynum | ./mycount" on linux shell): > > mynum: > > #******************************************************************* > # Write a number from 1 to oo > #****************************************************************** > > #!/usr/bin/perl > 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 $count; > my $last; > > local $SIG{'ALRM'}=\&on_count; > > alarm 10; > > > while ( <STDIN> ) { > > my $num = <STDIN>; > chop $num; > next if(!($num=~m/(^([0-9]+)$)/)); > > $sum=$sum+$num; > > > } > > 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; > > } > > .....but it doesn't work (I mean the pipe doesn't work) do Somebody > have an idea ? > > Mariana C. Aņez Salaverria > --------------------------------------- > Sync Consultores c.a. > www.sync.com.ve > Av. Libertador, Torre Maracaibo Of 13H > Caracas - Venezuela > Telf.: (0212) 762-8555/3012/8693 > Fax : (0212) 762-6671 > Cel : (0416) 622-0000 > -------------------------------------- > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]