drodinthe559 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w #use strict; use File::Find; use File::stat; my @results; my $ext = "A"; find(\&search, "c:/test"); sub search { if ($_ =~ m/ACH/ ) { push @results, [$_, stat($_)->mtime, stat($_)->size]; } } @results = sort { $a->[1] <=> $b->[1]} @results; foreach my $x (@results){ rename ($x->[0], "USB" . $ext); print $x->[0] . "\t" . localtime($x->[1]) . $x->[0]->size ."\n"; ++$ext; } my @temp; find(\&post, "c:/test"); sub post { if ($_ =~ m/USB/ ) { push @temp, [$_, stat($_)->mtime]; } } foreach my $y (@temp) { print $y->[0] . "\t" . localtime($y->[1]) . "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Script Critique
by toolic (Bishop) on Jul 21, 2008 at 01:40 UTC | |
|
Re: Script Critique
by ikegami (Patriarch) on Jul 21, 2008 at 01:59 UTC | |
|
Re: Script Critique
by kyle (Abbot) on Jul 21, 2008 at 02:07 UTC | |
by drodinthe559 (Monk) on Jul 21, 2008 at 04:07 UTC | |
|
Re: Script Critique
by GrandFather (Saint) on Jul 21, 2008 at 01:56 UTC | |
by ikegami (Patriarch) on Jul 21, 2008 at 02:02 UTC | |
|
Re: Script Critique
by leocharre (Priest) on Jul 23, 2008 at 01:55 UTC |