in reply to open a new xml file if line count exceeds 4000 lines

thanks for suggestion ! i shall try to put my queries in more matured fashion :)For now am unable to think logic on file spliting /writing into a new file once it exceeds sum count rather number of lines !Your help is greatly appreciated !
  • Comment on Re: open a new xml file if line count exceeds 4000 lines

Replies are listed 'Best First'.
Re^2: open a new xml file if line count exceeds 4000 lines
by Anonymous Monk on May 29, 2012 at 07:21 UTC

    For now am unable to think logic on file spliting /writing into a new file once it exceeds sum count rather number of lines !Your help is greatly appreciated !

    Its hard to devise new logic when the logic you already have is hard to determine.

    It is easier to see the current logic once you cleanup the code. Then you can work on changing the logic because its easier to see what is missing.

    If you want something new, here you go

    while( $xfactor > 0 ){ my $newfile = sprintf 'new-x-%d-%d', $xfactor, $nimblefoot; MahFourThousand( $newfile, $xfactor, $nimblefoot ); $xfactor--; } sub MahFourThousand { my $counter = 0; while( $counter < 4000 ){ ## print one line $counter++; ## print 10 lines $counter += 10; ... } }

    That is how I'd start changing your program, but I'm not 100% sure what you're after.

    If you go ahead and make the changes we suggest, we'll help you make the next set of changes.