gnu@perl has asked for the wisdom of the Perl Monks concerning the following question:

In the following code I want to indent the first field a number of characters. If I do not include the first '@' before the '<<<<<' I get the left arrows printed on my screen.

My solution was to ad a '@' in the beginning of the line with a empty variable correlating to it. This does get my text that I want to display to indent but I don't like the idea of having to include an empty value just to do it.

I know I must be missing something.

Also, I realize the code here is terriable looking, I just threw it together as an example.

TIA, Chad.

my ($Company, $Department, $DeptCode, $Address, $Page, $Address2, $Pho +neNumber, $NumPieces, $DatRcvd, $Month, $Day, $Year, $SubmittedBy) = +('US LEC','','','8210 University Exec Park Dr.','1 of 4','','704.319. +6297','20','','10','07','2002','Chad Johnson'); my $NULL = ''; format STDOUT = @<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<< $NULL, $Company @<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<< +<<<<<<<<<<< $NULL, $Department, $DeptCode @<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<< $NULL, $Address, @<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<< $Page, $Address2 @<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<< +<<<<<<<<<<< $NULL, $PhoneNumber, $NumPieces @<<<<<<<<<<<<<<@<<@<<@<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $DatRcvd, $Month,$Day,$Year, $SubmittedBy . write;
As it is written above I get(the format I want):
US LEC 8210 University Exec Park Dr. 1 of 4 704.319.6297 20 10 07 2002 Chad Johnson
If I take out the '@' in the beginning of each line I get:
<<<<<<<<<<<<<<US LEC <<<<<<<<<<<<<< <<<<<<<<<<<<<<8210 University Exec Park Dr. 1 of 4 <<<<<<<<<<<<<<704.319.6297 20 10 07 2002 Chad Johnson

Replies are listed 'Best First'.
Re: indenting with 'format'
by zigdon (Deacon) on Oct 07, 2002 at 16:54 UTC
    I think all you need is to replace the @<* in the beginning of the line with spaces. See man perlform.

    -- Dan

      Yeah, that would make sense. Especially since without the @<* in the beginning I got the "<<<<" printed to the screen, the spaces should print as is as well.

      Thanks, I guess I just wasn't seeing the solution although it was hitting me in the face like a tree while skiing.

Re: indenting with 'format'
by VSarkiss (Monsignor) on Oct 07, 2002 at 17:34 UTC

    If you don't have a variable indent, it's pretty easy: just put the fields exactly where you want them to end up. For example,

    format STDOUT = @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<< $Company, $DeptCode
    and so on. In other words, you don't need to fill up the whole line. More info at perlform.

    Or are you trying to do something fancy with the indentation level? If so, please clarify.