in reply to Multiline Regex replacement in Multiline file

This would be a far better question -- i.e., one that would be easier for us to help you with -- had you included some explanation of what's going wrong -- error messages; erroneous output (that is, output other than what you expected and wanted); computer begins to smoke; etc.

My guess, however, is that perhaps you saw something like this (where <t>nn is perhaps 14, 15, or 16, depending on what your header (hashbang, strict, warnings, etc) contains.):

Use of uninitialized value within %dic in substitution iterator at 110 +0671.pl line nn, <F> line 3. Use of uninitialized value within %dic in substitution iterator at 110 +0671.pl line nn, <F> line 3.

If so, Perl is basicly telling you it ran out of input at line 3 of your input file... which makes a lot of sense since your sample shows only two lines in the input file.

An ordinary way to deal with this is to read from F in a WHILE construct; other would be to test the read result for content (ie, len != 0 or similar).

UPDATE: PS: put code tags around data, as well as around code.


++$anecdote ne $data


Replies are listed 'Best First'.
Re^2: Multiline Regex replacement in Multiline file
by akamboj84 (Novice) on Sep 16, 2014 at 01:30 UTC
    Hi Mate, I am new to Perl Monks and posted my first question so now onwards will give more details. Thanks anyway for pointing out.

      But this wasn't your first question. It was the second question, although nearly a duplicate of your first one with the same title: Multiline Regex replacement in Multiline file. That question already received responses. Perhaps you could let us know how the new question relates to the answers you got the first time around, so that the help we provide is closer to what you need this second time around.

      The first one is better formatted (the sample data should be in code tags, just like the code is in code tags)... but that's because I edited it for you. This time it's your turn. ;) Writeup Formatting Tips.


      Dave