USING: arrays assocs io.encodings.utf8 io.files kernel pcre sequences shuffle ; IN: nmap-parser : parse-line ( port-data current-ip line -- port-data' current-ip' ) dup "\\((\\d+.\\d+.\\d+.\\d+)\\)" findall [ "(\\d+)/tcp (open|filtered)" findall [ first second second spin [ push-at ] 2keep swap ] unless-empty ] [ nip first second second nip ] if-empty ; : parse-output ( filename -- port-data ) utf8 file-lines { H{ } f } [ [ first2 ] dip parse-line 2array ] reduce first ;