my $user_id = <>; # the scanner sends keyboard input my $person_timeout = time() + 30; # 30 seconds until we consider the scan done while( time < $person_timeout and my $book_id = <> ) { $person_timeout = time() + 30; # 30 seconds until we consider the scan done print "Person $user_id has checked out book $book_id\n"; }