open (DIR, '>> c:\dir\dir.txt') || die "Can't open file; $!" ; my $dir = `dir *.pl`; print DIR $dir;