
FishMonger
Veteran
Aug 25, 2009, 7:39 AM
Post #14 of 16
(2516 views)
|
|
Re: [spider] [HELP] Using a Perl scrip to read a Text File and parse sinlge entries in seperate txt files
[In reply to]
|
Can't Post
|
|
Since the exact same output is going to multiple handles, I'd use IO::Tee. Since the print function takes a list, I'd use a single print statement and I'd also use descriptive names for the vars.
#!/usr/bin/perl use strict; use warnings; use IO::Tee; my $data_file = "Number.csv"; open my $CSV, '<', $data_file or die "Could not open $data_file $!"; while( <$CSV> ) { chomp; my($phone, $password) = split(/,/, $_); my $filename = "sip_$phone.cfg"; open my $sip_cfg, '>', $filename or die "Could not open $filename $!"; my $tee = IO::Tee->new(\*STDOUT, $sip_cfg); print $tee "LINE1 = $phone\n", "LINE1_PROXY = 1\n", "LINE1_CALLID = Sip Phone $phone\n", "USER = $password\n"; }
|