Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Re: How to route a format into a variable

by Kanji (Parson)
on Feb 12, 2003 at 18:07 UTC ( [id://234773]=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://234773]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2024-04-19 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found