in reply to Re: Debug help
in thread Debug help

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 ?

Replies are listed 'Best First'.
Re^3: Debug help
by planetscape (Chancellor) on Dec 21, 2008 at 09:39 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 ?

    Wild guess... some sort of looping construct?

    HTH,

    planetscape
Re^3: Debug help
by AnomalousMonk (Archbishop) on Dec 21, 2008 at 15:22 UTC
    ... 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); }