use strict; use warnings; use IO::File; my $filepath='\\\\mucsdn21\\fischron\\tmp\\created_on_unix.txt'; if(-f $filepath) { my $fh=IO::File->new(); $fh->open($filepath) || die "$!"; binmode($fh,':unix'); my @result=<$fh>; $fh->close || die "$!"; print(@result." lines read\n"); $!=0; # Documentation does not say whether or not unlink sets $! on error if(!unlink($filepath)) { print("*************** Could not delete $filepath ($!)\n"); } } else { print("$filepath does not exist"); }