#!/usr/bin/perl -w system("ls -1 10.* > hostfilelist"); open (LIST, "hostfilelist"); push(@entrys, ); foreach my $entry (@entrys) { open (CURRENT, "$entry"); my @contents = ; @results = grep {/hostname/} @contents; #print $results[0]; @outputname = split (/ / , $results[0]); #print $outputname[1]; system("touch $outputname[1]"); open (OUTPUTFILE, ">$outputname[1]"); print OUTPUTFILE "@contents"; close (LIST); close (CURRENT); close (OUTPUTFILE); unlink ("hostfilelist"); } #### #!/usr/bin/perl -w use strict; my @entrys; my $entry; my $host; #to specify the directory, just uncomment the next line and put in the #real path to the dir, then comment out, or erase the opendir line that #references "." #opendir DIR, "/path/to/dir/with/configs" or die "Cant open dir $!\n"; opendir DIR, "." or die "Cant open dir $!\n"; @entrys = readdir DIR; #uncomment the next line if you are specifying a differenet directory #other than the pwd. #chdir "/path/to/dir/with/configs" or die "Cant change directory $!\n"; foreach my $entry (@entrys) { next if ( $entry !~ /^10/ ); open CURRENT, $entry or die "Cant open file $entry $!\n"; while () { $host = $_; if ( $host =~ /^hostname/ ) { $host =~ s/^hostname\s(.*)/$1/; chomp $host; open OUTPUTFILE, ">$host" or die "Cant create file $!\n"; print OUTPUTFILE ; close OUTPUTFILE; } } close CURRENT; }