use strict; use warnings; while(<>) { chop; my($id) = /\\\\.+\\(.+)/; print "$id\n" if($id); } #### \\domca-prn01\DH4-2139-HP4 \\vlasd \\\dsasd \test\ing