#! perl -slw use strict; use threads; my $FILEPATH = './AUV*.dat'; my $file; while( 1 ) { sleep( 1 ) until defined( $file = glob $FILEPATH ); async{ process( $file ) }->detach; } sub process { my $file = shift; return unless $file =~ m[AUV(\d+)\.dat$]; my $AUVNO = $1; eval "use AUV::$AUVNO"; warn "No processing module found for AUV no: $AUVNO" and return if $@; AUVProcess( $file ); return; } #### package AUV::123; use strict; our @ISA = 'Exporter'; our @EXPORT = 'AUVProcess'; sub AUVProcess{ my $file = shift; open DATA, '<', $file or warn "Couldn't open $file : $!\n"; ## Process data from file here print while ; close DATA; unlink $file; return; } print "AUV::123 loaded";