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

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."

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

    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.

        Oops, me bad
        use Text::Wrap qw( );
        should be
        use Text::Wrap qw( wrap );

        A reply falls below the community's threshold of quality. You may see it by logging in.
Re^5: 80 characters long
by GrandFather (Saint) on Sep 27, 2007 at 20:08 UTC

    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