use strict; use warnings; open (HANDLE, 'C:\username\Sources') || die; $_ = join '', ; my $c = () = m/\\/g; print "Found $c matches!";