Your code does not compile. Please do yourself a huge favor and use warnings; and use strict; at the start of every file. This is especially important for a novice Perler.
Even with strict and warnings, your code still has syntactic problems. The monks like to see working code, even if it does not do all (or even most) of what you want. Please see Short, Self-Contained, Correct Example.
Some syntactic thoughts:
-
$b[$j] =s~/"//g; What is this statement supposed to do? Will it even compile?
-
if ($j==1 && my @arr = grep { $_ =~ /\"1"$/ } @b); Will this compile?
-
else Will this compile?
Some best-practices thoughts:
-
my @a = <$fh1>; Is this supposed to read all lines from the file handle? Then why not name the variable @lines or @input_lines (since you want to transform them and then produce something like an @output_lines array) instead?
-
Similar objections apply to array names like @arr and @b
-
if ($j==1 && my @arr = grep { $_ =~ /\"1"$/ } @b); Assuming this actually compiled, which @arr in the script is referred to in the following @arr = map{$_ = "P"} @arr; statement? (There are two @arr arrays floating around in the script.)
-
@arr = map {$b[$j] - 1} (1..$#b); A similar @arr confusion attaches to this statement ...
-
print @arr; ... and to this.
These comments are dashed off quickly. Although it may seem that way, I don't mean to be blunt or dismissive. I hope you will take them as food for thought.
Give a man a fish: <%-{-{-{-<
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.