in reply to Re: trivial wrapping
in thread trivial wrapping

     That way is much too complicated. A format will serve the purpose very well in this case...

format FH = ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ $var1 . $var1 = "hahhahahahaThis is my great big long string of more " . "than 60 characters hahahahahahahahahahahahahaahahahhahah" ; open (FH, "> somefile.txt"); write FH; close FH;

Summary:
  1. The circumflex (^) indicates that it is a variable length record
  2. The less-than signs (<) left-justify the printed value
  3. The squiggles (tildes (~)) suppress blank lines and keep printing lines until the variable is empty.
  4. This also destroys the variable

     I got this directly from the Camel's mouth... All hail the Camel (O'Reilly Programming Perl).

Invulnerable. Unlimited XP. Unlimited Votes. I must be...
        GhodMode

Replies are listed 'Best First'.
Re: Re: Re: trivial wrapping
by BrowserUk (Patriarch) on Nov 18, 2002 at 14:52 UTC

    Now show me a FORMAT that will wrap two strings to 60 wide and interleave them as requested by the OP and I'll buy you a coffee next time I see you:)


    Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
    Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
    Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
    Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

      I like strong coffee, no cream, lotsa sugar :) ...

      format FILE = ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $var1 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $var2 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $var3 ------------------------------------------------------------ ------------------------------------------------------------ . $var1 = "11111111111111111111". "11111111111111111111". "11111111111111111111". "11111111111111111111". "11111111111111111111". "11111111111111111111". "11111111111111111111". "11111111111111111111". "11111111111111111111"; $var2 = "22222222222222222222". "22222222222222222222". "22222222222222222222". "22222222222222222222". "22222222222222222222". "22222222222222222222". "22222222222222222222". "22222222222222222222". "22222222222222222222"; $var3 = "33333333333333333333". "33333333333333333333". "33333333333333333333". "33333333333333333333". "33333333333333333333". "33333333333333333333". "33333333333333333333". "33333333333333333333". "33333333333333333333"; open (FILE, "> file.txt") or die "Could not open file\n$!\n"; while ( ($var1 ne "") and ($var2 ne "") and ($var3 ne "") ){ write FILE;

      It's a little more complex, but I still like the format better :)
      Here's the output...
      cat file.txt 111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333 ------------------------------------------------------------ ------------------------------------------------------------ 111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333 ------------------------------------------------------------ ------------------------------------------------------------ 111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333 ------------------------------------------------------------ ------------------------------------------------------------ 111111111111111111111111111111111111111111111111111111111111 222222222222222222222222222222222222222222222222222222222222 333333333333333333333333333333333333333333333333333333333333 ------------------------------------------------------------ ------------------------------------------------------------ 1111111111111111111111111111111111111111 2222222222222222222222222222222222222222 3333333333333333333333333333333333333333 ------------------------------------------------------------ ------------------------------------------------------------

      Invulnerable. Unlimited XP. Unlimited Votes. I must be...
              GhodMode