<commit_before>#!/usr/bin/perl -w
#
# Parse nmap scan tool : parse-nmapdata.pl
# Awfully written by: <NAME> <<EMAIL>>
# Version: .002
# 
# Changes: .002 - Got rid of that trailing comma
#
# Please make sure you have installed Nmap::Parser in perl before using this script.
# perl -MCPAN -e 'install Nmap::Parser'
#
use strict;

#
#
use Nmap::Parser;
my $np = new Nmap::Parser;

#
print "Enter filename of nmap xml (input):  ";
my $userFileName = <STDIN>;
chomp $userFileName;
exit 0 if ( $userFileName eq "" );
print "Enter output filename:  ";
my $userOutputFileName = <STDIN>;
chomp $userOutputFileName;
exit 0 if ( $userOutputFileName eq "" );
$np->callback( \&parseDataSub );

#
$np->parsefile($userFileName);

sub parseDataSub {
   my $host = shift;
   my @portLists;
   open( MYOUTFILE, ">>$userOutputFileName" );
   print MYOUTFILE "-p";
   for my $port ( $host->tcp_ports('open') ) {
      push @portLists, $port, ",";
   }
   chop $portLists[-1];
   print MYOUTFILE @portLists;
   print MYOUTFILE " ";
   print MYOUTFILE $host->addr, "\n";
   close(MYOUTFILE);
}<commit_msg>.003 - Update and clean<commit_after>#!/usr/bin/env perl
#
# Parse nmap scan tool : parse-nmapdata.pl
# Awfully written by: <NAME> <<EMAIL>>
# Version: .003
#
# Changes:  .003 - Cleaned up code a little more, changed shebang
#					  .002 - Got rid of that trailing comma
#
# Please make sure you have installed Nmap::Parser in perl before using this script.
# perl -MCPAN -e 'install Nmap::Parser'
#
use strict;
use warnings;

#
#
use Nmap::Parser;
my $np = new Nmap::Parser;

#
print "Enter filename of nmap xml (input):  ";
my $userFileName = <STDIN>;
chomp $userFileName;
exit 0 if ( $userFileName eq "" );
print "Enter output filename:  ";
my $userOutputFileName = <STDIN>;
chomp $userOutputFileName;
exit 0 if ( $userOutputFileName eq "" );

if ( -e $userOutputFileName ) {
    print
"Output file already exists. To append to this file, press y, to cancel press n:  ";
    my $fileTest = <STDIN>;
    chomp $fileTest;
    if ( $fileTest =~ /^[N]?$/i ) {
        exit 0;
    }
}

#
$np->callback( \&parseDataSub );

#
$np->parsefile($userFileName);

sub parseDataSub {
    my $host = shift;
    my @portLists;
    open( my $MYOUTFILE, ">>", "$userOutputFileName" )
      || die "Can't open $userOutputFileName";
    print $MYOUTFILE "-p";
    for my $port ( $host->tcp_ports('open') ) {
        push @portLists, $port, ",";
    }
    chop $portLists[-1];
    print $MYOUTFILE @portLists;
    print $MYOUTFILE " ";
    print $MYOUTFILE $host->addr, "\n";
    close($MYOUTFILE);
}
{'fraction_non_alphanumeric': 0.15321637426900586, 'fraction_numerical': 0.009746588693957114, 'mean_word_length': 3.5415929203539824, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3051701', 'n_tokens_mistral': 936, 'n_tokens_neox': 894, 'n_words': 276}