Ron McKeever wrote:
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???
I'm sorry, Ron, but it doesn't appear that your question has anything to do with CGI, so you probably need to look elsewhere for answers. But to open a file for writing, you would need to use the "open" function. Any basic perl textbook will have a section on file I/O.

Sean

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to