sub fexist($) { my $str = shift; for (glob qq("$str")) { return 3 if -l "$_"; return 2 if -d "$_"; return 1 if -f "$_"; } return 0; }