lolly has asked for the wisdom of the Perl Monks concerning the following question:
Hi, this program outputs strings which are greater in length than 250 characters (each string begins with '>'). however, i am trying to wrap the string so that it prints 60 characters per line, and its not working. The program runs fine but the wrapping doesn't work. where am i going wrong??
#! /usr/local/bin/perl -w use strict; open (INPUT, $ARGV[0]) or die "unable to open file"; my $count = 1; my $line; while (<>) { chomp; $line = $_; $line =~ s/(.{60})/$1\n/g; if (/>/) { ++$count; } print "\>$count\n", $_, "\n\n" if length $_ >= 250; } close INPUT;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: why won't it wrap??
by tadman (Prior) on May 01, 2002 at 10:40 UTC | |
| |
(cLive ;-) Re: why won't it wrap??
by cLive ;-) (Prior) on May 01, 2002 at 10:42 UTC | |
by Anonymous Monk on May 01, 2002 at 14:12 UTC | |
Re: why won't it wrap??
by Maclir (Curate) on May 01, 2002 at 14:46 UTC | |
by Fletch (Bishop) on May 01, 2002 at 15:07 UTC |
Back to
Seekers of Perl Wisdom