Re: 16b hex conversion

2004-03-03 Thread eric-amick
> > It looks like you're doing this. Say if I'm way off-beam.
> 
> > sub d2h16 {
> >   sprintf "%04.4X", shift;
> > }
> 
> I don't believe it. That's amazing. That's not "off-beam", 
> that's "nail on the head". Is there a way of returning that
> as a value instead of printing it? 

sprintf() already returns it as a string; it's printf() that prints to the default 
filehandle. (As an aside, "%.4X" will produce the same result.)

--
Eric Amick
Columbia, MD
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: 16b hex conversion

2004-03-03 Thread Rob Dixon
Ed Chester wrote:
> 
> > sub d2h16 {
> >   sprintf "%04.4X", shift;
> > }
> 
> I don't believe it. That's amazing. That's not "off-beam", 
> that's "nail on the head". Is there a way of returning that
> as a value instead of printing it? 
> 
> ed, not worthy. 

Quite as worthy as I! But be careful with your boundary values
if they matter. I don't know what your app is, but leave it as
a sub if you can: Perl's excellent at in-line optimisation

d2h16 answers with the value, so you can

  my $answer = d2h16 31254;

It's the language that's cute: not me. Thank Larry!

Rob

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs