Elijah has asked for the wisdom of the Perl Monks concerning the following question:
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'); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File comparison problem!
by Roy Johnson (Monsignor) on Dec 01, 2003 at 18:20 UTC | |
by Elijah (Hermit) on Dec 01, 2003 at 23:10 UTC | |
|
Re: File comparison problem!
by duff (Parson) on Dec 01, 2003 at 18:24 UTC | |
by Elijah (Hermit) on Dec 01, 2003 at 23:38 UTC | |
by ysth (Canon) on Dec 02, 2003 at 00:05 UTC | |
by Elijah (Hermit) on Dec 02, 2003 at 05:41 UTC | |
by Elijah (Hermit) on Dec 02, 2003 at 17:15 UTC | |
by ysth (Canon) on Dec 03, 2003 at 00:02 UTC |