@dHarry, @tirwhan: Sorry for my mistake. I joined the forum today and was expecting that there will be an option to upload my code file directly. I couldn't find it. Discovered the tags later. Anyway, here's my code. (I have given the whole code so that exact mistake can be pointed out)

$, = "\t\t"; sub del { my $p = shift; my $days = shift; print $p; opendir ($dh, $p) || die "Some error: $!"; @flist = readdir($dh); closedir $dh; print "\nThe list of files is: \n"; foreach(@flist) { print "\n$_"; } my %list = (); foreach(@flist) { if(-f $_) { $list{$_}; $list{$_} = -M $_; } } print "\n\nList of all files with last modified (no. of days ago)\ +n"; foreach $si (keys %list) { print $si ,"------------->",$list{$si}; print "\n"; } print "\n\n\n"; print "\nList of files modified less than $days days ago\n"; foreach $si (keys %list) { if($list{$si} < $days) { print $si ,"------------->",$list{$si}; print "\n"; } } } &del ("D:/perlnew/ex/comp", 5); #*********************************************************** #Directory listing through command line: Directory of D:\perlnew\ex\comp 09/23/2010 02:48 PM <DIR> . 09/23/2010 02:48 PM <DIR> .. 08/30/2010 05:56 PM 377 a.txt 09/24/2010 11:56 AM 28 as.txt 09/24/2010 11:55 AM 20 blah.txt 09/23/2010 10:48 AM 38,056 Dumper.pl 09/23/2010 10:49 AM 38,056 Dumper.pm 09/23/2010 11:32 AM 604 ex_47.pl 09/14/2010 11:23 AM 1,591 ex_54FINAL.pl 09/02/2010 01:37 PM 2,081,634 perltut.pdf 09/14/2010 11:10 AM 1,938 prac14.pl 09/14/2010 10:47 AM 160 prac15.pl 09/21/2010 04:11 PM 216 prac16.pl 09/23/2010 10:49 AM 628 prac17.pl 09/24/2010 11:55 AM 20 q.txt 09/24/2010 11:55 AM 23 qw.txt 09/24/2010 11:55 AM 16 qwe.txt 09/24/2010 11:55 AM 25 qwer.txt 09/24/2010 11:55 AM 18 qwert.txt 17 File(s) 2,163,410 bytes 2 Dir(s) 52,993,323,008 bytes free #************************************************************** #OUTPUT OF PROGRAM: D:/perlnew/ex/comp The list of files is: . .. a.txt as.txt blah.txt Dumper.pl Dumper.pm ex_47.pl ex_54FINAL.pl perltut.pdf prac14.pl prac15.pl prac16.pl prac17.pl q.txt qw.txt qwe.txt qwer.txt qwert.txt List of all files with last modified (no. of days ago) prac17.pl -------------> 1.1802662037037 Dumper.pl -------------> 1.18054398148148 prac16.pl -------------> 2.95675925925926 prac14.pl -------------> 10.1655902777778 prac15.pl -------------> 10.1818171296296 ex_54FINAL.pl -------------> 10.1564699074074 ex_47.pl -------------> 1.15052083333333 Dumper.pm -------------> 1.17990740740741 List of files modified less than 5 days ago prac17.pl -------------> 1.1802662037037 Dumper.pl -------------> 1.18054398148148 prac16.pl -------------> 2.95675925925926 ex_47.pl -------------> 1.15052083333333 Dumper.pm -------------> 1.17990740740741

When I use (!-d $_) to identify files, .txt, .pdf files are printed, but their last modified (no. if days) is not printed.


In reply to Re^2: -f not identifying .txt files by rucha
in thread -f not identifying .txt files by rucha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.