in reply to Re: Hi Monks could you pls help Perl dummy user
in thread Hi Monks could you pls help Perl dummy user
I used strict and warnings but it doesn't go into any other directories other than current. Thus recursion doesn't work correctly i guess. Could you pls help me tofix it now?
#!/usr/bin/perl # #Author: Yury Sibirski #Name: users_home_dir #Date: 16 December 2014 #Purpose: This program analyze the directory structure of a Linux disk + and identify any files larger than 500 kbytes # use strict; use warnings; my $path = shift || '.'; read_dir($path); sub read_dir { my $dir = shift; opendir (my $DH, $dir) or die "Couldn't open current directory +: $!"; while (my $file = readdir($DH)) {#print "$file\n"; if ($file eq "." or $file eq "..") { next; } elsif (-z $file) { next; } elsif (-r $file and -f $file) { my $size = -s $file; print $file," ",$size, "\n" if $size > 200; } elsif (-d $file) { read_dir($file); } } closedir $DH; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Hi Monks could you pls help Perl dummy user
by LanX (Saint) on Dec 17, 2014 at 01:46 UTC | |
by sibyurik (Novice) on Dec 17, 2014 at 01:50 UTC | |
by LanX (Saint) on Dec 17, 2014 at 02:06 UTC |