in reply to Sort path strings by component count.
@paths = sort { $b =~ tr/\\// <=> $a =~ tr/\\// } @paths; [download]
By the way, <=> will force a scalar context, so scalar is not needed.