in reply to Re: Re: How to route a format into a variable
in thread How to route a format into a variable

There is an example of a sprintf-like function emulating write in the Perl Formats documentation, reproduced below for convenience.

use Carp; sub swrite { croak "usage: swrite PICTURE ARGS" unless @_; my $format = shift; $^A = ""; formline($format,@_); return $^A; } $string = swrite(<<'END', 1, 2, 3); Check me out @<<< @||| @>>> END print $string;

    --k.


Replies are listed 'Best First'.
Re: Re: Re: Re: How to route a format into a variable
by ppm (Novice) on Feb 12, 2003 at 18:10 UTC
    @Kanji:

    yes, i saw this topic .. but i don't understand how to use this for my e.g. any help?

      You would no longer use the format statement, instead you would supply your formats as string arguments to the formline function, and access what has been formatted through the $^A variable (see perlvar). Page headers would no longer be automatically handled, but you don't seem to be using that feature of formats anyway.
Re: Re: Re: Re: How to route a format into a variable
by ppm (Novice) on Feb 12, 2003 at 18:17 UTC
    @Kanji:

    yes, i saw this topic . but i've no idea how to do this for my e.g. do you have any ideas?