in reply to detection in Loop condition

See How do I post a question effectively? and define $line before, and after

Replies are listed 'Best First'.
Re^2: detection in Loop condition
by maha (Novice) on Jan 21, 2012 at 04:57 UTC

    sorry..i ve nearly 30 chapters in a book and it is XML file and i'm getting one by one chapter for closing the body tag

    the tag should close before reference|notes|ack,these statement may come in any order,in a chapter, which statement come first,the tag should close before that

      Do you mean your input file is an XML-file, but with the <body> tag not closed or closed at a wrong place? If the <body> tag is not closed then your XML-file is invalid and you better remedy that first.

      If you just want to move the <body> tag to some other place (which means you want to re-order your XML-tree structure) then consider that XML-files are best handled with one of the many XML-parsers and not with regexes.

      If you can show a (small / stripped down, but still relevant) example of your XML-file, you will get a much better reply from the Monks here.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      So instead of providing one line of input, that represents your real input, you'd rather attempt to describe it using English?

      So what we , random strangers, can interpret your English the way you do, provided you didn't omit anything, and then construct a $line correctly? Both how it looks before the change you want to make, and after?

      So that we can then craft a regular expression, that you can use to make the substitution you're attempting?

      But you yourself said you're not an native English speaker, so we'd be guessing the whole time.

      You've managed to provide input in all these previous postings of yours XML tag closing, XML tag closing, string concatenation, split function using multiple delimiters

      Do you want help or not?