There does not seem to be anything wrong with the code you posted. I understand it can be difficult to write an SSCCE when you do not know what is wrong. Perhaps this will help. As you can see, the following code does what I think you want without error. Please modify it to demonstrate your error. Post the failing code. Remember, we have to be able to run it and reproduce your error message.
>type crickson.pl use strict; use warnings; my $arg = \'$infile1'; my $infile1 = \"one_score\t999"; my $score=100000; open my $IN, '<', $arg or die "error opening list of files"; while (<$IN>) { $_ = eval $_; # Bad practice - Use only for 'in-memory' file. open my $IN1, '<', $_ or die "error opening file $_"; while (local $_ = <$IN1>) { my @temp = split /\t/; if ($temp[1] < $score) { warn "\$temp[1] not defined\n" if !defined $temp[1]; warn "\$score not defined\n" if !defined $score; print "$temp[1] < $score\n"; } } } >perl crickson.pl 999 < 100000 >
Bill

In reply to Re: Variable scope issue by BillKSmith
in thread Variable scope issue by crickson

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.