Skip to content

Commit

Permalink
Added the dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tr4nc3 authored Aug 7, 2019
1 parent a23b4e8 commit 9eb565e
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 0 deletions.
53 changes: 53 additions & 0 deletions dirparser.pm
Original file line number Diff line number Diff line change
@@ -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 = <SOURCE>)
{
if ($line =~ /Directory/)
{
# print $line;
$line =~ s/[a-zA-Z\s]+://;
chomp $line;
$dir = $line;
# print $line . $dir . "\n";
}
else
{
if ($line =~ /\<DIR\>/ || $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 = <SOURCE>)
{
chomp $line;
$line =~ s/^[A-Z]\://g ;
print DEST $line."\n";
} # end of while
close SOURCE;
close DEST;
}

1;
48 changes: 48 additions & 0 deletions lsparser.pm
Original file line number Diff line number Diff line change
@@ -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 = <SOURCE>)
{
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;
33 changes: 33 additions & 0 deletions separator.pm
Original file line number Diff line number Diff line change
@@ -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 = <SOURCE>)
{
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;

0 comments on commit 9eb565e

Please sign in to comment.