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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Warn in modules 3

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I cannot get 'warn' statements to print to screen from within a module, do I need to enable them in some way?

Keith
 
Your script web-based?

STDERR gets printed to the apache logs by default (again I'm making an assumption here).

If you want to print warnings to the browser window, include the following:
Code:
*STDERR = *STDOUT;
 
Incidentally, if you want to restrict that to only a part of your script, you can do the following. Note that the second warning goes only to the logs, not to the screen:
Code:
#!/usr/bin/perl -w
use strict;
use CGI qw( :standard );

{
   local *STDERR = *STDOUT; # this only applies inside this block

   print header,start_html, h1('Hello World');

   warn 'error!';

}
print p('printed to stdout');
warn 'error!';

print end_html;
 
Thanks ishnid, I only really need to view the warn statements during development as any failures are handled within the calling program.
I am in the process of learning about modules and as I also need to decode RTF files in a future project, I thought I would use that as my experimental module. I have since realised that all the RTF modules are beta versions so reliability is not guaranteed.
I have even considered writing my own module but the RTF file format seems to have been created to make interfacing as hard as possible.

Keith
 
but the RTF file format seems to have been created to make interfacing as hard as possible.

That's probably why the modules are all still in beta :)
 
This is for a web app and all I need to do is get the text from the document and basic formatting such as bold, centre, heading, underline etc. and convert them into a format compatible with CSS. It should be simple but I cannot understand the way the files nest curly braces. None of it is documented very well either.

Keith
 
You could just use the CGI::Carp module also, it shows how to get warnings printed to the browser. It does print them as comments in the thml code but if you are debugging from the command line you will see them. When I am debugging CGI scripts in a browser I print the warnings at the bottom of the page in a textarea box so they are easily viewable.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
The RTF format is owned by Microsoft, and is at v1.9 as of Feb 2007. The full spec is available (as a *.doc file, naturally) from
Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Thanks for your help but I am finding the file format a real challenge to decode. Before I go about reinventing the wheel, I am going to post a question on the web designers forum to see how other designers handle documents uploaded by admins.
It may be that I am approching this the wrong way.

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top