Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Monitor new file

by karlgoethebier (Abbot)
on Dec 05, 2017 at 17:36 UTC ( [id://1204978]=note: print w/replies, xml ) Need Help??


in reply to Monitor new file

May be you actually want a "hotfolder".

On Linux (which i don't have anymore) there is File::Hotfolder.

Here is a sketch written in a hurry and not thoroughly tested for the Mac using Mac::FSEvents:

#!/usr/bin/env perl use strict; use warnings; use Data::Dump; use Mac::FSEvents; use IO::Select; use feature qw(say); my $dir = q(/Users/karl/Desktop/somewhere; my $fs = Mac::FSEvents->new( path => $dir, file_events => 1, ); my $fh = $fs->watch; my $select = IO::Select->new($fh); while ( $select->can_read ) { my @events = $fs->read_events; # dd \@events; for my $event (@events) { say $event->path; say for ( stat( $event->path ) )[ 7, 9 ]; } } __END__

With File::Hotfolder something similar should be possible.

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2024-04-23 13:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found