[26885] in Perl-Users-Digest
Perl-Users Digest, Issue: 8882 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 24 18:05:53 2006
Date: Tue, 24 Jan 2006 15:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 24 Jan 2006 Volume: 10 Number: 8882
Today's topics:
File::Find::Rule for files younger than 24 hours <nomail@sorry.com>
Re: File::Find::Rule for files younger than 24 hours <glex_no-spam@qwest-spam-no.invalid>
Re: File::Find::Rule for files younger than 24 hours <rvtol+news@isolution.nl>
Re: File::Find::Rule for files younger than 24 hours <jgibson@mail.arc.nasa.gov>
Re: File::Find::Rule for files younger than 24 hours (Randal L. Schwartz)
Re: File::Find::Rule for files younger than 24 hours <nomail@sorry.com>
Re: Window control program help needed Jan. 24, 2006 <edgrsprj@ix.netcom.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 24 Jan 2006 11:35:43 -0800
From: Arvin Portlock <nomail@sorry.com>
Subject: File::Find::Rule for files younger than 24 hours
Message-Id: <dr5vil$1lu7$1@agate.berkeley.edu>
I'm trying to use File::Find::Rule to get files modified in
the last 24 hours. With the help of find2perl I got a plain
File::Find to work just fine, but File::Find is pretty horrible
so I'd prefer File::Find::Rule. This is on a Windows 2000
system:
My working File::Find version:
use File::Find;
my $rootdir = 'D:/MYDOCU~1/schema_validate';
File::Find::find({wanted => \&since_yesterday}, $rootdir);
sub since_yesterday {
my ($dev,$ino,$mode,$nlink,$uid,$gid);
(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
(int(-M _) < 1)
&& print("$File::Find::name\n");
}
My not-working File::Find::Rule version:
use File::Find::Rule;
my $rootdir = 'D:/MYDOCU~1/schema_validate';
my @files = File::Find::Rule->file()
->name( '*.pl' )
->mtime ("-1")
->in($rootdir);
foreach my $file (@files) {
print "$file\n";
}
I've actually tried a variety of things for the mtime() method
but either get nothing or I get everything. It's not clear to
me how to apply mtime() here.
Arvin
------------------------------
Date: Tue, 24 Jan 2006 14:30:10 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: File::Find::Rule for files younger than 24 hours
Message-Id: <n7wBf.85$EG3.2852@news.uswest.net>
Arvin Portlock wrote:
> use File::Find::Rule;
>
> my $rootdir = 'D:/MYDOCU~1/schema_validate';
>
> my @files = File::Find::Rule->file()
> ->name( '*.pl' )
> ->mtime ("-1")
> ->in($rootdir);
> foreach my $file (@files) {
> print "$file\n";
> }
>
> I've actually tried a variety of things for the mtime() method
> but either get nothing or I get everything. It's not clear to
> me how to apply mtime() here.
The value for mtime is the time the file was modified, in seconds. So
figure out the current number of seconds, minus 1 day, of seconds.
my $today = time();
my $days_ago = $today - 86400; #seconds in a day
my @files = File::Find::Rule->file()
->name( '*.pl' )
->mtime (">$days_ago")
->in($rootdir);
The documentation could probably add a few more examples.
------------------------------
Date: Tue, 24 Jan 2006 21:27:00 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: File::Find::Rule for files younger than 24 hours
Message-Id: <dr66qj.194.1@news.isolution.nl>
Arvin Portlock schreef:
> my @files = File::Find::Rule->file()
> ->name( '*.pl' )
> ->mtime ("-1")
> ->in($rootdir);
http://www.perladvent.org/2002/11th/
does it like this:
my $last_week = time()-7*24*60*60;
my @files = File::Find::Rule->file
->name('*.mp3')
->size('>=200K')
->mtime("<$last_week")
->in('/home/mark/mp3');
but from `perldoc -f -M` I guess that should be ->mtime('>7').
I would expect '<1' to mean '<24h', but maybe the unit is exclusively
"seconds since epoch", like with stat.
See also File::Finder::Steps.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Tue, 24 Jan 2006 13:12:25 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: File::Find::Rule for files younger than 24 hours
Message-Id: <240120061312257227%jgibson@mail.arc.nasa.gov>
In article <dr5vil$1lu7$1@agate.berkeley.edu>, Arvin Portlock
<nomail@sorry.com> wrote:
> I'm trying to use File::Find::Rule to get files modified in
> the last 24 hours. With the help of find2perl I got a plain
> File::Find to work just fine, but File::Find is pretty horrible
> so I'd prefer File::Find::Rule. This is on a Windows 2000
> system:
What about File::Find do you find "horrible?" You at least got it
working!
> My working File::Find version:
>
> use File::Find;
> my $rootdir = 'D:/MYDOCU~1/schema_validate';
> File::Find::find({wanted => \&since_yesterday}, $rootdir);
>
> sub since_yesterday {
> my ($dev,$ino,$mode,$nlink,$uid,$gid);
>
> (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
> (int(-M _) < 1)
> && print("$File::Find::name\n");
> }
Since you don't use any of the $dev,...,$gid, you could shorten the
above to:
File::Find::find(
sub { lstat $_; print "$_\n" if (-M _) < 1},
$rootdir );
>
> My not-working File::Find::Rule version:
>
> use File::Find::Rule;
>
> my $rootdir = 'D:/MYDOCU~1/schema_validate';
>
> my @files = File::Find::Rule->file()
> ->name( '*.pl' )
> ->mtime ("-1")
> ->in($rootdir);
> foreach my $file (@files) {
> print "$file\n";
> }
>
> I've actually tried a variety of things for the mtime() method
> but either get nothing or I get everything. It's not clear to
> me how to apply mtime() here.
mtime() returns absolute modification time in seconds. -M returns
difference between modification time and time script started ($^T) in
days. So you need to test mtime against 86400 seconds before $^T, and
the test should be greater-than, not just equality:
my $yesterday = $^T - 86400;
my @files = File::Find::Rule->file()
->name( '*.pl' )
->mtime (">$yesterday")
->in($rootdir);
Note that File::Find::Rule does not seem to have any ability to test
the link rather than the file to which the link is pointing.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: 24 Jan 2006 13:21:23 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: File::Find::Rule for files younger than 24 hours
Message-Id: <86lkx52ugc.fsf@blue.stonehenge.com>
>>>>> "Arvin" == Arvin Portlock <nomail@sorry.com> writes:
Arvin> my @files = File::Find::Rule->file()
Arvin> -> name( '*.pl' )
Arvin> -> mtime ("-1")
Arvin> -> in($rootdir);
Arvin> foreach my $file (@files) {
Arvin> print "$file\n";
Arvin> }
In File::Finder, that'd be:
my @files = File::Finder
->name('*.pl')
->mtime('-1')
->in($rootdir);
File::Finder uses find(1) primitives, which I find easier to understand
than File::Find::Rule's mix of find(1) and ad-hoc constructs.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Tue, 24 Jan 2006 14:12:04 -0800
From: Arvin Portlock <nomail@sorry.com>
Subject: Re: File::Find::Rule for files younger than 24 hours
Message-Id: <dr68nq$1p2a$1@agate.berkeley.edu>
Arvin Portlock wrote:
> I'm trying to use File::Find::Rule to get files modified in
> the last 24 hours.
> My not-working File::Find::Rule version:
>
> use File::Find::Rule;
>
> my $rootdir = 'D:/MYDOCU~1/schema_validate';
>
> my @files = File::Find::Rule->file()
> ->name( '*.pl' )
> ->mtime ("-1")
> ->in($rootdir);
> foreach my $file (@files) {
> print "$file\n";
> }
This thread has become very interesting for me. Thanks for
all the input. One interesting thing that was causing me
problems and contributed to my overall confusion vis-à-vis
mtime () was that my program wouldn't work if I included
the program's directory in the search path. Something odd
happens when the program attempts to retrieve itself in
the list of files. No error message, I would simply get no
results. I didn't notice this problem until a few minutes
ago, so was trying a wide variety of crazy things to get
it to work. A few evals done early might have revealed
the problem.
Might be a Windows-specific problem.
------------------------------
Date: Tue, 24 Jan 2006 22:33:34 GMT
From: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Re: Window control program help needed Jan. 24, 2006
Message-Id: <2XxBf.5856$vU2.1069@newsread3.news.atl.earthlink.net>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
news:Xns975583A43D442asu1cornelledu@127.0.0.1...
> > 1. I would like Perl to send characters etc. to the Windows operating
> > system as if the instructions were being entered from the keyboard.
>
> http://search.cpan.org/search?query=sendkeys
>
Thanks for the information.
I was able to download Win32-GuiTest from that Web site and somehow got it
installed without really understanding what I was doing. And its SendKeys()
command does actually do what is needed.
Goal # 2 has to do with redirecting input from the keyboard.
If Perl is the active window then
$word = readline STDIN;
will pull in a character or word from the keyboard after you hit the ENTER
key.
However if a text file for example is the active window and you enter
anything on the keyboard then the text will print directly to the screen in
the text file window.
There is probably some Perl routine which can direct keyboard input to be
sent to a Perl program even though a text file window is the one you are
looking at. So, if something were typed in, nothing would appear on the
screen unless the Perl program used the SendKeys() command to print the text
to the screen.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 8882
***************************************