Hi List I have a configuration file and I would like to split the main file into multiple small files and push the small temp. files into an array. My config file looks like this
GRC01;8;8;1;1;323U6_SIU-8;2048;2048;20;0;OFF GRC01;12;12;2;2;134S1_SIU-12;2048;2048;20;0;OFF GRC01;25;25;3;3;016S1_SIU-25;2048;2048;20;0;OFF GRC01;29;29;4;4;018S1_SIU-29;2048;2048;20;0;OFF GRC01;31;31;5;5;060S1_SIU-31;2048;2048;20;0;OFF GRC01;48;48;6;6;023S1_SIU-48;2048;2048;20;0;OFF GRC01;49;49;7;7;023S1_SIU-49;2048;2048;20;0;OFF GRC01;51;51;8;8;030S1_SIU-51;2048;2048;20;0;OFF GRC01;52;52;9;9;031S1_SIU-52;2048;2048;20;0;OFF GRC01;54;54;10;10;033S1_SIU-54;2048;2048;20;0;OFF GRC01;69;69;11;11;078S1_SIU-69;2048;2048;20;0;OFF GRC01;77;77;12;12;097S1_SIU-77;2048;2048;20;0;OFF GRC01;86;86;13;13;070S1_SIU-86;2048;2048;20;0;OFF GRC01;103;103;14;14;039S1_SIU-103;2048;2048;20;0;OFF GRC01;110;110;15;15;047S1_SIU-110;2048;2048;20;0;OFF GRC01;114;114;16;16;051S1_SIU-114;2048;2048;20;0;OFF GRC01;115;115;17;17;052S1_SIU-115;2048;2048;20;0;OFF GRC01;120;120;18;18;089S1_SIU-120;2048;2048;20;0;OFF GRC01;125;125;19;19;140S2_SIU-125;2048;2048;20;0;OFF GRC01;133;133;20;20;300S2_SIU-133;2048;2048;20;0;OFF GRC01;140;140;21;21;315S2_SIU-140;2048;2048;20;0;OFF GRC01;154;154;22;22;100S1_SIU-154;2048;2048;20;0;OFF GRC01;156;156;23;23;103U6_SIU-156;2048;2048;20;0;OFF GRC01;160;160;24;24;120S1_SIU-160;2048;2048;20;0;OFF GRC01;162;162;25;25;126S1_SIU-162;2048;2048;20;0;OFF GRC01;165;165;26;26;101S1_SIU-165;2048;2048;20;0;OFF GRC01;175;175;27;27;302S1_SIU-175;2048;2048;20;0;OFF GRC01;207;207;28;28;203S1_SIU-207;2048;2048;20;0;OFF GRC01;225;225;29;29;321U6_SIU-225;2048;2048;20;0;OFF GRC01;233;233;30;30;333S1_SIU-233;2048;2048;20;0;OFF GRC01;238;238;31;31;338S1_SIU-238;2048;2048;20;0;OFF GRC01;335;335;32;32;335U6_SIU-335;2048;2048;20;0;OFF This config file has got 32 lines so I am planning to write a code which will create four tmp. files out of the main config file. I have written the following code. #!/usr/bin/perl use Tie::File; use strict; use warnings; my @config_file_contents; tie @config_file_contents, 'Tie::File', "GRC01_TG_SCGR_IPM_LIST" ###<-- This is main config file or die "Can't open filename"; my @tmp_config_array=@config_file_contents; untie @config_file_contents; my $last_element_index = $#tmp_config_array; my $counter = 1; my $start_index = 0; my $next_index = 8; for (my $i=0; $i<= $last_element_index; $i++) { print "inside for loop\n"; print "START=$start_index\n"; print "NEXT=$next_index\n"; my $file_to_write = "GRC01_TG_SCGR_IPM_LIST_$counter"; my @tmp_line_content = splice (@tmp_config_array,"$start_index","$next_index"); open my $WFH,'>',$file_to_write; foreach my $el (@tmp_line_content) { print "EL=[$el]\n"; next if /^\s*$/; print $WFH "$el\n"; } close($WFH); $start_index = ($next_index+1); $next_index = ($start_index+8); $i = $start_index; $counter++; # @tmp_line_content = undef; } while executing the code 4 tmp files are created but all of them are zero byte. Though in the print for first time "EL" I am getting 8 lines and second time "EL" prints 15 lines but line number 9-15 are skipped.Second time EL should start printing from line number 9 instead it starts printing from line number 18. But the counters like $start_index,$next_index are incrementing properly. Also I am getting warning message "splice() offset past end of array at ./ tie_file.pl line 22" Please provides some pointers on those points. Best Regards Anirban.