in reply to Re: 80 characters long
in thread 80 characters long

Not wrap them, but write them to seperate lines (carriage return at column 81) Please if what I am asking does not make sense, let me know, I will try yo explain it another way.

Replies are listed 'Best First'.
Re^3: 80 characters long
by ikegami (Patriarch) on Sep 27, 2007 at 18:33 UTC

    That's what wrapping means.

    ...Although Text::Wrap will only break on a word boundary. Did you want to break at colomn 80 unconditionally, even if it's in the middle of a word?

    $text =~ s/(.{80})(?!$)/$1\n/gm;
      Thanks, here is what I have from the examples
      use Text::Wrap $Text = "C:\\ACK_DATA\\ar835.dat"; open(IN,$a) || die "cannot open $a for reading: $!"; $Text::Wrap::columns = 80; print wrap('', '', @Text);
      but I get an error ""C:\ACK_DATA\ar835.dat" is not exported by the Text::Wrap module Can't continue after import errors at perl-form.pl line 3 BEGIN failed--compilation aborted at perl-form.pl line 3."

        You never created or assigned anything to @Text.
        ( oh, that error is cause you're missing a semicolon at the end of the use statement. )

        use Text::Wrap qw( wrap ); my $file_name = "C:\\ACK_DATA\\ar835.dat"; open(my $fh, $file_name) or die "Unable to open input file \"$file_name\": $!\n"; $Text::Wrap::columns = 80; while (<$fh>) { print wrap('', '', $_); }

        Updated to fix error mentioned in reply.

        Note that it will help you a lot with your future coding if you use strictures (use strict;use warnings;) at the top of each script you write. They will detect various coding errors early and force you to avoid some coding practices that tend to make code harder to write correctly.


        Perl is environmentally friendly - it saves trees