#!/usr/bin/perl use DBI; use IO::Handle; $dbh = DBI->connect("DBI:mysql:db-name:example.com","db-user","db-pass"); while ($answer = ) { chomp $answer; @personal = split(/ /, $answer); $sql = "select login from users where login='$personal[0]' and password='$personal[1]'"; $sth = $dbh->prepare($sql); $sth->execute or die "SQL Error: $DBI::errstr\n"; $result = $sth->fetchrow_array(); if ($result) { print "OK\n"; } else { print "ERR\n"; } IO::Handle::flush(STDOUT); }