Thread Speichern und öffnen von Dateien
(1 answers)
Opened by Mako at 2007-10-17 13:18 Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 #!/usr/bin/perl use strict; use warnings; use Tk; my $text; my $mw = tkinit; my $textw = $mw->Text()->pack; $mw->Button( -command => \&getfilename, -text => 'oeffnen' )->pack; $mw->Button( -command => \&getoutput, -text => 'speichern' )->pack; MainLoop; sub getfilename{ my $file = $mw->getOpenFile; if( open my $fh, '<', $file ){ local $/; $text = <$fh>; } $textw->insert('end', $text); } sub getoutput{ my $file = $mw->getSaveFile; if( open my $fh, '>', $file ){ $text = $textw->get('1.0','end'); print $fh $text; close $fh; } } OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/) -- Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html Perl-Entwicklung: http://perl-services.de/ |