#!usr/bin/perl
# program takes a base part and changes some fields to show new part
#
use strict;
#use warning;
#use 5.280;
use Data::Dumper;
use Fcntl qw(:flock SEEK_END);
use Cwd 'abs_path';
# Info from Base Part Job report
my $base_part_test = '5237all5x_a1_rpt.txt';
my $base_part_file = '5237all5x';
my $base_part_file_uc = uc $base_part_file;
my $base_part_rev = 'a1';
my $base_part_rev_lc = lc $base_part_rev;
my $base_part_Customer = 'SA';
my $base_path = '/Product/SA_customer_product/'.$base_part_Customer.'/'.$base_part_file_uc.'/'.$base_part_file_uc.'_rev_'.$base_part_rev_lc.'/RetBuildReport';
my $Real_base_part_file = $base_path.'/'.$base_part_file.'_'.$base_part_rev.'_rpt.txt';
#check if the Report file exists in the directory then do the substitution of builder.
if ( -f $Real_base_part_file) {
# Info to New Buld Report
my $New_part_report = 'NEW_PART_REPORT.txt';
# Test what's inside the vars
print Dumper ( $base_part_file, $base_part_rev , $base_path, $Real_base_part_file );
# Creating a file
system "touch $New_part_report";
my $New_Part_Date = system "date";
open my $base_fh , '+<', $base_part_test or die;
open my $New_fh ,'>', $New_part_report or die;
while(my $line = <$base_fh>) {
if ($line eq "Builder : Xi Wong"){
print " found original builder : ";
Want to substitute builder Xi Wong to Lucca P. but not
sure how???
# then continue to write the rest of report
print $New_fh $line;
}
}
close($base_fh);
close($New_fh);
}
####
---------------------------------------
Basic Information:
---------------------------------------
Build Report Rev: 02
Builder: Xi Wong
Part Name: MG5237ALL5X
Customer Name: SI
Route: S5H2-12A
####
---------------------------------------
Basic Information:
---------------------------------------
Build Report Rev: 01
Builder: Lucca P.
Part Name: MG5415DP
Customer Name: SA
Route: S5H2-12A