in reply to Counting Characters

$string = "teststring"; sprintf "%s%n", $string, $len; print "$len";
that is so evil.

Replies are listed 'Best First'.
(jcwren) RE: RE: Counting Characters
by jcwren (Prior) on Jul 15, 2000 at 16:32 UTC
    If you blew this one off because it looked like bad code, go check it out again. The key is the '%n'.
    perldoc -f sprintf
    I'd have to give this the Most Obscure award.

    --Chris

    Update: Someone thought I was directing this to the author. Indeed not. You, the reader, should look at the code again. jlistf used a little known sprintf formatting technique to make this work. And it's just too cool to not file this tidbit away.

    e-mail jcwren