Win32-GUI - Problem executing shell commands from within perl after call to GetSaveFileName

Posted on Sat Apr 5 04:04:06 2008 by grtoro
Problem executing shell commands from within perl after call to GetSaveFileName
Hi, This question may be too simple for this group; if so, I apologize. I only use perl once in a while and this is my first experience with Win32::GUI.

I wrote a simple perl script that calls GetSaveFileName to get the name of an output file and then calls the shell to execute some separate programs (using backtics or system). After the call to GetSaveFileName, the shell commands do not seem to find the necessary files (even though they exist in the current directory). If I remove the call to GetSaveFileName and hard-wire a name, everything works.

It is not a problem with the subroutine that calls GetSaveFileName; it returns the right name (the problem is with another file). It seems like Win32::GUI is having some undesirable side effect:
does it change the current path? (my tests suggests it does not)
does it change the shell that executes the backtic or system commands?
anything else?

I would appreciate any suggestions.

Thanks,

Gabriel

PS: Here is my GetSaveFileName (which, as I indicated, is working OK except for the "side effects").
sub GetSaveFileName # # returns selected pdf file # #no arguments (may want to add them later) { use strict; use warnings; use Win32::GUI qw(); my $window_main = Win32::GUI::Window->new( -name => 'window_main', -size => [320, 240], -title => 'CmnDlg - Save As', ); $window_main->Show(); my $file = ''; my $directory = 'C:/'; # Save as file dialog box, show files with *.txt extension, in messages folder $file = Win32::GUI::GetSaveFileName( -owner => $window_main, -title => 'Select Output pdf file', -directory => $directory, -filter => ['Pdf files', '*.pdf', 'All files', '*.*'], -file => $file, ); return $file; } 1 # needed if we are using require
Write a response