On Wed, Feb 23, 2000 at 01:06:23AM +0800, robinmcf@altern.org wrote: > The script below is an attempt at writing a generic handler script for > getting the paths to standard folders. Though logic says by passing the > name of the folder to FindFolder() it should yield the path to the folder, > yet I get > > # Use of uninitialized value. > File 'Untitled'; Line 37 # (#1) > > What gives? The usual problem: failure to check return values. > #! perl -w > > use diagnostics-verbose; > use strict; > > > #-=-=-=-=-=Declare Includes-=-=-=-=-=-=-=-=-=-=-= > use Mac::Files; > use File::Find; > #-=-=-=-=-=Declare Variables-=-=-=-=-=-=-=-=-=-= > > my ($path,$folder,$file,@StdFolders,); > > #-=-=-=-=-=Script Body-=-=-=-=-=-=-=-=-=-=-=-=-= > > $path = FindFolder(kOnSystemDisk(),kDesktopFolderType()); #typing the > folder name like this > > # works > print "path to desktop folder is> $path\n"; > > @StdFolders= q(kAppleMenuFolderType() #load the standard folders into an array An array of one element... I assume you meant qw(). And that comment is part of the string. That's only half the problem, though. Consider the difference between these two lines of code: $path = FindFolder(kOnSystemDisk(),kDesktopFolderType()); $path = FindFolder(kOnSystemDisk(),"kDesktopFolderType()"); > kShutdownFolderType() > kControlPanelFolderType() > kStartupFolderType() > kDesktopFolderType() > kSystemFolderType() > kExtensionFolderType() > kTemporaryFolderType() > kFontsFolderType() > kTrashFolderType() > kPreferencesFolderType() > ); > > > foreach $file (@StdFolders) { > $path=(FindFolder(kOnSystemDisk(),$file)); FindFolder() is returning undef because its second argument does not specify an existing file. Unfortunately, instead of checking the return value from FindFolder, you just go ahead and print it: > print "$path\n"; > print "$file\n"; > > } > _END_ Ronald # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org