diff options
author | Daniel Friesel <derf@finalrewind.org> | 2017-10-01 16:18:55 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2017-10-01 16:18:55 +0200 |
commit | ee9b0f5cfc4eecb9c68880d5a6b4ea2e981f0df1 (patch) | |
tree | 2c32c9480c37b8131fa613048ac7c99aa93b4fbd /bin | |
parent | a80cd82cd46221bbf26dd59c47cc467bd5d120a1 (diff) |
Gracefully handle nonexistent files
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/mqtt-multipub | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/mqtt-multipub b/bin/mqtt-multipub index 4c9b2dc..c079d6f 100755 --- a/bin/mqtt-multipub +++ b/bin/mqtt-multipub @@ -14,8 +14,10 @@ my $mqtt = Net::MQTT::Simple->new( '172.23.225.193' ); sub parse_content_string { my ($raw_content) = @_; if ($raw_content =~ m{ ^ / [^/] }x) { - my $content = read_file($raw_content); - chomp $content; + my $content = read_file($raw_content, { err_mode => 'carp' }); + if (defined $content) { + chomp $content; + } return $content; } return $raw_content; |