Hi,
I've tried to fiure this out on my own but hit a road block. I'm reading in
an external file, then doind a search and replace. I am also using the
following to break lines at 256 characters
use Text::Wrap qw(wrap $columns $huge);
$columns = 256;
$huge = "die";
Problem I'm having is if there is a tag like below
<test attr1="var" attr2="var" attr3="var" attr4="var" attr5="var"
attr6="var" attr7="var">
It may get broken like so:
<test attr1="var" attr2="var" attr3="var"
attr4="var" attr5="var" attr6="var" attr7="var">
I don't want this to happen. How can I avoid this? The program breaks lines
at 256 characters. If its in the middle of a tag I want it to break before
or after and NOT in between. How do I do this?
Code below:
#!/usr/local/bin/perl
require 5.000;
use Env;
use Cwd;
use File::Basename;
use Text::Wrap qw(wrap $columns $huge);
$columns = 256;
$huge = "die";
my $infile = $ARGV[0];
open(FILEREAD, "$infile.txt");
open(FILEWRITE, "> $infile.temp");
$i=1;
while (<FILEREAD>)
{
chomp $_;
$_ =~ s/<p>/\n<p>/ig;
print FILEWRITE wrap("", "", $_), "\n";
$i++;
}
close FILEWRITE;
close FILEREAD;