use Text::Diff;
for($count = 0; $count <= 1000; $count++){
my $data_dir=\"archive/oswiostat/oracleapps.*dat\";
my $data_file= `ls -t $data_dir | head -1`;
The real fix is File::ChangeNotify or File::Monitor or something similar (e.g., on Windows, Win32::ChangeNotify).
use File::ChangeNotify;
my $watcher = File::ChangeNotify->instantiate_watcher(
directories => [ 'archive/oswiostat' ],
filter => qr/\Aoracleapps[.].*dat\z/,
);
while (my @events = $watcher->wait_for_events) {
# ...
}