#!/usr/bin/perl use strict; use warnings; my $template = 'x2A4A8A4A3x2A6A5x2A5A5x2A4'; my ($bus,$service,$day,$time,$from,$departure,$to,$arrival,$avail); while () { next if m/^\+/; next unless /^|/; ($bus,$service,$day,$time,$from,$departure,$to,$arrival,$avail) = unpack($template,$_); next unless $bus =~ /[A-Z]\d/; print "Bus $bus of the $service service, arrives at $to at $arrival, from $from, leaving at $departure on $day. ($avail)\n"; } __DATA__ ---TEXT BEFORE--- +---------------+ | Bus Timetable | +---------------+----+------------+-----------+------+ | BUS SERVICE DAY tm | FROM DEPT | TO ARR | 24/7 | +--------------------+------------+-----------+------+ | C4 metro mon 15 | twn 0900 | Apt 1011 | yes | | C6 intl mon 45 | LDN 1000 | XTR 1426 | no | | B2 susx mon 20 | cly 1034 | btn 1118 | no | | A0 xxxxx xxx xx | xxx xxxx | xxx xxxx | xxx | +--------------------+------------+-----------+------+ ---TEXT AFTER--- #### Bus C4 of the metro service, arrives at Apt at 1011, from twn, leaving at 0900 on mon. (yes) Bus C6 of the intl service, arrives at XTR at 1426, from LDN, leaving at 1000 on mon. (no) Bus B2 of the susx service, arrives at btn at 1118, from cly, leaving at 1034 on mon. (no) Bus A0 of the xxxxx service, arrives at xxx at xxxx, from xxx, leaving at xxxx on xxx. (xxx)