#!/usr/bin/perl -w ###################################################################### +########

It is usually good practice to use the warnings and strict pragmas:

#!/usr/bin/perl use warnings; use strict; ###################################################################### +########

open FH, "<:encoding(UTF-16)", "$file_folder\\$ori_datafile" or die + "can't open file"; ... #open (NEWFILE, ">$file_folder\\$new_datafile") or die "can't open fil +e"; open (NEWFILE, ">:encoding(UTF-16)","$file_folder\\$new_datafile") or +die "can't open file"; open (FIXLOG, ">$log_folder\\$fix_log") or die "can't open file"; open (ERRLOG, ">$log_folder\\$error_log") or die "can't open file"; open (FIXRPT, ">$log_folder\\$rptfile") or die "can't open file";

It is usually a good idea to include the $! or $^E variable in your error message so that you know why open failed.


chop; # aviod \n in last field;

Most modern Perl programs use chomp instead of chop.


$ori_line_number=$ori_line_number+1;

That is usually written as:

$ori_line_number += 1;

Or simply:

$ori_line_number++;

$pipe_thisline=($_ =~ tr/\|/\|/);

tr/// does not interpolate so the back-slashes are not necessary.    Also, if the replacement character list is the same as the search character list then the replacement character list can be omitted, and the default binding is to the $_ variable so that can be omitted as well, so:

$pipe_thisline = tr/|//;

if ($pipe_thisline eq $right_pipes) { ... if ( $pipe_thisline > $right_pipes ) {

Are $pipe_thisline and $right_pipes numeric or text, because you are using numeric comparison in one place and text comparison in another.


if ($ori_line_number eq 1) { print FIXRPT "Report on Fixing Line Bre +aks in CT_Vendor_Summary File\n\n"; ... else { if ($pipe_sum eq 0 ) { ... elsif ($pipe_sum eq $right_pipes ) {

Why are you using text comparison on numeric values?


In reply to Re^3: Perl to Read/Write Window Unicode Text files by Anonymous Monk
in thread Perl to Read/Write Window Unicode Text files by maylin

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.