perl : unmatched ) in regex error -


i'm no perl programmer, need simple script run:

perl -e 'open(file,"tmp.plot"); $seqlength = 643292; $count=1; while(my $ln = <file>){ if( $ln =~ m/^(\d+)\s+(\d+)/ ) { if($1 > $count) { for($i = $count; $i < $1 ; $i++){ print "0\n" } }; print "$2\n"; $count=$1+1;   }  } for($i = $count; $i <= $seqlength; $i++){ print "0\n" }' > dnaplotter.plot 

the error is: unmatched ) in regex; marked <-- here in m/^(\d+)\s+(\d+) <-- here / @ -e line 1.

anyone knows how fix it?

thank in advance!

tp

this program looks rather better laid out script. use strict , use warnings it's fine:

use strict; use warnings;  open(file, "tmp.plot") or die $!;  $seqlength = 643292; $count     = 1;  while (my $ln = <file>) {     if ($ln =~ m/^(\d+)\s+(\d+)/) {         if ($1 > $count) {             (my $i = $count; $i < $1; $i++) {                 print "0\n";             }         }         print "$2\n";         $count = $1 + 1;     } }  (my $i = $count; $i <= $seqlength; $i++) {     print "0\n"; } 

run as

perl script.pl > dnaplotter.plot 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -