in reply to Sort path strings by component count.

Don't use split to count:
@paths = sort { $b =~ y/\\// <=> $a =~ y/\\// } @paths;

Caution: Contents may have been coded under pressure.