You might take a look at AnyEvent Intro:
http://search.cpan.org/~mlehmann/AnyEvent-7.02/lib/AnyEvent/Intro.pod



在 2012-8-30,下午9:46, Chris Stinemetz 写道:

> Hello List,
> 
> I am creating a program, where for the first time, I will be reading
> in data from a socket port.
> 
> I am a bit confused about how to print the processed data while still
> reading in data from the port. Thus far, I have only processed data
> from a file where the while loop ends  when EOF criteria has been met.
> 
> So my question is how do I continue to read in data from the port and
> print the generated array as it is being created?
> 
> snippet:
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> use IO::Socket;
> use Data::Dumper;
> 
> 
> my $host = 'ip..address';
> my $port = portnum;
> my $sock = new IO::Socket::INET(
> PeerAddr => $host,
> PeerPort => $port,
> Proto    => 'tcp'
> );
> 
> die "cannot open socket $!" unless ($sock);
> 
> my @array;
> while ( my $line = <$sock> ) {
> 
>  do stuff and create array...
> 
>  push @array, [ .... stuff .... ];
> 
> }
> ## print @array
> for my $item (@array) {
>    print join(",",@$item),"\n";
> }
> 
> Thanks in advance,
> 
> Chris
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to