I need the read non-blocking of check if there's any
data ready before doing the READ.

The complete consumer is a program that reads account
packets from a radius server (this problem has been solved)
and stores the Radius attributes (MAC,IP,User_name) in a
List of Hashes. This list of hashes has to be processed
every 60 seconds.

The consumer only reads from stdin in order to add new
packets to the listofHashes.


Here there's the consumer that works with: #cat accounts| ./consumer.pl where accounts has: MAC1;IP1;USer1 MAC2;IP2;USer2


#consumer.pl #!/usr/bin/perl -w


my (%account,@accountList,@accountListTemp);


while(1){ my (@lines,$line,@values); sleep(60); @lines = <STDIN>; foreach $line (@lines){ #MAC;IP;User_Name\n chomp($line); @values = split ';',$line; $account{"MAC"} = $values[0]; $account{"IP"} = $values[1]; $account{"Name"} = $values[2]; push @accountList, {%account}; }


my $i;
for $i (0 .. $#accountList){
#Process @accountList <-- IMPORTANT !!



} }

Bob Showalter wrote:
David Moron wrote:

The consumer has only to read lines from its STDIN and print them to
the STDOUT.


print while(<>);


These scripts are a simplified version of the producer/consumer
problem and they try to emulate a multithreaded perl program. IMHO
It's not important what I want to do with consumer, the problem is
that consumer cann't read lines from producer because producer never
sends EOF.


Well of course it can read lines. It just can't read *all* the lines into an
array, because the only way for it to know it has read *all* the lines is to
receive an EOF.

From perldoc perlop:

       If a <FILEHANDLE> is used in a context that is looking for a list, a
       list comprising all input lines is returned, one line per list
element.
       It's easy to grow to a rather large data space this way, so use with
       care.


-- David Morón Ruano Coordinador de Proyectos

Grupo OpenWired, S.L.
Cardenal Reig, 26, entr. 3? - 08028 - Barcelona (Spain)
Tel (+34) 93/440 99 90 - Fax (+34) 93/448 41 44
www.openwired.net, www.tecnologialinux.com



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to