in reply to Extract data from next n-th line
local $/ = ""; while (<>) { my ($station, %fields) = /(\S+)/g; print(join(' ', $station, @fields{qw( N E U )}), "\n"); }
Or if the values can contain whitepace,
local $/ = ""; while (<>) { my $station = s/^(\S+)\s+// ? $1 : undef; my %fields = /(\S+)\s+([^\n]*)\n/g; print(join(' ', $station, @fields{qw( N E U )}), "\n"); }
|
|---|