Re: Checking on logical functionality



Thks for your answer.
if I want to compare 2 files. The content of file1 is A&B while file 2
is B&A.
How can I compare and print that the functionality is same.

My source code:

use strict;
open (MYFILE1,"file1.txt") or die "$!";
open (MYFILE2,"file2.txt") or die "$!";
my %diff;

$diff{$_} =1 while (<MYFILE2>);

while (<MYFILE1>){
print "They are not the same.","\n" unless $diff{$_};
}
close(MYFILE1);
close(MYFILE2):


usenet@xxxxxxxxxxxxxxx wrote:
jyetying wrote:
I need to write a script to show that, for example A&B is same as B&A.

Hmmmm...... A question that good deserves an answer this good:

#!/usr/bin/perl

use strict; use warnings;

sub A { 1 }
sub B { 1 }

if ( A&B == B&A ) {
print "They are the same!\n";
}

__END__


--
David Filmer (http://DavidFilmer.com)

.



Relevant Pages

  • Re: Number of days since 1/1/2000
    ... use strict; ... use warnings; ... Compare your solution to the truly simple and elegant solution posted by ... sub prima_donna_method { ...
    (comp.lang.perl.misc)
  • Re: Validate Cell Value
    ... "Tim Zych" wrote: ... Private Sub Worksheet_Change(ByVal Target As Range) ... Workbook Compare - Excel data comparison utility ...
    (microsoft.public.excel.programming)
  • RE: Comparing data in two sheets with similar values
    ... Sub TestCompareWorksheets() ... ' compare two different worksheets in two different workbooks ... .Weight = xlHairline ...
    (microsoft.public.excel.worksheet.functions)
  • RE: Variable variables and sub routines
    ... Sub colourit(target As Range, Compare) ... .Pattern = xlSolid ... Compare = Cells(5, ColCount) ...
    (microsoft.public.excel.programming)
  • RE: Complex Copy
    ... Try the below macro which will create a copy of ws1 and work on it....Try ... Sub CompareSheets() ... Dim ws1 As Worksheet, ws2 As Worksheet ... If you mean to compare row by row then try the below macro which will work ...
    (microsoft.public.excel.programming)