CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [Siei] Question with a simple disk walking script: Edit Log



BillKSmith
Veteran

May 1, 2013, 5:23 AM


Views: 764
Re: [Siei] Question with a simple disk walking script

I recommend that you test for the success of opendir and report failures. The symptoms that you describe are consistent with its failure.

Code
opendir (my $dh, $dir) or die "Cannot open $dir:$!";


There are several other minor problems:

  • You must escape the dot in your test for special directories.

    Code
    @objs = grep(!/^\.{1,2}$/, @objs);



  • You should not be using prototypes in your subroutine. They do not do what you think! In fact, you have them specified wrong.

    Code
    sub dirwork



  • You should not be using the "&" in your subroutine calls. The biggest thing it does is hide the previous problem.

    Code
    ($total_size, $timemodified, $filename) 
    = dirwork( $dir, $total_size, $timemodified, $filename );



  • UPDATE:
    Added corrected code.
    Removed erroneous comment
    Good Luck,
    Bill

    (This post was edited by BillKSmith on May 1, 2013, 10:08 AM)


    Edit Log:
    Post edited by BillKSmith (Veteran) on May 1, 2013, 10:08 AM


    Search for (options) Powered by Gossamer Forum v.1.2.0

    Web Applications & Managed Hosting Powered by Gossamer Threads
    Visit our Mailing List Archives