Do you mean that you want to remove the code lines you show from all of the *.pm files? If so, you could so this with in-place editing and a flip-flop (..) operator. You have to make sure you escape any regular expression meta-characters in the code lines you use to delineate start and end of the section to remove.

knoppix@Microknoppix:~/perl/Monks$ ls d971401/ File1.pm File2.pm File3.pm File4.pm File5.pm knoppix@Microknoppix:~/perl/Monks$
knoppix@Microknoppix:~/perl/Monks$ head -99 d971401/* ==> d971401/File1.pm <== package File1; Some lines of code here my $t0 = [gettimeofday]; my $time = tv_interval ( $t0, [gettimeofday]); my @timeData = localtime(time); $time= join(':', @timeData); if($time =~m#^(.*?)\:(\d+)\:(\d+).*?$#) { $time = $3 . ':' . $2 . ':' . $1; } more code here 1; ==> d971401/File2.pm <== package File2; Some lines of code here my $t0 = [gettimeofday]; my $time = tv_interval ( $t0, [gettimeofday]); my @timeData = localtime(time); $time= join(':', @timeData); if($time =~m#^(.*?)\:(\d+)\:(\d+).*?$#) { $time = $3 . ':' . $2 . ':' . $1; } more code here 1; ==> d971401/File3.pm <== package File3; Some lines of code here my $t0 = [gettimeofday]; my $time = tv_interval ( $t0, [gettimeofday]); my @timeData = localtime(time); $time= join(':', @timeData); if($time =~m#^(.*?)\:(\d+)\:(\d+).*?$#) { $time = $3 . ':' . $2 . ':' . $1; } more code here 1; ==> d971401/File4.pm <== package File4; Some lines of code here my $t0 = [gettimeofday]; my $time = tv_interval ( $t0, [gettimeofday]); my @timeData = localtime(time); $time= join(':', @timeData); if($time =~m#^(.*?)\:(\d+)\:(\d+).*?$#) { $time = $3 . ':' . $2 . ':' . $1; } more code here 1; ==> d971401/File5.pm <== package File5; Some lines of code here my $t0 = [gettimeofday]; my $time = tv_interval ( $t0, [gettimeofday]); my @timeData = localtime(time); $time= join(':', @timeData); if($time =~m#^(.*?)\:(\d+)\:(\d+).*?$#) { $time = $3 . ':' . $2 . ':' . $1; } more code here 1; knoppix@Microknoppix:~/perl/Monks$
knoppix@Microknoppix:~/perl/Monks$ perl -ni.BAK -e ' print unless m{^my \$t0 = \[gettimeofday\];} .. m{^\s+\}};' d971401/*. +pm knoppix@Microknoppix:~/perl/Monks$ ls d971401/* d971401/File1.pm d971401/File3.pm d971401/File5.pm d971401/File1.pm.BAK d971401/File3.pm.BAK d971401/File5.pm.BAK d971401/File2.pm d971401/File4.pm d971401/File2.pm.BAK d971401/File4.pm.BAK knoppix@Microknoppix:~/perl/Monks$
knoppix@Microknoppix:~/perl/Monks$ head -99 d971401/*.pm ==> d971401/File1.pm <== package File1; Some lines of code here more code here 1; ==> d971401/File2.pm <== package File2; Some lines of code here more code here 1; ==> d971401/File3.pm <== package File3; Some lines of code here more code here 1; ==> d971401/File4.pm <== package File4; Some lines of code here more code here 1; ==> d971401/File5.pm <== package File5; Some lines of code here more code here 1; knoppix@Microknoppix:~/perl/Monks$

I hope that I have guessed correctly and that this is helpful.

Cheers,

JohnGG


In reply to Re: How to delete mutiple line from many pm files at one time by johngg
in thread How to delete mutiple line from many pm files at one time by Priti24

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.