i am not getting errors as well as output

That’s because you’ve removed

use strict; use warnings;

from the head of your script, although they were there in the original. With use strict restored, the errors return:

Global symbol "$count" requires explicit package name at test.pl line +13. Global symbol "@line" requires explicit package name at test.pl line 1 +5. Global symbol "@line" requires explicit package name at test.pl line 1 +9. Global symbol "@line" requires explicit package name at test.pl line 2 +5. test.pl had compilation errors.

You need to declare my $count and my @line before the while loop, so that they will still be visible in the following for loop:

... my (@line, $count); while (<$fhConditions>) { push @line, $_; $count++; } for (my $i = 0; $i < $count; $i++) { my @pos = $line[$i] =~ /chr[0-9]\s+(.+?)\s/g; ...

See the section “Scope” in the “Functions” chapter of chromatic’s Modern Perl, available free online at http://modernperlbooks.com/books/modern_perl/.

Note: In your original question, you gave a sample of the contents of your first input file (1.txt), but not of the second (2.txt), so it’s difficult to see what your script is trying to do.

Athanasius <°(((><contra mundum


In reply to Re^3: How to get rid of the errors in my perl script by Athanasius
in thread How to get rid of the errors in my perl script by Anonymous Monk

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.