Hi, Here is my code written to identify the particular position which is after a string (chr*).
my input file looks some thing like this
aanbb:anhn:iuopl:12345 chr1 12345 asnmkol * # kjiiii.....anmkij:lpolk: +lopll:abnnj chr5 123222 polko * dddfgg .... aaanbb:anhn:iuopl:aanjuj chr2 44345 asnmkol * # kjiiii.....anmkij:lpol +k:lopll:abnnj chr7 567222 polko * dddfgg .
i wanted to get the @pos as the immediate occurance after chr* as there are 2 such occurances in each line the first occrance has to be stored in pos[0] and second in pos1 for pos[0] pattern search has to be made wih in pos[0]+6 characters and same vs for pos1 but backwards
use strict; use warnings; open (my $fhConditions, "<1.txt"); my $l=6; open (my $read, "<2.txt"); my @e = <$read>; my $d = join('', @e ); $d =~ s/\s+//g; while (my $line = <$fhConditions>) { chomp $line; my @pos = $line[$i] =~/chr*\s+(.+?)\s/g; if($pos[0] =/[0-9]/) { my $match = substr($d,$pos[0],$l) print "$line" if $match =~m/AAGCTT/; } if($pos[1] =/[0-9]/) { my $a = $pos[0]-$l; my $match = substr($d,$a,$l); print "$line" if $match =~m/AAGCTT/; } }
ERRORS
Global symbol "@line" requires explicit package name at restriction.pl + line 11. Global symbol "$i" requires explicit package name at restriction.pl li +ne 11. syntax error at restriction.pl line 15, near ") print" Global symbol "$match" requires explicit package name at restriction.p +l line 15.

In reply to How to get rid of the errors in my perl script by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.