Reading data using HandlerSocket and PERL
In this recipe, we will create a simple PERL script that reads data using HandlerSocket.
Getting ready
Install the HandlerSocket PERL client libraries as described in the Installing the HandlerSocket PERL client libraries recipe earlier in this chapter.
Launch the mysql
command-line client and run the following commands to create a test table with some data:
CREATE DATABASE IF NOT EXISTS test; USE test; DROP TABLE IF EXISTS hs_test; CREATE TABLE hs_test ( id SERIAL PRIMARY KEY, givenname varchar(64), surname varchar(64) ); INSERT INTO hs_test VALUES (1,"William","Hartnell"), (2,"Patrick","Troughton"), (3,"John","Pertwee"), (4,"Tom","Baker"), (5,"Peter","Davison"), (6,"Colin","Baker");
This sample data is also in the hs_sample_data.sql
file available on the book's website.
How to do it...
Create a file named
hs_read_test.pl
with the following content:#!/usr/bin/perl use strict; use warnings; use Net::HandlerSocket; my $read_args = { host...