I would do this using map; something like:
my $state = join("\n",map { s{^\./}{}; $_} @noCvsDirs);
In fact, you can replace the entire main routine of your program with:
The find('.') returns the list of filenames, the grep removes any that have CVS in them, and the map removes the leading dot-slash.my $fh = new IO::File(">hwconfig.cfg") or die "Couldn't open hwconfig.cfg: $!\n"; print $fh join("\n", map { s{^\./}{}; $_ } grep { !/CVS/ and !/~$/ } find('.')) or die "Couldn't write to hwconfig.cfg: $!\n"; close $fh or die "Couldn't close hwconfig.cfg: $!\n";
If you still want to write everything to a string first, it should be straightforward to modify.
Also, File::Find is designed to do exactly what you're doing, though in this case I'm not sure it would actually be easier to learn how to use it than to just write it how you have it.
In reply to Re: Need help stripping characters in an array please.
by sgifford
in thread Need help stripping characters in an array please.
by Seventh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |