Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

blahblah's scratchpad

by blahblah (Friar)
on Jun 05, 2004 at 11:38 UTC ( #361480=scratchpad: print w/ replies, xml ) Need Help??

for ikegami:
sub process_branch { # this sub is infinitely recursive - it calls itself sometimes! local $branch = $_[0]; if (ref $branch eq 'SCALAR') { crapout("All branches must end in a piece of sub code, not a SCA +LAR\n$global->{breadcrumbs}"); } elsif (ref $branch eq 'ARRAY') { crapout("All branches must end in a piece of sub code, not an AR +RAY\n$global->{breadcrumbs}"); } elsif (ref $branch eq 'HASH') { foreach my $nextbranch (keys %{$branch}) { # process special keywords if ($nextbranch eq 'directory') { # look +for a single directory here my @dirs = list_of_dirs_here($global->{thisdirfull}); if (@dirs > 1) { # is th +ere more than one directory here? crapout("Invalid tree structure defined.\nYou specified + a single directory at $global->{thisdir}\nbut there is more than one + directory here\+nPerhaps use foreachdir?"); } elsif (@dirs == 0) { crapout("Invalid tree structure defined.\nYou specified + a single directory at $global->{thisdir}\nbut there are no directori +es here"); } else { $global->{breadcrumbs} .= " -> directory ($dirs[0])"; $global->{thisdirfull} .= "/$dirs[0]"; $global->{thisdir} = $dirs[0]; printlog("*=====Traversing: $global->{breadcrumbs}\n"); process_branch($branch->{$nextbranch}); } } else { # no keywords - process regular $global->{breadcrumbs} .= " -> $nextbranch"; $global->{thisdirfull} .= "/$nextbranch"; $global->{thisdir} = $nextbranch; if (!-e "$global->{thisdirfull}" || !-d "$global->{thisdir +full}") { crapout("The directory $global->{thisdirfull}\ndoesn't +exist or is not a directory"); } printlog("**====Traversing: $global->{breadcrumbs}\n"); process_branch($branch->{$nextbranch}); } } } elsif (ref $branch eq 'GLOB') { crapout("All branches must end in a piece of sub code, not a GLO +B\n$global->{breadcrumbs}"); } elsif (ref $branch eq 'REF') { crapout("All branches must end in a piece of sub code, not a REF +\n$global->{breadcrumbs}"); } elsif (ref $branch eq 'CODE') { debug("Preparing to execute the code at\nbranch: $global->{bread +crumbs}\ncurrent directory: $global->{thisdirfull}") if $global->{deb +ug}; $branch->(); } else { crapout("All tree branches must end in a piece of sub code, not +values.\nThe $global->{breadcrumbs} branch ends with the value $branc +h"); } }
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2015-07-05 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (68 votes), past polls