in reply to Comparing 2 files without diff or compare

Untested, but it usually works, and written in a way that if this is homework, someone will notice.
sub slurp { local *ARGV; @ARGV = @_; <> } my %where; $where{$_} .= "1" for slurp($file1); $where{$_} .= "2" for slurp($file2); for (sort keys %where) { my $where = $where{$_}; if ($where =~ /12/) { print "both"; } elsif ($where =~ /1/) { print "left"; } else { print "right"; } print ":\t$_"; }

update: Yeah, oops, thanks akho. Fixed.

Replies are listed 'Best First'.
Re^2: Comparing 2 files without diff or compare
by akho (Hermit) on May 02, 2007 at 08:29 UTC
    Doesn't always work, actually. What if $where eq '11111222'?