in reply to re-calling called functions

how about:

sub DIRUtil { my $self = shift; my $caller; $caller = shift if ref $_[0]; my ($path, $dirname, $option) = @_; while ($option eq "-c") { print $path."\n"; chdir($path) or next; mkdir ("xxx") or next; return; } continue { # failure handling $caller->() if $caller; return; } }

and

sub caller { $other->DIRUtil (&caller, ...); }

Of course the failure handling in DIRUtil needs to exit early if directory creation failed.

BTW, $Utils = new Tools; is an error and the quoting in "D:/\box/\/\somthing/\SB" is bogus. /'s don't need to be quoted and as written it is the following letter that is needlessly quoted in any case. Using strictures (use strict; use warnings;) would pick up at least some of these problems for you.


DWIM is Perl's answer to Gödel