in reply to Re: How to implement printf like functions
in thread How to implement printf like functions
Close, I think. However, given that we're coming from C++ to Perl, chances are that "m_" means "member variable". In other words, we're in an object method here.
sub recordStatus { my $self = shift; if($self->{UseLog} and $iLogLevel <= $self->{LogLevel}) { my $format = shift; my $fh = $self->{SourceFile}; my $string = sprintf $format, @_; return length $string if(print $fh $string); return -1; } }
Although, to be honest, the return code from the function probably doesn't matter. I've left it in as a strict interpretation of the OP would mandate it, but likely we could bypass the intermediate sprintf and just printf directly to the output, returning the boolean value that printf returns. It would change the signature by a small bit, but it would probably be a good bit. ;-) Strict porting isn't that great of an idea in the long term anyway.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to implement printf like functions
by fmerges (Chaplain) on Aug 29, 2005 at 18:07 UTC |