The scalar "$filename" is the file that was opened in it's original form and "compare" is a temp file I create to load the changed text into from the text editor before saving. I then compare the original file to the edited file and if there have been changes I want the program to prompt to save and if there have been no changes I want the program just to save. Now as I said it prompt every time even when I am sure the files are the same. Is there an issue with "$filename" being a full file path and "compare" being a local file in this subdirectory?sub close { open (TEMP, ">compare"); print TEMP $t->get("1.0", "end"); close(TEMP); print "\$filename equals ",$filename,"\n"; if (compare($filename,"compare") == 0) { print "They are the same\n"; exit; }elsif (compare($filename,"compare") == -1) { $t->insert("end", "There was an error while comparing!\n"); }else{ print "They are different\n"; my $sw = MainWindow->new(-title=>"Content Has Changed"); my $frame = $sw->Frame->pack(-side => 'top', -fill => 'x'); $frame->Label(-text => "The file has changed since last save. Wo +uld you like to save before exiting?")-> pack(-side => 'left', -anchor => 'w'); $frame->Button(-text => "No", -background => 'navy blue', -foreg +round => 'white', -command => sub {exit;})-> pack(-side => 'right'); $frame->Button(-text => "Yes", -background => 'navy blue', -fore +ground => 'white', -command =>\&save_and_exit)-> pack(-side => 'right'); } }
In reply to File comparison problem! by Elijah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |