If you want 4 character towns, change the unpack line to this:
my ($from, $dept, $to, $arr) = unpack('x23a4x2a4x3a4x1a4', $_);
unpack is different from regular expressions. The xn skips over characters, the an captures the character string:
x23: skip 23 characters
a4: get 4 characters
x2: skip 2
a4: get 4
...
The 4 a4 unpack directives capture the 4 parts of the string you are interested in.
Add this to strip the extra spaces:
s/\s+//g for ($from, $dept, $to, $arr);
Here's the whole thing:
|