#!/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---