First uncomment the use warning and change 'warning' to 'warnings'. Your intent to use strictures (strict and warnings) is good, but ignoring errors is really bad.

Now consider the following self contained example script:

use strict; use warnings; my $template = <<FILE; --------------------------------------- Basic Information: --------------------------------------- Build Report Rev: 02 Builder: Xi Wong Part Name: MG5237ALL5X Customer Name: SI Route: S5H2-12A FILE my $outText; my %subs = ( 'Build Report Rev' => '01', 'Builder' => 'Lucca P.', 'Part Name' => 'MG5415DP', 'Customer Name' => 'SA', 'Route' => 'S5H2-12A' ); # Info to New Buld Report open my $base_fh, '<', \$template; open my $New_fh, '>', \$outText; while (my $line = <$base_fh>) { if ($line =~ /^([^:]+):(\s+)/ && exists $subs{$1}) { $line = "$1:$2$subs{$1}\n"; } print $New_fh $line; } close $base_fh; close $New_fh; print $outText;

Prints:

--------------------------------------- Basic Information: --------------------------------------- Build Report Rev: 01 Builder: Lucca P. Part Name: MG5415DP Customer Name: SA Route: S5H2-12A

which I think does what you want. Notice the hash used to store the substitution values. In a real life example that could be populated from a database or from a file containing the required edits. Although, in real life it feels like this whole exercise should be done using a database. You may be interested in Databases made easy for an introduction to using databases.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

In reply to Re: Edit a New file in place after reading it in by GrandFather
in thread Edit a New file in place after reading it in by perlynewby

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.