Print to new file for each results
- From: rmckeever@xxxxxxxxxxxxx (Ron McKeever)
- Date: Wed, 30 Aug 2006 00:16:25 -0400 (EDT)
I am tring to use part of someones elses code that creates a 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.
This is not exactly doing what I need:
#!/usr/bin/perl
use strict;
my %dept = ();
while (<DATA>)
{
chomp $_;
next if ($_ eq "");
my @lines = split(/[|]/);
#$line[3] = %dept++;
$dept{$lines[2]}++;
$dept{$lines} = $value;
#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??? Any help, thanks.
Thanks,
Ron
.
- Follow-Ups:
- Re: Print to new file for each results
- From: Ken Foskey
- Re: Print to new file for each results
- From: John W. Krahn
- Re: Print to new file for each results
- Prev by Date: Re: Time::Local let me faint
- Next by Date: Re: Print to new file for each results
- Previous by thread: Re: Print to new file for each results
- Next by thread: Re: Print to new file for each results
- Index(es):