use strict; use warnings; while (<>) { chomp; next if /^\s*$/; if (/^(\S+):(\d+)\s*(\d+)$/) { my ($host, $port, $size) = ($1, $2, $3); print qq/{"hostname":"$host","port":$port,"size":$size}\n/; } else { die "Syntax error: Line $.: $_\n"; } }