SPUG: "diff" utility within Perl

Colin Meyer cmeyer at helvella.org
Tue Nov 6 13:38:33 CST 2001


Hi, Bob,

On Tue, Nov 06, 2001 at 11:14:06AM -0800, Bob Brockhausen wrote:
> Does anyone know of if a "diff" like module exists within
> Perl?? I have script that uses "-s" to do simple diff,
> but I've found that the files are same size BUT different
> in content (single char in date 5 vs 6). I'd like to
> use some kina "diff" utlity to verify if indeed the two files
> are identical of not (don't need to know the difference, 
> just that they exist is good enought) If no module exists
> does anyone have utility that would work???

If you aren't concerned with what the actual difference is, just
whether two lines (strings) are equal or not, then just use
string comparison (called 'eq' in Perl):

#---------
my $line_a = <FILE_A>;
my $line_b = <FILE_B>;

print 'line_a and line_b differ'
  unless $line_a eq $line_b;
#---------

Have fun,
-C.

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://zipcon.net/spug/





More information about the spug-list mailing list