apj has asked for the wisdom of the Perl Monks concerning the following question:

HI. . . I'm creating a mail message and would like to format the body using format. The only way I can think of to do that is write to a file and then reread the file into a variable which doesn't sound very perlish. Is there a better easier way - maybe something similar to the recent STDERR solution using tie (Catch messages to STDERR)? Sort of like:
format FORMATFH = @<<<< $yadda . write(FORMATFH); # somehow get FORMATFH into $foo (the operative part) # goes here --><--- # so that I can go like this: $object_that_takes_string_arg->open($foo);
Does that seem odd? Thanks for any ideas. . .

-- Andy

Replies are listed 'Best First'.
Re: Format as sprintf++
by Roy Johnson (Monsignor) on May 07, 2004 at 20:18 UTC
      Looks like a great perlish feature for 5.8. Unfortunately I'm constrained to 5.6.1. Thanks for your reply, though - I didn't know about that feature.

      -- Andy
Re: Format as sprintf++
by haoess (Curate) on May 07, 2004 at 20:15 UTC

    See »perldoc -q "into a string"«. (Sorry, no hyperlink. perldoc.com is not working for a few days.)

    -- Frank

      Very cool - I should have thought to look there. Thanks -

      -- Andy