F
Faith Greenwood
Hi,
I am trying to split a file into two parts. My file is as follows:
data
1
2
3
end data
data
4
5
6
end data
I want to split the file into two parts, w/ the first file having the
following:
data
1
2
3
end data
and the second file having:
data
4
5
6
end data
I have the following code:
open(SPLITTY, "<", "/media/hd/test.txt");
my $linecnt=0;
while(<SPLITTY>){
if(/data/../end data/){
open(YESSPLIT,">>","/media/hd/testtwo.txt");
print YESSPLIT $_;
close YESSPLIT;
}
}
close SPLITTY;
however, this just copies the original file to a new file. How can I
tweak this to get what I am looking for?
I am trying to split a file into two parts. My file is as follows:
data
1
2
3
end data
data
4
5
6
end data
I want to split the file into two parts, w/ the first file having the
following:
data
1
2
3
end data
and the second file having:
data
4
5
6
end data
I have the following code:
open(SPLITTY, "<", "/media/hd/test.txt");
my $linecnt=0;
while(<SPLITTY>){
if(/data/../end data/){
open(YESSPLIT,">>","/media/hd/testtwo.txt");
print YESSPLIT $_;
close YESSPLIT;
}
}
close SPLITTY;
however, this just copies the original file to a new file. How can I
tweak this to get what I am looking for?