Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reporting at the end of a script? 1

Status
Not open for further replies.

Tve

Programmer
May 22, 2000
166
FR
Hi,

I have a general question about reporting.

Usually, my scripts perform text operations on large files, such as converting them from one format to another format.

I run checks as I go and I handle the errors. This all works fine, but I am now looking for a solution to report errors at the end of the script. Often, to report an error, I need to provide several strings (of course, often not the same lengths).

I was thinking of appending them to an @my_error array in a CSV format:
[red]
push @my_error , "value1,value2,value3";
push @my_error , "err1,err2,err3";
[/red]
I was hoping to use a standard module to print them out.

Is this the way to go? If it is, which module should I use?

Thanks,

Thierry
 
Why do you think you need a standard module to print them out? What special processing do you want to do? Seems according to your explanation you will have a @my_error array - why not just loop through the elements of the array and print out your error messages?

foreach $error (@my_error) {
print $error . "\n";
}

What more needs to be done?
Hardy Merrill
Mission Critical Linux, Inc.
 
Well, if you have a list such as:
[red][tt]
"abcde,This is error 1,Coment 1"
"aw,Error 2,com2"
[/red][/tt]
and you want to get:
[red][tt]
Col1 Col2 Col3
==== ==== ====
abcde This is error 1 Comment 1
aw Error 2 com2
[/red][/tt]

In unix, I used "NAWK printf" function to do this, but under windows I do not have this tool.

I hope this is clear.

Thierry
 
The "Programming Perl" 2nd Edition p. 121-127 has a section titled "Formats". Here's the first sentence:

Perl has a mechanism to help you generate simple,
formatted reports and charts. It can keep track of
things like how many lines on a page, what page
you're on, when to print page headers, and so on.

In fact, there's a perldoc devoted to perl formats - display it by doing "perldoc perlform".

Is this what you were looking for?
Hardy Merrill
Mission Critical Linux, Inc.
 
maybe this is what you are looking for..... printf is another option that uses a little different style of format.

#!/usr/local/bin/perl
@fields = ('field1','field2','field3');
printf "%-10s%-10s%-8s\n", ('COL1','COL2','COL3');
print "========= ========= ========\n";
printf "%-10s%-10s%-8s\n", @fields;


keep the rudder amid ship and beware the odd typo
 
hmer,I will look at the references you provided.

goboat, thanks for the example.

Thierry


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top