Hi all.
I'm new to Perl, and by new I mean I started looking at it yesterday. I inherited a Perl project from someone who retired from my employer and have been tasked with a few changes. They've all gone well...except for one. Here's the problem: I've got a chunk of text stored in a hash. The length of this text varies depending on the file we parse. Somtimes it's two chracters; other times, it's 100 or more. We output our results to a log file under column headings. Problem is, I've got the script spacing things using tabs, which work somewhat. Depending on the length of the string from the hash, the spacing gets all messed up and destroys our log file. Here's the code as it is now:
print LOG $key."\t\t\t\t\t".$gOccurrenceHash{$key}."\t".$gOccurrenceHash2{$key}."\n";
The headings are printed with this code:
print LOG "Object Name \t\t\t\t\t\t\t\t\tRef Count \t Scope \t Environment\n\n";
Some logs end up fine. Others (most) end up like this:
## OCCURRENCE Object Count
############################
Object Name Ref Count Scope Environment
index_seiseki_sougou.pdf_38839.9246990741_T_6.98255586e-002_0_0_6.98255586e-002 690 Global toppan-cache
index_seiseki_getsuji.pdf_38839.9244907407_T_6.98255586e-002_0_0_6.98255586e-002 644 Global toppan-cache
index_seiseki_nyudan.pdf_38839.9251851852_T_6.98255586e-002_0_0_6.98255586e-002 414 Global toppan-cache
index_seiseki_joho.pdf_38839.9249537037_T_6.98255586e-002_0_0_6.98255586e-002 345 Global toppan-cache
D000000000029.pdf_38996.2427314815_CB_25.511811_6.23622047e-002_646.299213_858.96 299 Global toppan-cache
D000000000029.pdf_38996.2427314815_CB_0_6.23622047e-002_620.787402_858.96 230 Global toppan-cache
D000000000001.pdf_38996.2375694444 115 Global toppan-cache
D000000000031.pdf_38996.2428703704 115 Global toppan-cache
D000000000032.pdf_38996.2380787037 115 Global toppan-cache
D100000000001.pdf_38993.9662962963 115 Global toppan-cache
D000000000030.pdf_38996.2428703704_CB_0_6.23622047e-002_620.787402_858.96 94 Global toppan-cache
D000000000031.pdf_38996.2428703704_CB_0_6.23622047e-002_620.787402_858.96 67 Global toppan-cache
D000000000030.pdf_38996.2428703704_CB_25.511811_6.23622047e-002_646.299213_858.96 46 Global toppan-cache
D000000000031.pdf_38996.2428703704_CB_25.511811_6.23622047e-002_646.299213_858.96 46 Global toppan-cache
Hopefully this will all be readable once it's posted. If not, please let me know and if you think you can help, I can send you some text files.
In case you're wondering, the tool I'm trying to fix parses PPML, and XML-based print job format for HP Indigo Presses.
Any help you can give me is very much appreciated. I have a fall back plan, but it's going to be messy and time-consuming to implement. Thanks!
I'm new to Perl, and by new I mean I started looking at it yesterday. I inherited a Perl project from someone who retired from my employer and have been tasked with a few changes. They've all gone well...except for one. Here's the problem: I've got a chunk of text stored in a hash. The length of this text varies depending on the file we parse. Somtimes it's two chracters; other times, it's 100 or more. We output our results to a log file under column headings. Problem is, I've got the script spacing things using tabs, which work somewhat. Depending on the length of the string from the hash, the spacing gets all messed up and destroys our log file. Here's the code as it is now:
print LOG $key."\t\t\t\t\t".$gOccurrenceHash{$key}."\t".$gOccurrenceHash2{$key}."\n";
The headings are printed with this code:
print LOG "Object Name \t\t\t\t\t\t\t\t\tRef Count \t Scope \t Environment\n\n";
Some logs end up fine. Others (most) end up like this:
## OCCURRENCE Object Count
############################
Object Name Ref Count Scope Environment
index_seiseki_sougou.pdf_38839.9246990741_T_6.98255586e-002_0_0_6.98255586e-002 690 Global toppan-cache
index_seiseki_getsuji.pdf_38839.9244907407_T_6.98255586e-002_0_0_6.98255586e-002 644 Global toppan-cache
index_seiseki_nyudan.pdf_38839.9251851852_T_6.98255586e-002_0_0_6.98255586e-002 414 Global toppan-cache
index_seiseki_joho.pdf_38839.9249537037_T_6.98255586e-002_0_0_6.98255586e-002 345 Global toppan-cache
D000000000029.pdf_38996.2427314815_CB_25.511811_6.23622047e-002_646.299213_858.96 299 Global toppan-cache
D000000000029.pdf_38996.2427314815_CB_0_6.23622047e-002_620.787402_858.96 230 Global toppan-cache
D000000000001.pdf_38996.2375694444 115 Global toppan-cache
D000000000031.pdf_38996.2428703704 115 Global toppan-cache
D000000000032.pdf_38996.2380787037 115 Global toppan-cache
D100000000001.pdf_38993.9662962963 115 Global toppan-cache
D000000000030.pdf_38996.2428703704_CB_0_6.23622047e-002_620.787402_858.96 94 Global toppan-cache
D000000000031.pdf_38996.2428703704_CB_0_6.23622047e-002_620.787402_858.96 67 Global toppan-cache
D000000000030.pdf_38996.2428703704_CB_25.511811_6.23622047e-002_646.299213_858.96 46 Global toppan-cache
D000000000031.pdf_38996.2428703704_CB_25.511811_6.23622047e-002_646.299213_858.96 46 Global toppan-cache
Hopefully this will all be readable once it's posted. If not, please let me know and if you think you can help, I can send you some text files.
In case you're wondering, the tool I'm trying to fix parses PPML, and XML-based print job format for HP Indigo Presses.
Any help you can give me is very much appreciated. I have a fall back plan, but it's going to be messy and time-consuming to implement. Thanks!