Skip to content

Instantly share code, notes, and snippets.

@moznion
Created January 5, 2015 06:52
Show Gist options
  • Save moznion/0fc7e7cf503314d20acc to your computer and use it in GitHub Desktop.
Save moznion/0fc7e7cf503314d20acc to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
my ($old_file, $new_file) = @ARGV;
if (!defined $old_file || !defined $new_file) {
die "You must give two file names via command line argument";
}
open my $old_fh, '<', $old_file or die "Cannot open file ($old_file): $!";
my @old_file_lines = sort { $a cmp $b } split /\r?\n/, do { local $/; <$old_fh> };
open my $new_fh, '<', $new_file or die "Cannot open file ($new_file): $!";
my @new_file_lines = sort { $a cmp $b } split /\r?\n/, do { local $/; <$new_fh> };
if (join('', @old_file_lines) ne join('', @new_file_lines)) {
print "Different!\n";
}
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment