in reply to How to implement printf like functions
Hi,
Could be something like this...
sub recordStatus { if($m_bUseLog and $iLogLevel <= $m_iLogLevel) { my $format = shift; my $string = sprintf $format, @_; return length $string if(print $m_sSourceFile $string); return -1; } }
This would be something like you have, having $m_bUseLog, $iLogLevel, $m_iLogLevel, $m_sSourceFile, as global variables. Where $m_sSourceFile is the FILEHANDLE...
In the C++ as in the Perl, you should add some errors check, from input and also define a common error return (if return -> croack)...
Regards,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to implement printf like functions
by Tanktalus (Canon) on Aug 29, 2005 at 14:12 UTC | |
by fmerges (Chaplain) on Aug 29, 2005 at 18:07 UTC |