<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: perl hack: commenting lines between two markers? in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-hack-commenting-lines-between-two-markers/m-p/5229217#M679670</link>
    <description>Outstanding!  I knew there was a better way to do that than what I was coming up with!&lt;BR /&gt;&lt;BR /&gt;Thanks alot!&lt;BR /&gt;&lt;BR /&gt;Doug</description>
    <pubDate>Wed, 10 Mar 2010 14:57:47 GMT</pubDate>
    <dc:creator>Doug O'Leary</dc:creator>
    <dc:date>2010-03-10T14:57:47Z</dc:date>
    <item>
      <title>perl hack: commenting lines between two markers?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-hack-commenting-lines-between-two-markers/m-p/5229214#M679667</link>
      <description>Hey;&lt;BR /&gt;&lt;BR /&gt;I'm having a hard time wrapping my mind around this one this morning; maybe under-caffeinated..&lt;BR /&gt;&lt;BR /&gt;I have a text file with two markers between which I want to be able to comment (or uncomment) lines.  &lt;BR /&gt;&lt;BR /&gt;I've got a beginning:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict; &lt;BR /&gt;my @lines = &amp;lt;&amp;gt;; my $lines = join*('',@lines);&lt;BR /&gt;my ($chunk) = $lines =~ m{^# mcsg_begins\n(.*?)#mcsg_ends}mgs;&lt;BR /&gt;$chunk =~ s/^/# /mg;&lt;BR /&gt;print $chunk;&lt;BR /&gt;&lt;BR /&gt;That comments out the lines between the markers but only in the variable $chunk; I can't, for instance, print out $lines and have the stanza commented.&lt;BR /&gt;&lt;BR /&gt;Anyone have a slick way of doing this?  Extra helping of eternal gratitude if there's a way to do it with a perl one-liner...&lt;BR /&gt;&lt;BR /&gt;Thanks for any hints/tips/suggestions.&lt;BR /&gt;&lt;BR /&gt;Doug O'Leary&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Mar 2010 14:30:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-hack-commenting-lines-between-two-markers/m-p/5229214#M679667</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2010-03-10T14:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: perl hack: commenting lines between two markers?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-hack-commenting-lines-between-two-markers/m-p/5229215#M679668</link>
      <description>&lt;!--!*#--&gt;Hi Doug:&lt;BR /&gt;&lt;BR /&gt;# perl -pe 's/^(.)/#$1/ if  (/mcsg_begins/../mcsg_ends/)' myfile&lt;BR /&gt;&lt;BR /&gt;...where:&lt;BR /&gt;&lt;BR /&gt;# cat myfile&lt;BR /&gt;line-1&lt;BR /&gt;line-2&lt;BR /&gt;line-3&lt;BR /&gt;mcsg_begins&lt;BR /&gt;line-1.1&lt;BR /&gt;line-2.1&lt;BR /&gt;line-3.1&lt;BR /&gt;mcsg_ends&lt;BR /&gt;line-4&lt;BR /&gt;line-5&lt;BR /&gt;line-6&lt;BR /&gt;&lt;BR /&gt;...yielding:&lt;BR /&gt;&lt;BR /&gt;line-1&lt;BR /&gt;line-2&lt;BR /&gt;line-3&lt;BR /&gt;#mcsg_begins&lt;BR /&gt;#line-1.1&lt;BR /&gt;#line-2.1&lt;BR /&gt;#line-3.1&lt;BR /&gt;#mcsg_ends&lt;BR /&gt;line-4&lt;BR /&gt;line-5&lt;BR /&gt;line-6&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 10 Mar 2010 14:40:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-hack-commenting-lines-between-two-markers/m-p/5229215#M679668</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-03-10T14:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: perl hack: commenting lines between two markers?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-hack-commenting-lines-between-two-markers/m-p/5229216#M679669</link>
      <description>Hi (again) Doug:&lt;BR /&gt;&lt;BR /&gt;I'm under-caffeinated too.  We don't need to capture in our substitution, just do:&lt;BR /&gt;&lt;BR /&gt;# perl -pe 's/^/#/ if (/mcsg_begins/../mcsg_ends/)' file&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 10 Mar 2010 14:45:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-hack-commenting-lines-between-two-markers/m-p/5229216#M679669</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-03-10T14:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: perl hack: commenting lines between two markers?</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-hack-commenting-lines-between-two-markers/m-p/5229217#M679670</link>
      <description>Outstanding!  I knew there was a better way to do that than what I was coming up with!&lt;BR /&gt;&lt;BR /&gt;Thanks alot!&lt;BR /&gt;&lt;BR /&gt;Doug</description>
      <pubDate>Wed, 10 Mar 2010 14:57:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-hack-commenting-lines-between-two-markers/m-p/5229217#M679670</guid>
      <dc:creator>Doug O'Leary</dc:creator>
      <dc:date>2010-03-10T14:57:47Z</dc:date>
    </item>
  </channel>
</rss>

