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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -