in reply to Formatting Question

you either want format() (see perlfunc), or here-docs, which are explained in perldata
update: and perlform

Replies are listed 'Best First'.
Re: Re: Formatting Question
by debiandude (Scribe) on May 27, 2004 at 13:28 UTC

    It was format. Thanks. I guess another quick question would be is there a way to abbreviate the number of <<'s or >>'s. Like I have filled that is just 100 characters of filler (whitspace) it seems silly to have to put 100 >'s.

    As I am writing this I am thinking maybe printf would be better. But can you left and right justify in printf. I am not sure.

      $_ = 'justify my love'; printf "[%20s] and [%-20s]\n", $_, $_;
      will give you
      [ justify my love] and [justify my love ]
      You can actually combine sprintf and formats, if you want to avoid specifying the width as a picture. You can use @* as your format for a line, and do all the actual formatting of the line with a sprintf. That assumes that you have some reason for using format/write instead of doing it all with printf.

      The PerlMonk tr/// Advocate
        Thanks. printf is just what I need. I appreciate all the help.