Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

@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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-25 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found