<?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: parse a file and merge another file (before a mark) in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-and-merge-another-file-before-a-mark/m-p/5869449#M638894</link>
    <description>&lt;P&gt;&amp;gt;are the changes in regulatory?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you mean are they correct?&amp;nbsp; You could just try it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;when a blank line before the "mark" exists, can this blank line be removed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like this:&lt;/P&gt;&lt;P&gt;my $was_blank = 0;&lt;/P&gt;&lt;P&gt;while (&amp;lt;&amp;gt;) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( /^\s$/ ) {&amp;nbsp; # found blank line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; if ($was_blank) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf "\n";&amp;nbsp; # multiple blank lines, print all but last&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; $was_blank = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; next;&amp;nbsp; # suppress&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( /^$start/ ) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /$start/ and print @contents; printf "\n$start\n";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; next;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($was_blank) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf "\n";&amp;nbsp; # print previous blank line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; $was_blank = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print;&lt;BR /&gt;}&lt;/P&gt;</description>
    <pubDate>Sat, 17 Nov 2012 02:58:06 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2012-11-17T02:58:06Z</dc:date>
    <item>
      <title>parse a file and merge another file (before a mark)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-and-merge-another-file-before-a-mark/m-p/5866545#M638893</link>
      <description>&lt;P&gt;hello ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a new issue due this thread&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hpe.com/t5/Languages-and-Scripting/parse-a-file-and-merge-another-file/m-p/5236212#M40604" target="_blank"&gt;parse a file and merge another file&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i want to insert another file before a fix defined mark and keep the mark.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in the other solution the marks will be replace with the variable insert file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;START_TOKEN="TEST_MARK" ./filter.pl variable1 template&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#!/usr/bin/perl -i

use strict;
use warnings;
my $start    = $ENV{START_TOKEN} || die "no START token defined\n";
my $varfile  = shift or die "Usage $0: varfile infile\n";
open( my $fh, "&amp;lt;", $varfile ) or die "can't open '$varfile': $!\n";
my @contents = &amp;lt;$fh&amp;gt;;
close $fh;
while (&amp;lt;&amp;gt;) {
    if ( /^$start/ ) {
        /$start/ and print @contents; printf "\n$start\n";
        next;
    }
    print;
}
1;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;are the changes in regulatory ? a little wish will be , when a blank line before the "mark" exists , can this blank file maybe removed ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2012 17:26:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-and-merge-another-file-before-a-mark/m-p/5866545#M638893</guid>
      <dc:creator>support_billa</dc:creator>
      <dc:date>2012-11-14T17:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: parse a file and merge another file (before a mark)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-and-merge-another-file-before-a-mark/m-p/5869449#M638894</link>
      <description>&lt;P&gt;&amp;gt;are the changes in regulatory?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you mean are they correct?&amp;nbsp; You could just try it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;when a blank line before the "mark" exists, can this blank line be removed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like this:&lt;/P&gt;&lt;P&gt;my $was_blank = 0;&lt;/P&gt;&lt;P&gt;while (&amp;lt;&amp;gt;) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( /^\s$/ ) {&amp;nbsp; # found blank line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; if ($was_blank) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf "\n";&amp;nbsp; # multiple blank lines, print all but last&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; $was_blank = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; next;&amp;nbsp; # suppress&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ( /^$start/ ) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /$start/ and print @contents; printf "\n$start\n";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; next;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($was_blank) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf "\n";&amp;nbsp; # print previous blank line&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; $was_blank = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print;&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Sat, 17 Nov 2012 02:58:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-and-merge-another-file-before-a-mark/m-p/5869449#M638894</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2012-11-17T02:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: parse a file and merge another file (before a mark)</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-and-merge-another-file-before-a-mark/m-p/5888401#M638895</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tested your version and in same cases i have to insert a blank line. so i extended with my moderate skills your version :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;START_TOKEN="TEST_MARK" ./filter.pl Y variable1 template&amp;nbsp;&amp;nbsp; # Y ... YES and insert a blank line&lt;BR /&gt;START_TOKEN="TEST_MARK" ./filter.pl N variable1 template&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;use strict;
use warnings;

my $was_blank = 0;

my $start             = $ENV{START_TOKEN} || die "no START token defined\n";
my $insert_blank_line = shift or die "Usage $0: blank_line([Y|N]) varfile infile [n-infile]\n";
my $varfile           = shift or die "Usage $0: blank_line([Y|N]) varfile infile [n-infile]\n";

my $chr_line = ($insert_blank_line eq 'Y' ? "\n" : "");

open( my $fh, "&amp;lt;", $varfile ) or die "can't open '$varfile': $!\n";
my @contents = &amp;lt;$fh&amp;gt;;
close $fh;
while (&amp;lt;&amp;gt;) {
    if ( /^\s$/ ) {  # found blank line
       if ($was_blank) {
          printf "\n";  # multiple blank lines, print all but last

       }
       $was_blank = 1;       
       next;  # suppress
    }
    if ( /^$start/ ) {
        /$start/ and printf "$chr_line"; print @contents; printf "\n$start";
        next;
    }

    if ($was_blank) {
       printf "\n";  # print previous blank line
       $was_blank = 0;
    }
    print;
}
1;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2012 10:36:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parse-a-file-and-merge-another-file-before-a-mark/m-p/5888401#M638895</guid>
      <dc:creator>support_billa</dc:creator>
      <dc:date>2012-12-03T10:36:26Z</dc:date>
    </item>
  </channel>
</rss>

