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

Esteemed Monks, I'm almost embarassed to ask this - but I cannot find what appears to be a solid answer to my question. How may I print out lines longer than 72 chars (columns) wide (or long if that's how you want to think about it...) to a file? I'd rather tell perl to allow long lines than go the "text wrapping" route, but if wrapping is the only feasible solution then so be it. Isn't there some global setting I can set at the top of my script? Thanks, rspence

Replies are listed 'Best First'.
Re: Printing long(er) lines
by dragonchild (Archbishop) on Jun 08, 2004 at 01:27 UTC
    It is wrapping because your window is 72 columns wide. Try looking at the file in a longer (wider?) window.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

      Hi dragonchild - I am experiencing this problem in writing my data to a file - this is not a display issue. When opening the output file with vi I have the last bit of my data - a 6th string - on a line below where everything else (the first 5 strings..) is printed. And yes, this happens with every line. No, there is no "\n" in my "print" command. I can only surmise that there is something in either my perl - or - unix environment that is causing this newline behavior. I first thought it to be a perl phenomenon but now I'm wondering if it is something like $TERM that is causing this....
Re: Printing long(er) lines
by Zaxo (Archbishop) on Jun 08, 2004 at 01:31 UTC

    Just go ahead and print them to the file. Perl doesn't place any such limits on line length.

    After Compline,
    Zaxo

Re: Printing long(er) lines
by hsinclai (Deacon) on Jun 08, 2004 at 03:55 UTC
    Heya,

    Earlier you said..
    When opening the output file with vi ...

    Are you looking at the output file in vi? vim?
    You didn't mention cat, or, a pager (like less or more).

    Are you on a stock linux machine? If so, your vi may be vim.

    If so, check your

    /etc/vimrc
    /usr/local/etc/vimrc
    or, your ~/.vimrc

    for a vim text wrapping directive such as:
    set textwidth=72
    If you're using the stock vi on Solaris or BSD or something else there's textwrap controls too.. I don't know them off the top of my head.. I think it's the "wraplen" directive ..

    cat your outputfile in a large xterm at the command line - see if you have the same problem.. that is, without using an editor?

    As hinted at by Zaxo and Dragonchild, this probably has not to do with Perl:)
      All, Thanks for replying - I've been sitting here too long. I was getting newlines because I assigned a variable to the output of a command that, yes, returns a newline after its data. Deduct points for me. All I needed was chomp. Sorry - please move on. rspence
Re: Printing long(er) lines
by baruch (Beadle) on Jun 08, 2004 at 02:36 UTC

    Hi, rspence. What makes you think the lines are shortened? How can you tell how long the lines are?


    בּרוּך
      I am printing out (using "print") 6 strings. Cumulatively they cover somewhere between 71-74 chars including a single char (space or comma,) in between each string. What I end up with are the first 5 strings on a line (usually 60-63 chars) with the 6th string on a line below for each set. This happens with every single print command. Honestly I have no "\n" in the print statement. Also - I am writing this to a file created by sysopen. I'm beginng to think that this is not a perl problem but a unix (TERM?) environment problem. But I'm still in the dark...