Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Comparison Of Files

by gt8073a (Hermit)
on Dec 06, 2000 at 05:12 UTC ( [id://45150]=note: print w/replies, xml ) Need Help??


in reply to Comparison Of Files

My boss wants me to create a tool that tells you which cellsite came up over night. So if someone clicks the button today (tuesday) they would get the sites that came up monday night through tuesday morning.
use Time::Local; my $sec = 0; my $min = 0; my $close = 17; ## 5:00 pm my $open = 9; ## 9:00 am my $spd = 24 * 60 * 60; my $yes = time - timelocal( $sec, $min, $close, (localtime( tim +e - $spd ))[ 3, 4, 5 ] ); my $morning = time - timelocal( $sec, $min, $open, (localtime)[ 3, +4, 5 ] ); my $dir = '/'; ## where the files reside( rem ending slash ) my @cellsites; opendir CELLSITES, $dir or die "opendir"; @cellsites = map{ $_->[0] } grep{ $_->[1] <= $yes && $_->[1] >= $morning } map{ [ $_, ( ( -M "$dir$_" ) * $spd ) ]} readdir CELLSITES; closedir CELLSITES; ## print @cellsites to a file ## or to screen, or something

Replies are listed 'Best First'.
(tye)Re1: Comparison Of Files
by tye (Sage) on Dec 06, 2000 at 05:32 UTC

    Nice first post. (: I liked the completely different approach and I liked the way you did it.

    I thought you might appreciate another alternative for the final part:

    @cellsites = grep { my $age= $spd * -M $dir.$_; $age <= $yes && $morning <= $age } readdir CELLSITES;
    which I think is a slight improvement. Keep up the good work.

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://45150]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2025-01-20 18:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (59 votes). Check out past polls.