×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Reporting at the end of a script?

Reporting at the end of a script?

Reporting at the end of a script?

(OP)
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:

push @my_error , "value1,value2,value3";
push @my_error , "err1,err2,err3";

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

RE: Reporting at the end of a script?

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.
http://www.missioncriticallinux.com

RE: Reporting at the end of a script?

(OP)
Well, if you have a list such as:

"abcde,This is error 1,Coment 1"
"aw,Error 2,com2"

and you want to get:

Col1   Col2             Col3
====   ====             ====
abcde  This is error 1  Comment 1
aw     Error 2          com2


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

RE: Reporting at the end of a script?

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.
http://www.missioncriticallinux.com

RE: Reporting at the end of a script?

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

RE: Reporting at the end of a script?

(OP)
hmer,I will look at the references you provided.

goboat, thanks for the example.

Thierry


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close