After I applied appropriate indentation on the OP code (so I could read it), I noticed something odd about your print statement:
print $new $l;
Normally, the 'print' function takes a list, which means that there should be commas between its args. I didn't have your data files on hand, so I did a couple quick one-liner experiments:
perl -le '$x="foo"; $y="bar"; print $x $y' perl -le '$x="foo"; $y="bar"; print $x, $y'
The first of those (without a comma) didn't print anything at all. The second one printed "foobar", as expected.

In the first try, without the comma, the 'print' function is trying to interpret $x as a file handle, and failing. In the absence of use warnings;' there wasn't even a hint about the problem, but a third experiment was more instructive:

perl -wle '$x="foo"; $y="bar"; print $x $y' print() on unopened filehandle foo at -e line 1.
Given that sort of condition, the default (prudent) behavior is for the print function to do nothing at all.

Sorry - total brain fart on on the stuff above. I forgot that $new was supposed to be a file handle. Oh well.

UPDATE: Random Walk has apparently solved your problem, but here's a slightly different version of the same solution anyway... (possibly a bit less different from the OP code, possibly a little simpler, and, well, at least this allows my reply to have some usable content):

use strict; use warnings; my $name = "name"; # open( my $rfh,'<', $entry ) or die "cannot open > $entry: $!"; open( my $new, '>', "$name\_new.txt" ) or die "cannot open: $!"; my $signal1 = "s_abc_out"; my $signal2 = "s_abc_in"; my $label = "label"; while ( <DATA> ) { # would be <$rfh> for you if ( /$signal2\(\d+\).*\s*<=\s*$signal1\(\d+\).*/ ) { for my $i ( 0 .. 6 ) { my $j = $i + 1; print $new "$signal2\_rrfa_$label($j) <= $signal1\_rrfa_$l +abel($i);\n"; } } else{ print $new $_; } } __DATA__ ................................. s_abc_in(1450) <= s_abc_out(324); s_abc_in(1451 <= s_abc_out(1450); .................................

In reply to Re: Filehandle problem by graff
in thread Filehandle problem by amma

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.