in reply to Tk::getOpenFile: -initialdir doesn't work on UNIX

here the excential part of my program : the "initaldir"-option of getSaveFile/getOpenFile works fine under winnt4 but doesn't work on my linux box
#!/usr/bin/perl -w use Tk; use strict; use warnings; use English; my $initialdir; if ($OSNAME =~ /win/i){ $initialdir = 'C:\temp'; } if ($OSNAME =~ /linux|unix|bsd/i){ $initialdir = '/tmp'; } my $main = new MainWindow; my $menubar = $main->Frame(-relief=>"raised", -borderwidth=>2); my $filebutton = $menubar->Menubutton( -text=>"File", -underline => 0 ); my $filemenu = $filebutton->Menu(); $filebutton->configure( -menu=>$filemenu ); $filemenu->command( -command => \&open_choice, -label => "Open...", -underline => 0 ); $filemenu->command( -command => \&save_choice, -label => "Save...", -underline => 0 ); $filemenu->separator; $filemenu->command( -label => "Exit", -command => \&exit_choice, -underline => 1 ); my $helpbutton = $menubar->Menubutton( -text=>"Help", -underline => 0 ); $filebutton->pack( -side=>"left" ); $helpbutton->pack( -side=>"right" ); $menubar->pack( -side=>"top", -fill=>"x" ); MainLoop; sub open_choice { my $filename = $main->getOpenFile( -defaultextension => "cnf", -filetypes => [ ['Configuration Files','.cnf'], ['All Files','*'] ], -initialdir=> $initialdir, ); return unless $filename; print "Open file $filename\n"; } sub save_choice { my $filename = $main->getSaveFile( -defaultextension => "cnf", -filetypes => [ ['Configuration Files','.cnf'], ['All Files','*'] ], -initialdir => $initialdir, ); return unless $filename; }
the output of perl -V is:
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuratio +n: Platform: osname=linux, osvers=2.4.16-6mdksmp, archname=i386-linux uname='linux bi.mandrakesoft.com 2.4.16-6mdksmp #1 smp sat dec 8 0 +4:02:48 cet 2001 i686 unknown ' config_args='-des -Darchname=i386-linux -Dd_dosuid -Ud_csh -Dusesh +rplib -Doptimize=-O3 -fomit-frame-pointer -pipe -mcpu=pentiumpro -mar +ch=i586 -ffast-math -fno-strength-reduce -Dprefix=/usr -Di_ndbm -Di_g +dbm -Di_shadow -Di_syslog -Uuselargefiles -Dman1dir=/usr/share/man/ma +n1 -Dman3dir=/usr/lib/perl5/man/man3' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultipl +icity=undef useperlio=undef d_sfio=undef uselargefiles=undef usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include', optimize='-O3 -fomit-frame-pointer -pipe -mcpu=pentiumpro -march=i +586 -ffast-math -fno-strength-reduce', cppflags='-fno-strict-aliasing -I/usr/local/include' ccversion='', gccversion='2.96 20000731 (Mandrake Linux 8.2 2.96-0 +.75mdk)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=4 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -ldl -lm -lc -lcrypt -lutil perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil libc=/lib/libc-2.2.4.so, so=so, useshrplib=true, libperl=libperl.s +o Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynami +c -Wl,-rpath,/usr/lib/perl5/5.6.1/i386-linux/CORE' cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: Built under linux Compiled at Feb 21 2002 01:00:32 @INC: /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl

Replies are listed 'Best First'.
Re: Re: "initaldir" doesnt do anything?
by ariels (Curate) on Apr 29, 2002 at 12:20 UTC

    Are you sure this is precisely code you have that doesn't work on your box? Specifically, it works on all my boxes (Perl 5.005 on SunOS, Perls 5.005 and 5.6.1 on Linux).

    But if I change your line

    $initialdir = '/tmp';
    to this:
    $initialdir = '/tmp/';
    then I get the bad behaviour you describe -- browsing starts at <samp>/</samp>. Are you sure this is not your problem?

      I can duplicate his bug on my linux w/ 5.6.1... Specifically:

      Summary of my perl5 (revision 5.0 version 6 subversion 1) configuratio +n: Platform: osname=linux, osvers=2.4.13, archname=i386-linux uname='linux duende 2.4.13 #1 wed oct 31 19:18:07 est 2001 i686 un +known ' config_args='-Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=i386 +-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.6.1 -Darchlib=/usr/l +ib/perl/5.6.1 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvend +orarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/sh +are/perl/5.6.1 -Dsitearch=/usr/local/lib/perl/5.6.1 -Dman1dir=/usr/sh +are/man/man1 -Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3per +l -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Uusesfio -Duseshrpli +b -Dlibperl=libperl.so.5.6.1 -Dd_dosuid -des' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultipl +icity=undef useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='cc', ccflags ='-DDEBIAN -fno-strict-aliasing -I/usr/local/incl +ude -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-DDEBIAN -fno-strict-aliasing -I/usr/local/include' ccversion='', gccversion='2.95.4 (Debian prerelease)', gccosandve +rs='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=4, usemymalloc=n, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lgdbm -ldb -ldl -lm -lc -lcrypt perllibs=-ldl -lm -lc -lcrypt libc=/lib/libc-2.2.4.so, so=so, useshrplib=true, libperl=libperl.s +o.5.6.1 Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynami +c' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: USE_LARGE_FILES Built under linux Compiled at Jan 11 2002 04:09:18 @INC: /usr/local/lib/perl/5.6.1 /usr/local/share/perl/5.6.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.6.1 /usr/share/perl/5.6.1 /usr/local/lib/site_perl .

      bbfu
      Black flowers blossum
      Fearless on my breath
      Teardrops on the fire
      Fearless on my breath

      it is realy precisely the code that doesn't work on my box

      i have tried both and nither the one or the other worked the right way

      NaSe