Re: Transform my algorithm in perl. Ideas?
On Wed, 05 Sep 2007 14:56:27 +0200, Shams Fantar wrote: > Gunnar Hjalmarsson wrote: >> Shams Fantar wrote: >>> Gunnar Hjalmarsson wrote: opendir my $d, $dir or die $!; my @oldfiles = grep -f "$dir/$_" && -M _ > 10, readdir $d; if ( @oldfiles ) { # do something } >>> >>> Thank you for this solution, but I would prefer to write it myself. ;-) >> >> Well, that was an ... unexpected response. ;-) > > Sorry for my answer, it was not nasty. :P As I'm a beginner with perl, I > prefer to write my scripts myself. Gunnar's reply was a compliment. The part of his response that answers your question is the -M _ > 10 clause. Look up the -M operator with "perldoc -f -X". -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Transform my algorithm in perl. Ideas?
Gunnar Hjalmarsson wrote: Shams Fantar wrote: Gunnar Hjalmarsson wrote: opendir my $d, $dir or die $!; my @oldfiles = grep -f "$dir/$_" && -M _ > 10, readdir $d; if ( @oldfiles ) { # do something } Thank you for this solution, but I would prefer to write it myself. ;-) Well, that was an ... unexpected response. ;-) Sorry for my answer, it was not nasty. :P As I'm a beginner with perl, I prefer to write my scripts myself. -- Shams Fantar (http://snurf.info) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Transform my algorithm in perl. Ideas?
Shams Fantar wrote: Gunnar Hjalmarsson wrote: opendir my $d, $dir or die $!; my @oldfiles = grep -f "$dir/$_" && -M _ > 10, readdir $d; if ( @oldfiles ) { # do something } Thank you for this solution, but I would prefer to write it myself. ;-) Well, that was an ... unexpected response. ;-) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Transform my algorithm in perl. Ideas?
Tom Phoenix wrote: On 9/4/07, Shams Fantar <[EMAIL PROTECTED]> wrote: The mtime, atime and ctime functions don't exist in the perl documentation, normal? :) That's right. In Perl, we access those three timestamps in more than one way, but normally not by a function with the same name. The most common way to access a timestamp is with the filetest operators, -M, -A, and -C. These are documented (under -X) in the perlfunc manpage. http://perldoc.perl.org/perlfunc.html The other common place to find the three timestamps is in the return value from the stat() function. That's also documented in perlfunc. Hope this helps! --Tom Phoenix Stonehenge Perl Training I'm going to see that. I keep you informed for my perl script. :-) -- Shams Fantar (http://snurf.info) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Transform my algorithm in perl. Ideas?
yitzle wrote: On 9/4/07, Shams Fantar <[EMAIL PROTECTED]> wrote: The mtime, atime and ctime functions don't exist in the perl documentation, normal? :) Without documentation, I cannot use mtime... Regards, -- Shams Fantar (http://snurf.info) You retrive those values uses the stat command perldoc -f stat http://perldoc.perl.org/functions/stat.html Okay, thank you for this information. -- Shams Fantar (http://snurf.info) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Transform my algorithm in perl. Ideas?
On 9/4/07, Shams Fantar <[EMAIL PROTECTED]> wrote: > The mtime, atime and ctime functions don't exist in the perl > documentation, normal? :) That's right. In Perl, we access those three timestamps in more than one way, but normally not by a function with the same name. The most common way to access a timestamp is with the filetest operators, -M, -A, and -C. These are documented (under -X) in the perlfunc manpage. http://perldoc.perl.org/perlfunc.html The other common place to find the three timestamps is in the return value from the stat() function. That's also documented in perlfunc. Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Transform my algorithm in perl. Ideas?
Gunnar Hjalmarsson wrote: Shams Fantar wrote: Here is the algorithm : "If there is a file in this directory which is old likewise of 10 days, to delete it or else, do nothing." Do you have ideas to say "If there is a file which is old likewise of 10 days" in perl? opendir my $d, $dir or die $!; my @oldfiles = grep -f "$dir/$_" && -M _ > 10, readdir $d; if ( @oldfiles ) { # do something } Thank you for this solution, but I would prefer to write it myself. ;-) -- Shams Fantar (http://snurf.info) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Transform my algorithm in perl. Ideas?
Tom Phoenix wrote: On 9/3/07, Shams Fantar <[EMAIL PROTECTED]> wrote: Do you have ideas to say "If there is a file which is old likewise of 10 days" in perl? There are three timestamps that can mean the age of a file: the mtime, atime, and ctime. If you want to know how old the data in the file is, that's the mtime, or modification time. That's usually the one people mean when they talk about the age of a file, but Perl can also access the other timestamps. The usual way to access the mtime is with the -M operator, which returns the age as measured in days. my $filename = "fred"; warn "The file is at least one day old!" if -M $filename > 1; If you need to delete some file, you can do that with the unlink operator. Both unlink and -M are documented in the perlfunc manpage. http://perldoc.perl.org/perlfunc.html Does that get you closer to what you need? Good luck with it! --Tom Phoenix Stonehenge Perl Training The mtime, atime and ctime functions don't exist in the perl documentation, normal? :) Without documentation, I cannot use mtime... Regards, -- Shams Fantar (http://snurf.info) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Transform my algorithm in perl. Ideas?
On 9/3/07, Ken Foskey <[EMAIL PROTECTED]> wrote: > On Mon, 2007-09-03 at 21:56 +0200, Shams Fantar wrote: > > Hi ! > > > > I have a problem at which I have no solution. > > > > Here is the algorithm : > > > > "If there is a file in this directory which is old likewise of 10 days, > > to delete it or else, do nothing." > > > > Do you have ideas to say "If there is a file which is old likewise of 10 > > days" in perl? > > Please post what you have done and we can help, otherwise there are many > sites on the Internet to hire a contractor for a small job. > > -- > Ken Foskey > FOSS developer Likewise, the describe software already exists in freeware form. I recall seeing something similar not too long ago... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Transform my algorithm in perl. Ideas?
On Mon, 2007-09-03 at 21:56 +0200, Shams Fantar wrote: > Hi ! > > I have a problem at which I have no solution. > > Here is the algorithm : > > "If there is a file in this directory which is old likewise of 10 days, > to delete it or else, do nothing." > > Do you have ideas to say "If there is a file which is old likewise of 10 > days" in perl? Please post what you have done and we can help, otherwise there are many sites on the Internet to hire a contractor for a small job. -- Ken Foskey FOSS developer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Transform my algorithm in perl. Ideas?
Shams Fantar wrote: Here is the algorithm : "If there is a file in this directory which is old likewise of 10 days, to delete it or else, do nothing." Do you have ideas to say "If there is a file which is old likewise of 10 days" in perl? opendir my $d, $dir or die $!; my @oldfiles = grep -f "$dir/$_" && -M _ > 10, readdir $d; if ( @oldfiles ) { # do something } -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Transform my algorithm in perl. Ideas?
On 9/3/07, Shams Fantar <[EMAIL PROTECTED]> wrote: > Do you have ideas to say "If there is a file which is old likewise of 10 > days" in perl? There are three timestamps that can mean the age of a file: the mtime, atime, and ctime. If you want to know how old the data in the file is, that's the mtime, or modification time. That's usually the one people mean when they talk about the age of a file, but Perl can also access the other timestamps. The usual way to access the mtime is with the -M operator, which returns the age as measured in days. my $filename = "fred"; warn "The file is at least one day old!" if -M $filename > 1; If you need to delete some file, you can do that with the unlink operator. Both unlink and -M are documented in the perlfunc manpage. http://perldoc.perl.org/perlfunc.html Does that get you closer to what you need? Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Transform my algorithm in perl. Ideas?
Hi ! I have a problem at which I have no solution. Here is the algorithm : "If there is a file in this directory which is old likewise of 10 days, to delete it or else, do nothing." Do you have ideas to say "If there is a file which is old likewise of 10 days" in perl? Best regards, -- Shams Fantar (http://snurf.info) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/