http://www.perlmonks.org?node_id=688779


in reply to Connecting to network shared drive

Windows has invisible shares called C$, D$, etc representing C:, D:, etc.

If the machine you wish to poll has file sharing enabled,
if the machine on which the program runs is a Win32 machine with "Client for Microsoft Networks" enabled, and
if your login and password is the same for that machine as it is for the current machine,
then you can just open \\machine\c$\some\dir (or //machine/c$/some/dir if it's easier) using opendir. Win32::ChangeNotify will also accepts such a path.

use strict; use warnings; my $path = '\\\\godzilla\\c$\\temp'; for (;;) { my $count = () = do { opendir my $dh, $path or die; readdir($dh) }; print("$count\n"); sleep(2); }
2 2 2 2 3 3 3 4 Terminating on signal SIGINT(2)
use strict; use warnings; use Win32::ChangeNotify qw( FILE_NOTIFY_CHANGE_DIR_NAME FILE_NOTIFY_CHANGE_FILE_NAME ); my $path = '\\\\godzilla\\c$\\temp'; for (;;) { my $count = () = do { opendir my $dh, $path or die; readdir($dh) }; print("$count\n"); my $notify = Win32::ChangeNotify->new($path, 0, FILE_NOTIFY_CHANGE_ +DIR_NAME|FILE_NOTIFY_CHANGE_FILE_NAME); $notify->wait or die; }
2 3 4 Terminating on signal SIGINT(2)

Update: Added code.