>The string "\\n" will not match a newline, it will match the two
>characters '\' and 'n'.

I believe that's what I'm doing. Here is my "test harness" until I get
this worked out:
Input is from an XML File.

#!/usr/bin/perl -w

# load modules
use DBI;
use XML::Simple;

# create xml object
$xml = new XML::Simple;

$filename=$ARGV[0];

# read nessus XML file
$data = $xml->XMLin($filename) or die("cannot load XML file");

sub fixer($){
    my $data = $_[0];
    if($data =~ m/Description :\\n\\n(.+)\.[\\n{2}]/){
      $temp = $1;
      print ("$temp\n\n");
      $alsotemp=$temp;
      print ("$alsotemp\n\n");
      $temp =~ s/\\n/ /;
      print ("$temp\n\n");
      $data=~ s/$alsotemp/$temp/g;
      print ("$data\n");
  }
}

fixer($data->{Report}->{ReportHost}->[0]->{ReportItem}->[0]->
{data});

Output is:
The remote service understands the CIFS (Common Internet File System)
\nor Server Message Block (SMB) protocol, used to provide shared access
\nto files, printers, etc between nodes on a network.\n\nSolution :\n
\nn/a\n\nRisk factor :\n\nNone\n\nPlugin output :\n\nA CIFS server is
running on this port

The remote service understands the CIFS (Common Internet File System)
\nor Server Message Block (SMB) protocol, used to provide shared access
\nto files, printers, etc between nodes on a network.\n\nSolution :\n
\nn/a\n\nRisk factor :\n\nNone\n\nPlugin output :\n\nA CIFS server is
running on this port

The remote service understands the CIFS (Common Internet File System)
or Server Message Block (SMB) protocol, used to provide shared access
\nto files, printers, etc between nodes on a network.\n\nSolution :\n
\nn/a\n\nRisk factor :\n\nNone\n\nPlugin output :\n\nA CIFS server is
running on this port

\nSynopsis :\n\nA file / print sharing service is listening on the
remote host.\n\nDescription :\n\nThe remote service understands the
CIFS (Common Internet File System)\nor Server Message Block (SMB)
protocol, used to provide shared access\nto files, printers, etc
between nodes on a network.\n\nSolution :\n\nn/a\n\nRisk factor :\n
\nNone\n\nPlugin output :\n\nA CIFS server is running on this port.\n
\n

Does this explain things better?
s/(?<=.)\n(?=.)/ /g isn't helping in tis instance
my first regex matches til the end of the line, when I only want up
until the first \n\n. even excepting that,
The first newline gets taken out, none after that, and that change
doesn't end up in the final product.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to