tkx GUI open file and read

Posted by tarenkeoh on 2013-03-11 05:05

I am new to this perl and tkx...I was trying to write a UI that able to let user to chose the specific txt/xml file and read the content...i tried on code as below but seem like it didn't work...Need help :(

use strict;
use Tkx;
my $input1;
my @f1_data;
my $Main = Tkx::widget->new(".");
Tkx::wm_title(".", "Test");

my $browse1 = $Main->new_ttk__button(
-text => "Input Path",
-command => sub
{
my $input1 = Tkx::tk___getOpenFile();
#$input1 =~ s/\//\\/g;
open F1, "$input1" or die "Could not open file: $! \n"; #open file 1
my @f1_data = ;
close F1;
#print "input1: ". $input1 . "\n";
}
);
my $buttonSubmit = $Main ->new_ttk__button(
-text => "submit",
-command => sub {submit();}
);

$browse1->g_grid(-column => 1, -row=> 1);
$buttonSubmit ->g_grid(-column => 1, -row=> 2);

sub submit{
print @f1_data."\n";
}

Tkx::MainLoop();
exit;