summaryrefslogtreecommitdiffstats
path: root/bin/hush/update-weather
blob: 189929ec626333f5f5a4ebab1f450e6b54aa6650 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env perl
use strict;
use warnings;
use 5.020;
use feature 'signatures';
no warnings 'experimental::signatures';

use open ':encoding(UTF-8)', ':std';

if (my $weather = `weather`) {
    spew("$ENV{HOME}/.cache/weather", $weather);
}

sub spew($filename, $contents) {
    open my $fh, '>', $filename
        or die "couldn't open $filename: $!";
    print $fh $contents;
    close $fh;
}