On 08/29/2006 06:32 PM, 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...
[...]
Although this is very different from your program, it should
give you the general idea:
use strict;
use warnings;
use File::Slurp;
use File::Spec::Functions;
my @departments = q{
192.168.14.0|88|Sales|Richard Throop
192.168.16.0|90|Accounting|Juliet Rosenblatt
192.168.20.0|91|Logistics|Mark Mane
192.168.24.0|94|Security|Marlon Johnson
} =~ m/^\s*(.*)$/mg;
# print join "\n", @departments;
my $dir = catfile($ENV{HOME}, qw(tmp tmp));
foreach my $info (@departments) {
my $fname = (split /\|/, $info)[2];
$fname = catfile($dir, $fname);
print $fname, "\n";
write_file $fname, $info . "\n";
}
__HTH__
:-)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>