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.


In reply to Re: Installing File::find module by asifk1981
in thread Installing File::find module by asifk1981

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.