On Mon, Jul 07, 2003 at 12:59:27PM -0700, Harry Putnam wrote: > I'm pretty sure there is a nifty thrifty way to do this rather than > tying myself in knots like this: > > I want to unlink and symlinks that might be in a specific directory. > A snipped from hack-a-thonic script: > > my $mnsd = "/tmp/mns"; > if(! -d $mnsd){ > mkdir $mnsd or die "Can't mkdir $mnsd; $!"; > }else{ > opendir(DIR, $mnsd) or die "can?ft opendir DIR: $!"; > { my $target = $mnsd . "/" . $_; ^
Hmmm? > unlink $target if (-l $target)} readdir(DIR); ^ Ah, okay. But you'll need to make that into a real loop. use File::Spec::Functions; ... foreach (readdir(DIR)) { my $target = catfile($mnsd, $_); if (-l $target) { unlink $target or warn "unlink: $target: $!"; } } The "uninitialized value" was $_. -- Steve -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]