-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcatenate.pl
46 lines (35 loc) · 1.04 KB
/
concatenate.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl -w
use Cwd 'abs_path';
use constant false => 0;
use constant true => 1;
$directory="dataset";
if (@ARGV>0){
$directory = $ARGV[0];
}
print "\n****************************\n";
print "******** TESTs ******\n";
print "****************************\n";
print "** Univer. of Sapienza ***\n";
print "****************************\n\n";
print "Usage: perl concatenate.pl directory\n";
print "Result: \n\tdirectory.samplings\n";
$num_records=0;
open FILE_INSERT, ">",$directory.".samplings";
opendir(DIR, $directory);
@files = readdir(DIR);
$i=1;
foreach $file(@files)
{
if (($file ne ".") && ($file ne "..")){
open(DAT, $directory."/".$file)|| die("Could not open file results!");
foreach $line (<DAT>)
{
# uncomment to erase final \n of each line
# chomp($line);
print FILE_INSERT $i."\t".$line;
}
$i+=1;
close(DAT);
}
}
close(FILE_INSERT);