MajingaZ has asked for the wisdom of the Perl Monks concerning the following question:
Update: I changed the .+? to [^\\]+ to be more self documenting as that is what I'm actually expecting but was relying on the greediness on .+ and laziness on .+? to get what I wanted, so this makes it easier to read.my $BMinus = substr ($B, 0, (index ($B,&CheckFile(\$A,$B)) - 1)); sub CheckFile { my ($P_ref,$T) = @_; &CrawlForward($P_ref,\$T); while (!(-s "$$P_ref\\$T") || (-s $T)) { $$P_ref =~ s/\A(.+)\\[^\\]+\z/$1/; &CrawlForward($P_ref,\$T); } return $T; } sub CrawlForward { my ($C_ref,$T_ref) = @_; my $FHold = $$T_ref; while (!-s "$$C_ref\\$$T_ref") { unless ($$T_ref =~ s/\A[^\\]+\\(.+)\z/$1/) { $$T_ref = $FHold; last; } } return 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Merge a UNC Dir with a Mapped File
by roboticus (Chancellor) on Jul 28, 2010 at 23:25 UTC |