sub read_content {
my ($file_name, $binary_mode) = @_;
my $content;
my $file = IO::File->new;
# Custom {
if (-e $file_name) {
#print "File $file_name exists!\n";
# Original source code {
$file->open($file_name, '<') or die "Cannot open file $file_name: $!";
if ($binary_mode) {
binmode $file;
}
my($number_of_bytes,$buffer);
$content = '';
while (($number_of_bytes = $file->read($buffer, 16384)) > 0) {
$content .= $buffer;
}
defined $number_of_bytes or die "Error reading from file $file_name: $!";
$file->close or die "Error closing $file_name: $!";
# } Original source code
}
else {
#print "File $file_name does not exist!\n";
my $logfile = '/var/log/sa-update-userlog.log';
my $str = "File $file_name does not exist!";
open(FH, '>', $logfile);
print FH $str;
close(FH);
}
# } Custom
return $content;
}