added missing function read_file
This commit is contained in:
parent
2b99bfb803
commit
e9bd646983
|
@ -87,6 +87,7 @@ our @EXPORT = qw(
|
|||
print_warning
|
||||
print_stderror
|
||||
read_configuration
|
||||
read_file
|
||||
simple_decode_json
|
||||
snmp_data_switcher
|
||||
snmp_get
|
||||
|
@ -1263,6 +1264,27 @@ sub read_configuration {
|
|||
return $config;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
## Reads a file and returns entire content or undef if error.
|
||||
################################################################################
|
||||
sub read_file {
|
||||
my $path = shift;
|
||||
|
||||
my $_FILE;
|
||||
if( !open($_FILE, "<", $path) ) {
|
||||
# failed to open, return undef
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Slurp configuration file content.
|
||||
my $content = do { local $/; <$_FILE> };
|
||||
|
||||
# Close file
|
||||
close($_FILE);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# General arguments parser
|
||||
################################################################################
|
||||
|
|
Loading…
Reference in New Issue