in reply to dir match, dir may or may not appear
$path =~ m|^usr/(?:/[^/]+)?/bin/| [download]
As a general thing don't use | as a regex delimiter because it is the alternation (or) character. It allows you to match cat or dog m~cat|dog~ for example.