When perl dies/warns with a message that doesn't end in a newline, it displays the file name and the line number where die was called.

If an I/O read operation has been performed and the handle is still open, perl will also dipslay the name of the handle and the number of lines that have been read from that file handle. (Well, $. really.) This helps debug errors based on inputed data.

See Playing with "<FH> line 123" die messages.

Update: As for the "Modification of a read-only value attempted" part, that usually happens when a variable (usually $_) is aliased to a constant, and a value is assigned to that variable. For example,

sub trim { $_ = $_[0]; # Assigns to $_, but $_ is aliased to " abc ". s/^\s+//g; s/\s+$//g; return $_; } # Fix: # sub trim { # for ($_[0]) { # foreach (unlike while) localizes the loop var. # s/^\s+//g; # s/\s+$//g; # return $_; # } # } print trim($_) for " abc ", " def ", " ghi "

and

sub f { my $pos = tell(DATA); while (<DATA>) { # Assigns to $_, but $_ is aliased to 1. print; } seek(DATA, $pos, 0); } # sub f { # my $pos = tell(DATA); # while (defined(my $line = <DATA>)) { # print $line; # } # seek(DATA, $pos, 0); # } f() for 1,2,3; __DATA__ a b c

In reply to Re: read-only error by ikegami
in thread read-only error 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.