Thanks for the correction.
This points me into the right direction, checking conventions of dirfunc() return values.
I'm having problems though to get it to work when $filter is applied.
Sorry I completely ignored the $filter code segment, but it appears the
$filter is going to suffer from the same fate as the
previously discussed code did. The variables need to be
passed in and better contained to avoid problems.
That said, if this is a simple one time utility script,
you can get away with the globals, but it is a dangerous
practice.