Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
updated title. to more closely reflect my goal. update.. I have my file mover built, now I want to monitor the srcdir, to make sure the other program is not hung so i installed file monitor but its giving me this error, I am not sure i am even referring to the objects correctly here and apparently I am not as I get this message.. global symbol object requires explicit package name in copy.pl line 36 global symbol object requires explicit package name in copy.pl line 39 I guess I am just dense but I don't understand the watch with callback, I am guessing that means if it changes to call some other file?
use File::Copy::Recursive; use File::Find; use strict; my $srcdir='c:\\inetpub\\performancetesting\\output\\new\\'; my $destdir='c:\\'; File::Copy::Recursive::dircopy $srcdir, $destdir or die "Copy failed: + $!"; use File::Monitor; my $monitor = File::Monitor->new(); # Just watch $monitor->watch('c:\\inetpub\\performancetesting\\output\\new\\mlx +\\aar\\04-16-2009.txt'); # Watch with callback $monitor->watch('otherfile.txt', sub { my ($name, $event, $change) = @_; print "file has been changed"; # Do stuff; }); # Watch a directory $monitor->watch( { name => 'c:\\inetpub\\performancetesting\\output\\new\\ +mlx\\', recurse => 1, callback => { files_created => sub { my ($name, $event, $change) = @_; print "something modified in directory mlx"; } } } ); # First scan just finds out about the monitored files. No changes # will be reported. $object->scan; my $monitor->scan; # Later perform a scan and gather any changes my @changes = $object->scan;
I have a need to monitor text files as they are being updated by another application, ideally I would like to access the files shortly after the other program has written to them to check values against a threshold, as well as validate them to ensure they are in a proper format for input into a db, these checks can occur after the other program is finished with them if need be, but I would like to be able to send alerts in real time should the values for these transactions exceed the limits, in addition I would like the limits themselves to be user configurable and I would like to then copy the files into another location so my sql transaction can pick them up.

In reply to monitor text files by grashoper

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-26 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found