If you want to print multiple files, it might be best to push all file selections into an array, then send the whole
array to the printer, after selections are done. There are many ways to do it.
#!/usr/bin/perl
use Tk;
use strict;
my $TOP = MainWindow->new;
my $button = $TOP->Button(-text=> 'Print It' ,
-command => sub{
my $file_r = &fileDialog($TOP);
print"\n selected this file $file_r\n";
# use whatever method you want to send
# $file_r to the printer
# like with Net::Cups
print " printing now!\n";
# system( "lpr -lp0 -f $file_r"); #untested
}
)->pack();
MainLoop;
sub fileDialog {
my( $w ) = @_;
my @types =( ["C files", [qw/.c++ .cpp .c/]],
["Log files", [qw/.log/]],,
["Text files", [qw/.txt/]],
["All files", '*']
);
my $file = $w->getOpenFile( -filetypes => \@types );
return($file);
}