Zentara wrote: --------------------------------------------------------------------------------------------------- > #!/usr/bin/perl -w > > @users=('/home/zentara'); > > #put all user-root hidden files and hidden dirs into 1 temp dir > #this makes it easier to backup second level subdirs > foreach $homedir(@users){ > opendir DIR, $homedir or warn "Cannot readdir $homedir:$!\n"; > @files = grep !/^\.\.?$/, readdir DIR; > foreach (@files){push @movem,$_ if -f} > foreach (@files){push @movem,$_ if ($_ =~ m!^[.]!)} > print "@movem\n"; > print "##############################################\n"; > } > exit; > --------------------------------------------------------------------------------------------------------- > Can someone shed some light on why this happens? It has > something to do with running it from /. >
yes because readdir(DIR) only returns a relative path. you need to know where you are! example: #!/usr/bin/perl -w use strict; opendir(DIR,'.') || die $!; print join("\n",grep /\.pl$/, readdir(DIR)),"\n"; closedir(DIR); __END__ when i run the above in my perl directory, it prints the following: tmp.pl when i run the above in /, it prints nothing because under /, i don't have any script that ends with .pl now going back to looking at your: > foreach (@files){push @movem,$_ if -f} when you run it in /, your if statment is trying to do: foreach (@files){ push @movem,$_ if(-f /$_)} because you are under /. the test will mostly like fail. when you run it in /home/zentara, your if statement is trying to do: foreach (@files){ push @movem,$_ if(-f /home/zentara/$_)} so it work. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]