tachyon, that is fine and dandy and I appreciate the code :) but I am more into figuring out why the problem exists, therefore I can better appreciate the solution to the problem.
dir_search(*D,"$path$cont");
this seems to be where all the trouble lies, everything previous to this line works as expected. Actually the whole script runs without errors under perl -c it just doesn't do the recursion that I was expecting.
To clarify what I'm asking:
I want to know why my code doesn't work :)
#!/usr/bin/perl -w
#
##
use strict;
my $Spath='/home/s0ttlen/';
opendir(H, "$Spath")|| die "Error:$!\n";
dir_search(*H,"$Spath");
sub dir_search{
local(*ROOT)=$_[0];
my $path=$_[1];
my $cont;
foreach $cont (sort readdir(ROOT)){
next if $cont eq '.' or $cont eq '..';
next if -l "$path$cont";
if (-f "$path$cont"){
&log("$path$cont") if (-T "$path$cont" || -u "$path$cont");
}
elsif (-d "$path$cont" && opendir(D,"$path$cont")) {
dir_search(*D,"$path$cont");
}
}
}
sub log{
my $file=$_[0];
my $log='/home/s0ttlen/log/slog';
open(LOG,">>$log")|| die "Error:$!\n";
print LOG "$file\n";
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.