My current thinking: I need a certain module that will let me access the USB device. Also, I need some kind of deamon thing that will notify my script of any incoming USB connection event. And then I simply use some regexp to find the file I want to copy and then do the copying, maybe with some file copy module.
But I searched CPAN with the keyword "USB" only to find there're indeed very few relevant modules around and that seemingly most promising module that is called Device::USB says it does not support Windows system. I'm running Windows XP SP3, btw.
I assume this sort of automation shouldn't be too hard with Perl. But I'm just stuck there.
Any ideas? or any other suggestions? Thanks :)
UPDATE
Things are not as easy as expected. I'm sure I have a lot more to learn. But based on my existing Perl knowledge, I've managed to write a make-do script. I'm here to learn. Please kindly comment where I can improve my code. Thanks like always :)
use warnings;
use strict;
use File::Find;
use File::Copy;
my $from = 'I:/'; #Volume letter for USB drive in my OS
my $to = 'E:\Copy-to';
while (1) {
if (-e $from) {
last;
}else{
sleep(30);
}
}
my @files;
find(sub{ push @files, $File::Find::name if /pdf$/}, $from); #Find the PDF files in the USB drive for Copying experiment
for (@files){
copy ($_,$to);
}