in reply to remove files starting with white from its folders and sub folders using perl?

if ($d1 =~ /^white*/)

This matches any string consisting of 'whit' at the beginning followed by zero or more 'e' characters. Probably not what you wanted.

perl -Mstrict -WE ' say "`$_` " . ( $_ =~ /^white*/ ? "match" : "no match" ) for ("while", "whine", "white", "whitf", "whit ", "whit!", "whit") +; '
`while` no match `whine` no match `white` match `whitf` match `whit ` match `whit!` match `whit` match

Hope this helps!


The way forward always starts with a minimal test.