in reply to Extract data from next n-th line

This should get you started:
use strict; use warnings; my $station; my %params; while (<DATA>) { if (/^(\w{2,})/) { $station = $1; } elsif (/^(\w)\s+(\d+)/) { $params{$1} = $2; } else { print "$station @params{qw(N E U)}\n"; } } __DATA__ GRAZ X 4 Y 6 Z 3 N 22 E 3 U 15 KIGB X 2 Y 6 Z 6 N 13 E 20 U 11