in reply to Extract data from next n-th line

$ echo "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 " | perl -e' $/ = ""; $\ = "\n"; print "station N E U"; while ( <> ) { + print join " ", /\A(\S+)(?=.*^N\s+(\d+))(?=.*^E\s+(\d+))(?=.*^U\s+ +(\d+))/sm; } ' station N E U GRAZ 22 3 15 KIGB 13 20 11