use strict; use warnings; use Tk; use Win32::LongPath; use Spreadsheet::ParseXLSX; my $mw = Tk::MainWindow->new(); my $path; my $button = $mw->Button( -text => "Select a file", -command => \&show_file_dialog, )->pack(-side => 'left',); my $label = $mw->Entry( -text => 'No file yet', -width => 100, )->pack(-side => 'left',); $mw->MainLoop(); sub show_file_dialog { my @ext = ( ["Excel", ['xlsx']], ["All files", ['*']], ); $path = $mw->getOpenFile( -filetypes => \@ext, ); my $ShortPath = shortpathL ($path); $label->configure(-text => "$path - $ShortPath"); print "Trying to open file with Win32::LongPath::openL ... "; my $fh; Win32::LongPath::openL (\$fh, '<', $path) or die "Unable to open $path"; my $parser = Spreadsheet::ParseXLSX->new(); my $workbook = $parser->parse($fh); print "OK\n"; print "Trying to open file with shortpathL path ... "; my $parser = Spreadsheet::ParseXLSX->new(); my $workbook = $parser->parse($ShortPath); print "OK\n"; }