star7 has asked for the wisdom of the Perl Monks concerning the following question:
Hi, at first i am a beginner. So i am so sorry,if my questions seem to be stupid. I have some questions: - 1.if-command: open(FILE, "> $dir") doesn`t create a text-file with the name of the visited directory. How can I solve this problem. - 2.if-command: I want to write the files, which are in the directory in the text-file (which carries the name of the directory). thanks for your help#!/usr/bin/perl -w use File::Find; find(\&dir_explorer, "/home/gw/A/S/d"); sub dir_explorer { my $entry = $_; if (-d $entry) { $dir=$entry; open(FILE, "> $dir") or die "Can not open $dir with permission +for writing: $!\n"; close(FILE); }; if (-f $entry) { open(FILE, ">> $dir") or die "Can not open $dir: $!\n"; print FILE "$file\n"; close(FILE); }; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Some problems with my code - Help...
by SuperCruncher (Pilgrim) on May 26, 2003 at 20:43 UTC | |
by BazB (Priest) on May 26, 2003 at 21:46 UTC | |
by star7 (Novice) on May 26, 2003 at 22:11 UTC | |
|
Re: Some problems with my code - Help...
by tos (Deacon) on May 26, 2003 at 21:28 UTC |