in reply to Debug help

Substr outside of the string at line 42. <$fh> line 2.

$index (300) is greater than the the length of $text (69).

Use of Uninitialized value in concatenation or string at line 42. <$fh> line 4.

As a result of the previous problem, subst returned undefined.

Use of uninitialized value in hash element at line 34. <$fh> line 4.

$key is undefined, which means that split returned less than two values, which means $key didn't contain a "|" before the split. I wonder what $key contained...

Replies are listed 'Best First'.
Re^2: Debug help
by ashnator (Sexton) on Dec 21, 2008 at 08:56 UTC
    Actually I was doing for a single line ACTAGTACGTACGATCAGTAC but now there are mutiple lines like ACGTGACGTACGTACGTACGTA AGTACGATCACCCCCGTAGACG ACGTAGACATCAGATCGATAGT Howto take care of this in my code ?
      Actually I was doing for a single line ACTAGTACGTACGATCAGTAC but now there are mutiple lines like ACGTGACGTACGTACGTACGTA AGTACGATCACCCCCGTAGACG ACGTAGACATCAGATCGATAGT Howto take care of this in my code ?

      Wild guess... some sort of looping construct?

      HTH,

      planetscape
      ... mutiple lines like ACGTGACGTACGTACGTACGTA AGTACGATCACCCCCGTAGACG ACGTAGACATCAGATCGATAGT ...
      From looking at your example data, my guess is that you are working with data records composed of multiple lines of data. Also from your example, it seems that each record begins with a '>' character.

      If these guesses are acurate, it may be useful to set the input record separator variable $/ (see perlvar) to '>', then read each record with a single statement and then remove all newlines from the record with a substitution.

      Note, however, that because the first record of the file begins with a '>', the first record read from the file (any stuff before the first '>') is junk and must be ignored.

      E.g. (untested):

      $/ = '>'; # throw away first (junk) record defined(<$fh>) or ($! and die "reading: $!"); while (defined(my $record = <$fh>) or ($! and die "reading: $!")) { $record =~ s{ \n }{}xmsg; process($record); }
      Update: Since a <$fh> record read reads up to and including the input record separator string specified in $/ (or to the end of the file), there should probably be a chomp in that while loop to remove the extraneous '>' character at the end of each record:
      while (defined(my $record = <$fh>) or ($! and die "reading: $!")) { chomp $record; # remove $/ string $record =~ s{ \n }{}xmsg; process($record); }
A reply falls below the community's threshold of quality. You may see it by logging in.