All pastes #949901 Raw Edit

Counter

public text v1 · immutable
·published 2008-03-20 03:49 UTC
rendered paste body
#!/usr/bin/perl
use strict;
use warnings;

die "No filename given.\n" unless @ARGV;
die "Too many args.\n" unless @ARGV == 1;

my ($filename) = @ARGV;

open my $fh, "<", $filename
    or die "Couldn't open $filename for reading: $!";

my $count = 0;
while ( my $line = <$fh> ) {
    $count++ if $line =~ /\S/; # something other than whitespace
}

close $fh;

if ( $count == 0 ) {
    print "up to date\n";
} else {
    print "$count available updates\n";
}