Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 chanting in the Monastery: (9)
As of 2014-08-02 01:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (53 votes), past polls