while ($file_content =~ m{dp/(.\d+?)}g) { # we have to omit the \z print "Found one: $1\n"; }