#!/usr/bin/perl use warnings; use strict; do { $_ = <> } until /Bus Timetable/; <> for (1..3); # skip titles 3 lines while (<>) { last if /^\+/; my ($from, $dept, $to, $arr) = unpack('x23a4x2a4x3a4x1a4', $_); s/\s+//g for ($from, $dept, $to, $arr); print "$from$dept:$to$arr\n"; }