I'm having dificulty getting the correct syntax for passing and using a filename as a parameter to a subroutine which will then open and read it. I have be fiddling with different ways to deal with scope, but this is fairly new territory for me and I'm probably overlooking something obvious.... A synopsis of the code: #!perl -w # use strict; use Mac::Windows; use Mac::QuickDraw; use Mac::Events; use Mac::StandardFile; use Mac::Dialogs; #****************************************************** my($DoSearch,$dlg); $DoSearch = 0; ShowDialog(); while ($dlg->window() ) { $dlg->modal(); } if ($DoSearch == 1) { SearchDirs(); } dispose $dlg; #*************************************************** sub ShowDialog { #------ SET UP DIALOG FOR SEARCH #etc . . . #THE HEART OF THE MATTER sub SearchDirs() { my $myDisk = 'DorjeJigje'; print ("\nroot volume - $myDisk:\n"); my $rootdir = "$myDisk:Technical Mail, etc"; opendir(DIR, $rootdir) or die "cannot open $myDisk"; my @files = readdir(DIR); foreach my $file (@files) { print("$file\n"); my $newdir = $rootdir . $file; opendir(NEWDIR,$newdir); my @newfiles = readdir(NEWDIR); foreach my $newfile(@newfiles) { if (-B $newfile) { print "" ; } elsif (-d $newfile) { print ""; } else { SearchFile($newfile, $dlg->item_text(4)); #HERE'S WHERE THE TROUBLE STARTS } } } closedir(DIR); } #HERE'S WHERE THE PROBLEM LIES sub SearchFile(main::$newfile, $dlg->item_text(4)) { my $openFlag = 0; my $searchString = $dlg->item_text(4); open(IN,main::$newfile) or die ("Can not open file\n"); #I GET THE FOLLOW MESSAGE AT THIS LINE # Bad name after SearchDirs::. File 'DorjeJigje:Programming:MacPerl Ÿ:Noe's Perl Stuff:ReadDirs.pl '; Line 130 while main::$line = <IN> { if ( $line =~ m/$searchString/ ) { if $openFlag == 0 { $openFlag = 1; print ("\t $file \n"); print ("\t\t $line \n"); } else { print ("\t\t $line \n"); } } } close (IN); } Any pointing out the obvious would be welcome...... Noe \\\ (@v@) W ( O ) // | | // / ? |/ // | ||| \ M| /\ | || || || || LL LL ===== Want to unsubscribe from this list? ===== Send mail with body "unsubscribe" to macperl-request@macperl.org