BEGIN { print "digraph map {"; } /^. / { output_edge(); location = destination = ""; } $1 == "location" { location = $2; } $1 == "destination" { destination = $2; } $1 == "prospect" { prospect = $2; } END { output_edge(); print "}"; } function output_edge() { if (location && destination) print "\t" location " -> " destination; if (location && prospect) print "\t" location " -> " prospect " [style=dashed]"; }