-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |