starfrench: tk:geöffnete Datei unter anderem Namen speichern???

Beitrag lesen

Hallo

Komme in meinem Script nicht weiter.
Die ganze Sub-Routine "speichern" scheint falsch zu sein.
Wie kriege ich das Script dazu die geöffnete Datei zu speichern ??
Kann mir einer helfen????

Hier mein soweit funktionierendes Script!!

#!/usr/bin/perl-w
use strict;
use Tk;
my ($mw, $frame);
my ($text, $yscr, $xscr);
my ($fbut, $bread, $bask, $bxit);
my $input_file;
my $output_file;

$mw = MainWindow->new();
$frame = $mw->Frame();
$text = $frame->Text(-wrap => 'none');
$yscr = $frame->Scrollbar(-command =>
[yview => $text],
-orient => 'vertical');
$xscr = $frame->Scrollbar(-command =>
[xview => $text],
-orient => 'horizontal');
$text->configure(-yscrollcommand => [ set => $yscr ]);
$text->configure(-xscrollcommand => [ set => $xscr ]);

$frame->pack(-expand => 'yes', -fill => 'both');

$yscr->pack(-side => 'right', -fill => 'y');
$xscr->pack(-side => 'bottom', -fill => 'x');

$text->pack(-expand => 'yes', -fill => 'both',
-side => 'left');

$fbut = $mw->Frame();
####################
$input_file = $fbut->Entry(); #auslesen der Datei im Verzeichnis
####################
$bread = $fbut->Button(-text => 'Datei öffnen',
-command => &oeffnen);
#########################
$output_file = $fbut->Entry();
#######################
$bask = $fbut->Button(-text => 'Speichern',
-command => &speichern);
$bxit = $fbut->Button(-text => 'Exit',
-command => sub { exit 0 });
$fbut->pack(-side => 'bottom', -expand => 'both',
-fill => 'both');
###################
$input_file->pack(-side => 'left');
####################
$bread->pack(-side => 'left');
###################
$output_file->pack(-side => 'left');
####################
$bask->pack(-side => 'left');
$bxit->pack(-side => 'left');

MainLoop;

sub oeffnen {

######################
my $take_this = $input_file->get;
######################

open (IFILE, "<$take_this")or die "can't open $take_this : $!\n";
while (<IFILE>) {
$text->insert("end", $_);
$input_file->delete(0,100);
}
close (IFILE);
}

sub speichern {

######################
my $take_that = $output_file->get;

my $to_protect = $text->get;

######################

open (IFILE, ">$take_that");

close(IFILE);

}

schluss