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; }
In reply to Re^2: Hi Monks could you pls help Perl dummy user
by sibyurik
in thread Hi Monks could you pls help Perl dummy user
by sibyurik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |