#!/usr/bin/perl use strict; use warnings; use Tk::Carp qw/fatalsToDialog/; use Tk::Carp qw/warningsToDialog/; use Tk; my ( $in_file_name, $out_file_name, $MW, $message, $count_runs ); $MW = MainWindow->new(-title=>"Open/read times"); my $Frame=$MW->Labelframe( -text => 'Input Parameters', )->pack(); my $Ent_In_File_Name=$Frame->Entry( -textvariable => \$in_file_name, )->grid( -row => 0, -column => 0, -sticky => 'w', ); my $Btn_Open_File=$Frame->Button( -command => 'main::open_file', -text => 'Open File', )->grid( -row => 0, -column => 1, -sticky => 'w', ); my $Btn_run=$Frame->Button( -command => 'main::run_program', -text => 'Run program', )->grid( -row => 3, -column => 0, -sticky => 'w', ); my $Ent_Run=$Frame->Entry( )->grid( -row => 3, -column => 1, -sticky => 'w', ); ###### SUBROUTINES ############################################################# sub open_file { my $file_name_open=$MW->getOpenFile(); $Ent_In_File_Name->delete(0,'end'); $Ent_In_File_Name->insert(0,$file_name_open); } sub run_program { $count_runs++; my @data; open MYFILE ,$in_file_name or die "Could not open file to read:$in_file_name\n"; while() { my $temp=$_; chomp $temp; my @array=split("\t",$temp); push(@data,[@array]); } close MYFILE; $Ent_Run->delete(0,'end'); $Ent_Run->Insert("open/read N:$count_runs"); } MainLoop(); #### #!/usr/bin/perl use warnings; use strict; my $in_file="\\in_file\.txt"; my $count_runs=0; while (1) { $count_runs++; my @data; open MYFILE ,$in_file or die "Could not open file to read:$in_file\n"; while() { my $temp=$_; chomp $temp; my @array=split("\t",$temp); push(@data,[@array]); } close MYFILE; print "run $count_runs\n"; <>; }