in reply to Re: Re: (golf)String Concats or: playing with substr()
in thread (golf)String Concats or: playing with substr()

I suspect that Masem meant to use "%s" rather than "%f": sprintf "%${length}s", $string;

Replies are listed 'Best First'.
Re4: (golf)String Concats or: playing with substr()
by Albannach (Monsignor) on May 18, 2001 at 23:42 UTC
    Or rather:

    sprintf "%${length}.${length}s", $string;

    as it is the number following the dot that gives the maximum field width when using the s. You could also left-justify by throwing a - in after the % if you like.

    --
    I'd like to be able to assign to an luser

      Thanks for the description!
      sprintf "%-$args{length}.$args{length}s", ${$args{string}};
      Worked just fine for my application. Now, I'm off to bigger and better things. It is Monday after all.

      _14k4 - webmaster@poorheart.com (www.poorheart.com)