in reply to Re: length of 1's
in thread length of 1's

use warnings results in this warning;

Use of uninitialized value in numeric eq (==) at bin2runs.pl line 32

Without any better ideas, I tried changing the ==0 to ==$zero, and initializing $zero earlier (my $zero =0), to no success. Other than the warnings the script works.

Replies are listed 'Best First'.
Re^3: length of 1's
by ikegami (Patriarch) on Apr 27, 2009 at 05:07 UTC
    Not for the code you gave. Line 32 is a blank line. I can't speculate about code I know nothing about.
      Here is all my code, warning on first if line.
      !/usr/bin/perl -w use strict; open(INFILE,"<$ARGV[0]") or die "can't open $ARGV[0]"; open(OUTFILE,">$ARGV[1]") or die "can't open $ARGV[1]"; my @result = split '', 'abcdefghijklmno'; my @arg1 = (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); my %rules; # Build the rules hash $rules{$arg1[$_]} = $result[$_] for 0 .. $#result; my $run = 0; my @bin = (); my @newseq = (); while ( <INFILE> ) { chomp; @bin= split(//, $_); for my $i (0..$#bin) { if ($bin[$i]==0){ $run=0; push @newseq,$run; } elsif ($bin[$i]==1 && $bin[$i+1]==0||$bin[$i+1]==0)){ $run++; push @newseq, $run; } else { $run++; } } } my $m = $#newseq+1; for (1 .. $m) { if ( $_ % 80 != 0){ print OUTFILE "$rules{$newseq[$_-1]}"} else{ print OUTFILE "$rules{$newseq[$_-1]}\n"; } }

        warning on first if line.

        Errors in a statement can appear to originate on the first line of the statement. That means the warning can be (and is) issued by the elsif condition.

        I already told you how to fix it (3rd item). It occurs when the last element of @bin is a one and you peek past then end of the array.

      32 is this line ( Ive not posted all the code as most is not relevant) if ($bin$i==0){

        You can't get that warning from that line of the code you posted.

        Have you addressed the problems ree and I brought up? What's the point in continuing if you don't address those first.

        Ive not posted all the code as most is not relevant

        It doesn't have to be your original code but post runnable code that actually exhibits the problem. Right now, what you posted appears to be just as irrelevant to the problem as the code you didn't post.