Dear Monks,

Why does this bit of code give me problems?

$infile = "outfile.txt"; open (INFILE, "$infile"); $out_b = "outfile_b.txt"; open (OUT_B, "+>>$out_b"); while(<INFILE>){ print "here\n"; if ($_ =~ /^(.{1,50})\t{0,50}(.{0,50})\t{0,1}(.{0,50})\t{0,1}(.{0, +50})\t{0,1}(.{0,50})\t{0,1}(.{0,50})/){ print "here_B\n"; $gene_id = $1; if ($2 = /.{1,50}/){ (@alternative_ids, $2)}; if ($3 = /.{1,50}/){ (@alternative_ids, $3)}; if ($4 = /.{1,50}/){ (@alternative_ids, $4)}; if ($5 = /.{1,50}/){ (@alternative_ids, $5)}; if ($6 = /.{1,50}/){ (@alternative_ids, $6)}; if ($7 = /.{1,50}/){ (@alternative_ids, $7)}; if ($8 = /.{1,50}/){ (@alternative_ids, $8)}; if ($9 = /.{1,50}/){ (@alternative_ids, $9)}; print @alternative_id; foreach (@alternative_ids){ $alternative_id = $_; print OUT_B "$gene_id\t$alternative_id\n"; } undef @alternative_ids; } }
where infile is something like:
YAL069W YAL069W Yal069wp YAL068C YAL068C Yal068cp SEO1 YAL067C SEO1 Seo1p YAL066W YAL066W Yal066wp YAL065C YAL064W-B YAL064W-B Yal064w-bp YAL064C-A YAL064C-A Yal064c-ap YAL064W
I get the error message:
Modification of a read-only value attempted at extract_notes_B.pl line + 149, <INFILE> line 2.

In reply to File handle problems by matth

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.