#! /usr/bin/perl use warnings; use strict; use feature qw{ say }; use Syntax::Construct qw{ // }; use DBI; my $db = 'DBI'->connect('dbi:SQLite:dbname=:memory:', q(), q(), { RaiseError => 1, }); $db->do(<< '__SQL__'); CREATE TABLE items ( ID INTEGER PRIMARY KEY AUTOINCREMENT, link_id INTEGER, item VARCHAR NOT NULL, style VARCHAR) __SQL__ $db->do(<< '__SQL__'); CREATE TABLE times ( ID INTEGER PRIMARY KEY AUTOINCREMENT, link_id INTEGER, time1 VARCHAR, time2 VARCHAR, location VARCHAR, who VARCHAR, note VARCHAR, extra VARCHAR) __SQL__ my $insert = $db->prepare(<< '__SQL__'); INSERT INTO items(link_id, item, style) VALUES(?, ?, ?) __SQL__ $insert->execute(@$_) for [ 1, 'Large RV Permit Holders must arrive', "H" ], [ 2, 'Early Entry Permit Holders can arrive', "H"], [ 3, 'Registration Gate ', "H"], [ 4, 'Shuttle Bus Operates', "H"], [ 42, 'The Science of Byurakan: The Golden Era of Soviet Astronomy', "A"], [ 43, 'Astro Activities for Children', "K"], [ 44, 'Stellafane New Horizons Project', "Y"], [ 45, 'Scope Making For Teens', "Y"], [ 46, 'Scope Making Demo', "T"]; $insert = $db->prepare(<< '__SQL__'); INSERT INTO times (link_id, time1, time2, location, who, note, extra) VALUES(?, ?, ?, ?, ?, ?, ?) __SQL__ $insert->execute(@$_) for [ 1 , "2016-08-04 12:00", "2016-08-04 16:00", "Entry Gate", "", "Please don't arrive before Noon!", "" ], [ 2 , "2016-08-04 15:00", "2016-08-04 22:00", "Entry Gate", "", "Please don't arrive before 3:00!", "" ], [ 3 , "2016-08-05 09:00", "2016-08-05 22:00", "Entry Gate", "", "Hours", "" ], [ 3 , "2016-08-06 07:00", "2016-08-06 19:00", "Entry Gate", "", "Hours", "" ], [ 4 , "2016-08-05 10:00", "2016-08-05 18:00", "Bus Stops", "", "Bus Stops: Pine Island, Food Tent, Pink Clubhouse", "" ], [ 4 , "2016-08-06 09:00", "2016-08-06 17:00", "Bus Stops", "", "Bus Stops: Pine Island, Food Tent, Pink Clubhouse", "" ], [ 44 , "2016-08-05 13:00", "2016-08-05 17:00", "Bunkhouse", "Paul Fucile and James Lee", "(Teens 12-16)(Requires Signup)", "Modeling technology from the New Horizons" ], [ 45 , "2016-08-06 11:00", "2016-08-06 12:30", "Bunkhouse", "\"Stargazer\" Steve Dodson", "Ages 12-16", "" ], [ 46 , "2016-08-05 10:00", "2016-08-05 16:00", "Tent north of Pavilion", "Ray Morits", "ATM Demo Hours", "" ], [ 46 , "2016-08-06 10:00", "2016-08-06 16:00", "Tent north of Pavilion", "Ray Morits", "ATM Demo Hours", "" ], [ 46 , "2016-08-05 10:00:01", "2016-08-05 10:30", "Tent north of Pavilion", "Ray Morits", "Intro & Rough Grinding", "Intro & Rough Grinding" ], [ 46 , "2016-08-06 10:00:01", "2016-08-06 10:30", "Tent north of Pavilion", "Ray Morits", "Intro & Rough Grinding", "Intro & Rough Grinding" ], [ 46 , "2016-08-05 10:30", "2016-08-05 11:00", "Tent north of Pavilion", "Rick Hunter", "Fine Grinding", "Fine Grinding" ], [ 46 , "2016-08-06 10:30", "2016-08-06 11:00", "Tent north of Pavilion", "Rick Hunter", "Fine Grinding", "Fine Grinding" ], [ 46 , "2016-08-05 11:00", "2016-08-05 13:30", "Tent north of Pavilion", "Junie Esslinger", "Making Dental Stone Tools", "Making Dental Stone Tools" ], [ 46 , "2016-08-06 11:00", "2016-08-06 11:30", "Tent north of Pavilion", "Junie Esslinger", "Making Dental Stone Tools", "Making Dental Stone Tools" ], [ 46 , "2016-08-05 11:30", "2016-08-05 12:00", "Tent north of Pavilion", "Phil Rounseville","Making Pitch Laps", "Making Pitch Laps" ], [ 46 , "2016-08-06 11:30", "2016-08-06 12:00", "Tent north of Pavilion", "Phil Rounseville","Making Pitch Laps", "Making Pitch Laps" ], [ 46 , "2016-08-05 13:00", "2016-08-05 14:00", "Tent north of Pavilion", "Dave Groski", "Polishing & Figuring", "Polishing & Figuring" ], [ 46 , "2016-08-06 13:00", "2016-08-06 14:00", "Tent north of Pavilion", "Dave Groski", "Polishing & Figuring", "Polishing & Figuring" ], [ 46 , "2016-08-05 14:00", "2016-08-05 16:00", "Mirror Lab Room in Pavilion", "Dave Kelly", "Testing (Bring your own mirror)", "Testing (Bring your own mirror)" ], [ 46 , "2016-08-06 14:00", "2016-08-06 16:00", "Tent north of Pavilion", "Ken Slater", "Dobsonian Basics", "Dobsonian Basics" ]; my $select = $db->prepare(<< '__SQL__'); SELECT item, time1, time2, location, who, note, extra FROM items INNER JOIN times ON items.link_id = times.link_id WHERE times.time1 LIKE "2016-08-06 %" ORDER BY times.time1 __SQL__ $select->execute; while (my @row = $select->fetchrow_array) { say join ' ', map $_ // '--', @row; } __END__ Numbers of occurrences: 1 Shuttle Bus Operates 2016-08-06 09:00 2016-08-06 17:00 Bus Stops Bus Stops: Pine Island, Food Tent, Pink Clubhouse 1 Scope Making For Teens 2016-08-06 11:00 2016-08-06 12:30 Bunkhouse "Stargazer" Steve Dodson Ages 12-16 1 Scope Making Demo 2016-08-06 14:00 2016-08-06 16:00 Tent north of Pavilion Ken Slater Dobsonian Basics Dobsonian Basics 1 Scope Making Demo 2016-08-06 13:00 2016-08-06 14:00 Tent north of Pavilion Dave Groski Polishing & Figuring Polishing & Figuring 1 Scope Making Demo 2016-08-06 11:30 2016-08-06 12:00 Tent north of Pavilion Phil Rounseville Making Pitch Laps Making Pitch Laps 1 Scope Making Demo 2016-08-06 11:00 2016-08-06 11:30 Tent north of Pavilion Junie Esslinger Making Dental Stone Tools Making Dental Stone Tools 1 Scope Making Demo 2016-08-06 10:30 2016-08-06 11:00 Tent north of Pavilion Rick Hunter Fine Grinding Fine Grinding 1 Scope Making Demo 2016-08-06 10:00 2016-08-06 16:00 Tent north of Pavilion Ray Morits ATM Demo Hours 1 Scope Making Demo 2016-08-06 10:00:01 2016-08-06 10:30 Tent north of Pavilion Ray Morits Intro & Rough Grinding Intro & Rough Grinding 1 Registration Gate 2016-08-06 07:00 2016-08-06 19:00 Entry Gate Hours