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

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;

Replies are listed 'Best First'.
Re^4: 80 characters long
by aixmike (Novice) on Sep 27, 2007 at 19:13 UTC
    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.

        thanks for your patience. I tried your code, but it gives me an error "Undefined subroutine &main::wrap called at perl-form.pl line 10." this is the print wrap line.
          A reply falls below the community's threshold of quality. You may see it by logging in.

      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