in reply to pattern matching problem

Something like this might work.

use strict; use warnings; while(<>) { chop; my($id) = /\\\\.+\\(.+)/; print "$id\n" if($id); }

In the regular expression I use ()'s to group and capture, then because I used ()'s on the my, it puts a list context onto the assignment and so the RE returns a list of the captured values. In this case the first captured element returned is assigned to $id. I then use $id normally to print out the ID if the RE matched. On a non match $id is undef.

I tested with a tiny test case of:

\\domca-prn01\DH4-2139-HP4 \\vlasd \\\dsasd \test\ing

Only the identifier from the first line of the test file is output.