I am try to use part of someones elses code that creats the data file which
prints out like this:
ip|result|deptA|data
ip|result|deptB|data
ip|result|deptC|data
My goal instead of having all the data in one big file is to loop this and
create a file for each result.
So I would have a deptA.out file with deptA info then a deptB.out
file with dept b info and etc...
#!/usr/bin/perl
use strict;
my %dept = ();
while (<DATA>)
{
# safely remove a carriage return from the file
chomp $_;
next if ($_ eq "");
my @lines = split(/[|]/);
#$line[3] = %dept++;
$dept{$lines[2]}++;
#print "$line";
#foreach $line (@lines) {
#print $line."\n";
#}
}
#print "@{[ %dept ]}\n";
#print "%dept";
my @array=keys(%dept);
print "All of the elements stored in %dept are @array \n";
__DATA__
ip|result|deptA|data
ip|result|deptB|data
ip|result|deptC|data
How would I create a file for each hash then print to it???
Thanks,
Ron
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>