mbeason has asked for the wisdom of the Perl Monks concerning the following question:
At this point, it will print the $node and "1" for every file in the directory. I had thought it would populate the hash and then remove the $key if the $pattern exists. What I ultimately hope to do is put this is a CSV file with just the $node name. Any guidance you can offer would be appreciated.my(@node_list) = glob("/appl/perform/workspace/htdocs/node_reports/*/* +"); my($node) = ""; foreach $file (@node_list) { next if($file eq ".") or ($file eq "..") or ($file eq "lost+found" +); (undef,undef,undef,undef,undef,undef,$node,$filename) = split /\// +, $file; my($pattern) = "business_use\.$node"; chomp($node); chomp($filename); unless($filename =~ /^($pattern)/) { %needs_desc = ("$node" => 1); delete $needs_desc{$node} if("$filename" eq "$pattern"); while ( ($key, $value) = each %needs_desc ) { print "$key => $value\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex Basics
by Tanktalus (Canon) on Feb 07, 2007 at 20:16 UTC | |
|
Re: Regex Basics
by GrandFather (Saint) on Feb 07, 2007 at 20:29 UTC | |
|
Re: Regex Basics
by graff (Chancellor) on Feb 08, 2007 at 04:03 UTC | |
|
Re: Regex Basics
by Moron (Curate) on Feb 08, 2007 at 17:24 UTC |