diff --git a/dirparser.pm b/dirparser.pm new file mode 100644 index 0000000..f6d73f8 --- /dev/null +++ b/dirparser.pm @@ -0,0 +1,53 @@ +package dirparser; + +sub dir_parser +{ + $filename = $_[0]; + open SOURCE, "< $filename" or die "Could not open $filename\n"; + open DEST, "> $_[1]" or die "Could not open $_[1]\n"; + while ($line = ) + { + if ($line =~ /Directory/) + { + # print $line; + $line =~ s/[a-zA-Z\s]+://; + chomp $line; + $dir = $line; + # print $line . $dir . "\n"; + } + else + { + if ($line =~ /\/ || $line =~ /File\(s\)/ || $line =~ /^\s$/ || $line =~ /Total\sFiles\sListed\:/ || + $line =~ /Dir\(s\)/ || $line =~ /Volume/) + { # do nothing + } + else + { + @component = split (/\s/,$line); + $path = "$dir" . "\\" . $component[$#component]; + print DEST $path . "\n"; + } + + } + } # end of while + close SOURCE; + close DEST; + +} + +sub dir_parser_b +{ + $filename = $_[0]; + open SOURCE, "< $filename" or die "Could not open $filename\n"; + open DEST, "> $_[1]" or die "Could not open $_[1]\n"; + while ($line = ) + { + chomp $line; + $line =~ s/^[A-Z]\://g ; + print DEST $line."\n"; + } # end of while + close SOURCE; + close DEST; +} + +1; \ No newline at end of file diff --git a/lsparser.pm b/lsparser.pm new file mode 100644 index 0000000..29274d5 --- /dev/null +++ b/lsparser.pm @@ -0,0 +1,48 @@ +package lsparser; + +sub ls_parser +{ + $file = $_[0]; + open SOURCE, "< $file" or die "Could not open the $file"; + open DEST,"> $_[1]" or die "Could not open $_[1]\n"; + while ($line = ) + { + if ($line =~ /\:$/) + { + $line =~ s/\:$//; + chomp $line; + $dir = $line; + $dir =~ s/\//\\/g; + + } + else + { + if ($line =~ /total\s[0-9]+/) + { # do nothing + } + else + { + if ($line =~ /^\s$/) + { # do nothing + } + else + { + @component = split (/\s/,$line); + if ($line =~ /->/) + { + $path = "$dir" . "\\" . $component[$#component - 2]; + } + else + { + $path = "$dir"."\\".$component[$#component]; + } + print DEST $path . "\n"; + } + } + } + } + close SOURCE; + close DEST; +} + +1; \ No newline at end of file diff --git a/separator.pm b/separator.pm new file mode 100644 index 0000000..c524950 --- /dev/null +++ b/separator.pm @@ -0,0 +1,33 @@ +package separator; + +sub separator +{ + $filename = $_[0]; + open(SOURCE, "< $filename") + or die "Could not open $filename\n"; + open DEST,"> $_[1]" or die "Could not open $_[1]\n"; + while ($line = ) + { + chop($line); + my @dirs = split(/\\/,$line); + my $no_of_dirs = @dirs; + #print $no_of_dirs; + for ($i = 1 ; $i < $no_of_dirs ; $i++ ) + { + for ($j = $i ; $j < $no_of_dirs; $j++ ) + { + print DEST $dirs[$j]; + if ($j < $no_of_dirs - 1) + { + print DEST "\/"; + } + } #end of for + print DEST "\n"; + } + } + close SOURCE; + close DEST; + +} + +1; \ No newline at end of file