use strict; use warnings; my $f1 = 'z:\proj\proj'; my $f2 = '\\192.168.1.3\server\proj\proj.ext'; my $s1 = substring($f1); my $s2 = substring($f2); if ($s1 eq $s2) { print "Matched $s1\n"; } else { print "Main bus B undervolt - $s1 <> $s2\n"; } sub substring { my $file = shift; my $back = rindex($file, "\\"); my $dot = rindex($file, "."); if ($dot > $back) { return substr($file, $back + 1, $dot -$back - 1); } else { return substr($file, -(length($file) -1 -$back)); } }