use warnings; use strict; while () { chomp; if (/(\) | \.sta \)?) $/x) { print "Skipping $_\n"; next; } if (! m{ .* \\(\w+) # Get first file name [^\[]* \[ [^\]]* \] \s* # skip to date time string ([^-]*) # Everything up to the hyphen \d+/ .* \\ # skip to the last file name ([^.]*) # Grab file name excluding extension }x ) { print "No match: $_\n"; next; } my ($first, $datetime, $last) = ($1, $2, $3); print "Extracted $first, $datetime, $last\n"; } __DATA__ e:\logfiles\mylocationbase.log [3] Mon 13Mar06 11:00:25 - (000558) Sending file d:\data\18bn5489.dat e:\logfiles\mylocationbase.log [3] Mon 13Mar06 11:00:31 - (000558) Sent file d:\data\18bn5489.dat successfully (169 Kb/sec 1049600 bytes) e:\logfiles\mylocationbase.log [3] Mon 13Mar06 11:00:32 - (000558) Sending file d:\bnsf_data\18bn5489.sta