I am having a code shown below. this procedure is called as
Infile($filename)
where $filname contains a name of file. i am getting folowing error
Modification of a read-only value attempted at testscript1.pm at line line #(some number).
see the code i had written a comment where error comes. this is first place i am using $status scaler. Ca any one tell what is reason for this. when i change name of $status to $statu , no error comes.
sub InFile { local($outfile) = @_; if( -e $outfile) { if( open(SRC_FILE, $outfile)) { open(DEST_FILE, ">TEMPFILE_TOPLOG"); local($date1) = scalar localtime(); print DEST_FILE (@header); print DEST_FILE ("*** Log generated on $date1\n"); $line = <SRC_FILE>; while($line ne "") { print DEST_FILE ($line); $line = <SRC_FILE>; } close(DEST_FILE); close(SRC_FILE); local($filename1) = "TEMPFILE_TOPLOG"; local($newfile) = $outfile; $status = system("mv $filename1 $newfile");# HERE ERROR COMES if ($status != 0) { print "FAILED WHILE MOVING mv $filename1$newfile\n"; return 1; } } else { print "FAILED WHILE OPENING $outfile\n"; return 1; } } return 0; }

20050301 Janitored by Corion: Added code tags


In reply to help related to modifiaction of read only value attempted 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.