I am trying to write a sequence of files out. I seem to have run into a problem, where all of the records end up in the same file. I am not sure why this is happening. Granted it is the first time I am trying to do something like this. As always your help is greatly appreciated.
I call the sub with two values; the first value is the first two digits of an account code. A sample account would look like: 01-B4 123456 and a tabbed record that I want written to a file that would look similar to: 1\t2\t20071107\t01-B4 123456\tPAID\t91.40
All the records appear in the file, it ‘s just they all end up in the same file. I was expecting the directory to look something like:
msg_beta_4250.txt
msg_beta_4450.txt
msg_beta_1240.txt
Any thoughts or recommendations on what I might look for to correct his behavior?
Update, bad copy and paste.push(@passVars, $passCompCode); push(@passVars, $passLogRecord); write_msg_File(@passVars); sub write_msg_File { my $compCodeStr = $_[0]; my $logDataStr = $_[1]; my $logCompCode; $logCompCode = get_Comp_Code($compCodeStr); my $outFile = "/root/acs/out/msg_beta_" . "$logCompCode" . "\.txt"; #my $outFile = "/home/clr/log/msg" . "$logCompCode" . "\.txt"; open (WRECORD, ">> $outFile") or warn "Cannot Write Record! - $!"; print WRECORD $logDataStr; close (WRECORD); system "chown apache:apache $outFile"; system "chmod a=rw $outFile"; } #sub sub get_Comp_Code { my $companyRef = $_[0]; $companyRef =~ s/^0*//; my @companyArray = ("0000","4250","4450","3943","3943","4095","4241 +","1240","3943","4250","3943","1850","1850","4450","4450","1900","185 +5","1855","1855","1855","1863","1872","1855","1865","1855","1870","18 +55","3436","0000","1389","1780","0000","1872","3943","1864","3438","0 +000","1864","1864","1864","1240","1240","1240","1551","1392","1392"," +0000","1391","1451","0000","1397","4450"); if (($companyRef >= 52) || ($companyRef <= -1)) { return "0000"; } # if my $companyCode = $companyArray[$companyRef]; return $companyCode; } #sub
In reply to How to write a sequence of files? by kensaigm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |