Perl - How to split a file into smaller files -
i need advice how make perl program able split file smaller files using number line.
for example:
perl split.pl --file="data.txt" --numberline=2
input
data.txt:
line1 line2 line3 line4
output
data1.txt
line1 line2
data2.txt
line3 line4
or
perl split.pl --file="data.txt" --numberline=1
data1.txt
line1
data2.txt
line2
data3.txt
line3
data4.txt
line4
or perl split.pl --file="data.txt" --numberline=3
data1.txt
line1 line2 line3
data2.txt
line4
split:
system("split -l 2 $file");
Comments
Post a Comment