in reply to Re: Re: File comparison problem!
in thread File comparison problem!

Either print() is adding an extra newline (because you have the output record separator $\ set to "\n", e.g. if you are using perl's -l switch), or the extra newline is added by $t->get(), in which case you need to tell us more about what $t and get() are.

Replies are listed 'Best First'.
Re: Re: Re: Re: File comparison problem!
by Elijah (Hermit) on Dec 02, 2003 at 05:41 UTC
    Well $t is defined as the following:
    my $t = $mw->Scrolled("Text", -scrollbars => 'e')->pack (-side => 'bottom', -fill => 'both', -expand => 1);
    It is a scrolled text box and the get() function loads the contetnts of $t into the filehandle TEMP which is actually the file called "compare". Does this help?
Re: Re: Re: Re: File comparison problem!
by Elijah (Hermit) on Dec 02, 2003 at 17:15 UTC
    Yes it is the $t->get that is inserting the new line at the end. Is there any way to get around this? Or how could I remove the last line before comparison?
      my $filecontents = $t->get("1.0", "end"); chomp($filecontents); print TEMP $filecontents;
      or (if you want to eliminate multiple newlines, but leave at least one):
      my $filecontents = $t->get("1.0", "end"); $filecontents =~ s/\n+\z/\n/; print TEMP $filecontents;