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
Post a Comment