"H.Merijn Brand" <h.m.brand@xs4all.nl> writes: > $ perl -wle'print 0x' > 0 This should be a syntax error. (Unless, of course, there's a formal statement in the Perl docs that says that this is valis.) > my $base16 = tonumbase (16, 8364, "0x"); # 0x20ac > > just brainstorming there (the optional argument - when passed - adds a > (predefined) prefix unless the content is a unknown prefix in which > case it prefixes the passed argument. Trying to understand... tonumbase( 16, 8364 ); # 20ac or 0x20ac? tonumbase( 16, 8364, "0x" ); # 0x20ac tonumbase( 16, 8364, "0X" ); # 0X20ac or 0X20AC? tonumbase( 16, 8364, "xy" ); # xy20ac??? If I recall correctly, we already have a built-in that does this. It's called sprintf. sprintf( "%x", 8364 ); # 20ac sprintf( "0x%x", 8364 ); # 0x20ac sprintf( "0x%X", 8364 ); # 0x20AC -- JohanThread Previous | Thread Next