To fix your main problem, just change while (<>) to while (<File_Open>) in your Open sub.
The <> is a "null filehandle" (see "I/O Operators" in perlop), which would cause your program to seem to hang because it was waiting (silently) for keyboard input from the DOS window.
Incidentally, 'Ctl+O' should be 'Ctrl+O', and you need to add this line to make the accelerator work:
$main->bind("<Control-o>", \&Open);
Also, here are some improvements to your Open sub; clearer names, tightened variable scope, and correctly handling the user <cancel>ing out of the Open dialog box:
sub Open { my $csv_path = $main->getOpenFile( -filetypes => [ [ 'CSV files', '.csv' ], [ 'All Files', '*' ], ] ); return if not defined $csv_path; open my $csv_fh, '<', $csv_path or die "Cannot open '$csv_path': $!"; my $out_fh; my $last_filename = ''; while (<$csv_fh>) { my ($f) = /^([^,]+),/; my $filename = "$f.txt"; if ( $filename ne $last_filename ) { open $out_fh, '>', $filename or die "cannot open $filename: $!"; } print {$out_fh} $_; $last_filename = $filename; } }
In reply to Re: GetOpenFile (Perl::TK 804.028) on v.5.10.0
by Util
in thread GetOpenFile (Perl::TK 804.028) on v.5.10.0
by Knoperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |