Hi,
 
I can't seem to figure this out. I am reading in a xml file. Searching specific 
tags and adding a carriage return since data truncates. I'm breaking the lines 
at 256 characters (could be more). The problem is that sometimes a tab will get 
broken which I can't have. How can I have the script break the line either 
before or after the tag?
 
See below <link how it breaks.
 
ex.
 
<para>text text text text text text text text text text text text text text 
text text 
text text text text text text text text text text text text text text text text 
<link var="?" 
var2="?" var="?"> text text </para>
 
Below is my script. What am I not doing right?
 
 
 
Syntax: perl test.pl input
 
 
#!/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.xml");
 open(FILEWRITE, "> $infile.temp");
   $i=1;
  while (<FILEREAD>)
  {
   chomp $_;
   
   $_ =~ s/<\?xml/\n<\?xml/ig;
   $_ =~ s/<!DOCTYPE/\n<!DOCTYPE/ig;
         
   print FILEWRITE wrap("", "", $_), "\n";
   $i++;
  }
 close FILEWRITE;
close FILEREAD;

                                          

Reply via email to