my $session = POE::Session->create( inline_states => { _start => sub { # ... }; next => sub { # ... }; got_packet => sub { # decode packet into data structure my $data = { src_ip => $ip->{src_ip}, dest_ip => $ip->{dest_ip}, src_port => $l4->{src_port}, dest_port => $l4->{dest_port}, }; my $json = JSON::to_json($data); foreach my $client ( keys %clients ) { $response->send("<script>dataEvent($json);<script>"); } } } );