please help me to find the solution of this error

1- Modification of non-creatable array value attempted, subscript -1 at research.pl line 94.

############################################ # VARIABLES ############################################ .... # array scotching sms which was readed my @msg2 = (); .......... ############################################ # START EXECUTION ############################################ answer_sms(); ########################################### # answer_sms() ########################################### sub answer_sms { #Build gsm object $gsm = new Device::Gsm(port=>'/dev/cuaU0'); # read SMS of Sim card @msg = $gsm->messages('SM'); # get the number of sms in the card $taille = @msg; # read the old sms in my sim card proc_read_card(); # creat array for stoching nmbr of sms in the card @tab=($taille); print "\nWAITING FOR NEW SMS.......\n"; while(1) { my $newtime = (time+50); @msg2 =$gsm->messages('SM'); $taille2 = @msg2; push(@tab,$taille2); if($tab[-1] != $tab[-2]) { # get the number of the last sender # following the LINE 94# my $dernier_num = $msg2[$#msg2]->sender(); ................ $gsm->send_sms(recipient=>$dernier_num,content=>"Error" +); ............. } }
when the last line is executed i get the error. Thank you in advance

In reply to Modification of non-creatable array 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.