#! /usr/bin/perl -w
use strict;
use warnings;

# find . -name '*.html' -print | xargs -n1 perl -i.bak ./addads.pl 


# open(ADS, "< ads") or die "can't open ads: $!";
# my $ads;
# {
# local $/ = undef;
# $ads = <ADS>;
# }

my $file = $ARGV[0];

my $oldstuff = <<'EOF';
</head>
EOF

my $newstuff = <<'EOF';
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
EOF

chomp($oldstuff);
chomp($newstuff);

local $/ = undef;
print STDERR "* $file";
my $text = <>;

if ($text =~ s/${oldstuff}/${newstuff}/m) {
    print STDERR " updated\n";
} else {
    print STDERR " #### no change\n";
};
print $text;
