Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Installing File::find module

by asifk1981 (Novice)
on Dec 09, 2004 at 15:58 UTC ( [id://413602]=note: print w/replies, xml ) Need Help??


in reply to Installing File::find module

Here I am posting the script.
#!/usr/local/bin/perl #This script is for checking the modification time of files under /con +fig directory. use File::Find; use File::stat qw(:FIELDS); use HTTP::Request; use LWP::UserAgent; %fileModTimes; $serverPath = ""; $filesModified = ""; %broadcastingModTimes; $broadcastingModified = ""; open(IN, "/config/Status.conf") or file_not_found(); while (<IN>) { if (/ServerPath/) { s/ServerPath.*=(.*)/$1/; $serverPath = $1; } } close IN; find(\&updateFileModTimes, "/config"); find(\&updateBroadCastingModTimes,"/config/Notify.conf"); #Check all files under /config directory sub updateFileModTimes { if ( -f "$File::Find::name" && "$File::Find::name" =~ /.*\.txt/i) { if ($fileModTimes{$File::Find::name}) { stat($File::Find::name) or die "Couldn't find $File::Find::nam +e"; if ( $fileModTimes{$File::Find::name} eq $st_mtime ) { #do nothing } else { $fileModTimes{$File::Find::name} = $st_mtime; $filesModified = "true"; } } else { stat($File::Find::name) or die "Couldn't find $File::Find::nam +e"; $fileModTimes{$File::Find::name} = $st_mtime; } } } #Check Notify.conf file for broadcating message under /config sub updateBroadCastingModTimes { if ( -f "$File::Find::name" && "$File::Find::name" eq "/config/Notif +y.conf") { if ($broadcastingModTimes{$File::Find::name}) { stat($File::Find::name) or die "Couldn't find $File::Find::nam +e"; if ( $broadcastingModTimes{$File::Find::name} eq $st_mtime ) { #do nothing } else { $broadcastingModTimes{$File::Find::name} = $st_mtime; $broadcastingModified = "true"; } } else { stat($File::Find::name) or die "Couldn't find $File::Find::nam +e"; $broadcastingModTimes{$File::Find::name} = $st_mtime; } } } while ( true ) { sleep 3; $url = $serverPath."\/appl?method=Updatefile"; $ua = LWP::UserAgent->new; $request = HTTP::Request->new(GET => $url); $response = $ua->request($request); #Check all files under configfiles directory find(\&updateFileModTimes, "/config"); if ($filesModified eq "true" ) { #A sleep of 10 secs is allowed here to ensure that all the files #are modified correctly. sleep 10; find(\&updateFileModTimes, "/config"); #send a request to the servlet $url = $serverPath."\/appl?method=Updatefile"; $ua = LWP::UserAgent->new; $request = HTTP::Request->new(GET => $url); $response = $ua->request($request); $filesModified = ""; } #check Notify.conf file for broadcasting message under configfiles d +irectory find(\&updateBroadCastingModTimes, "/config/Notify.conf"); if ($broadcastingModified eq "true" ) { #A sleep of 10 secs is allowed here to ensure that Notify.conf fil +e #is modified correctly. sleep 10; find(\&updateBroadCastingModTimes, "/config/Notify.conf"); #send a request to the servlet $url = $serverPath."\/appl?method=Updatefile&NotificationMessage=b +roadcast"; $ua = LWP::UserAgent->new; $request = HTTP::Request->new(GET => $url); $response = $ua->request($request); $broadcastingModified = ""; } }

Edited by davido: Added readmore tags per consideration consensus.

Replies are listed 'Best First'.
Re^2: Installing File::find module
by Steve_p (Priest) on Dec 11, 2004 at 04:08 UTC

    I was just dealing with a similar issue on the perl5-porters mailing list. On that ticket, based on the directories used on HP-UX, the perl installed at /usr/local/bin/perl was 5.005002. Since I've been working on HP-UX 11.0 for about five years that seems about right.

    Please confirm the version of Perl used in your script by performing a /usr/local/bin/perl -v and let us know what you find.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-24 08:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found