4/7 |
Michael Robinson
|
#!/usr/bin/perl use POE qw(Component::Server::TCP Component::Client::TCP Filter::Stream); use strict; my $debug = 1; my %input = ( 'default' => { 'User:' => 'Michael', 'password:' => 'password', }, '10.0.0.1' => { 'User:' => 'Other\User', 'password:' => 'pass', } ); sub do_input { my ($ip, $input, $fd, $heap) = @_; my $response_ref = $input{$ip} || $input{'default'}; for my $k (keys %$response_ref) { if ($input =~ /$k/) { $fd->put($response_ref->{$k} . "\r\n"); } } }