in reply to Re: Perl Parser, need help
in thread Perl Parser, need help

#!/your/perl/here
use strict;
use warnings;
my $sequence;

while (my $line = <>)
{
# Sequence keyword
if ($line =~ /^Sequence:\s+(contig\d+)/)
{
$sequence = $1; # save the sequence
next;
}

# Parameter keyword
#next if ($line =~ /^Parameters:\s+(.*)$/)

# print any other non-blank lines
if ($line != /^\s*$/)
{
print "$sequence $line";
next;
}
}

QM..

I have tried your script, before i mark the parameter keyword out, the script have compilation error at line 24. After i mark that line, i manage to run the script with error, the compiler stated : isn't numeric in numeric ne (!=) at trf.pl line 19. But I still manage to get the output, after edited in excel. But funny thing is that, for those result starting from 1 (eg: 1 45 7 6.4 7 97 0 72 35 44 4 15 1.67 CCTAAAC CCTAAACCCTAAACCCTAAACCCTAAACCCTAAGCCCTAAGCCCT, it won't show in the parsed result... i wonder what's with this.. but anyway thank u so much!

Replies are listed 'Best First'.
Re^3: Perl Parser, need help
by QM (Parson) on May 19, 2005 at 22:37 UTC
    I did mention that it was untested.

    That line is missing a terminating semicolon, fixed.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

      Hi QM.. thanks for everything! After some modification on the matching of the "Sequence : Contig.." part, the script finally working! I disable the warning output, so it looks abit nicer when running the script.. here is the modified one. Thank u again QM! And thanks to everyone who helped!

      #!/bin/perl/
      my $sequence;

      while (my $line = <>)
      {
      # Sequence keyword
      if ($line =~ /^Sequence:\s+(\S+)/)
      {
      $sequence = $1; # save the sequence
      next;
      }

      # Parameter keyword
      next if ($line =~ /^Parameters:\s+(.*)$/);

      # print any other non-blank lines
      if ($line != /^\s+$/)
      {
      print "$sequence $line";
      next;
      }
      }

      Thanks again everyone!
        I disable the warning output, so it looks abit nicer when running the script.
        You mean you removed strict and warnings ???

        I can't check it where I am right now, but I don't see anything that would cause you problems, unless you're running on a very old or customized Perl.

        Perhaps you could relate what warnings you're getting, and we might convince you to put strict and warnings back in? Or perhaps it's related to your larger script, and not to this minimal example?

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of