> -----Original Message----- > From: Phillip [mailto:fibbe...@gmx.net] > Sent: Thursday, June 11, 2009 12:00 > To: beginners@perl.org > Subject: Please, I need help!!! > > Hallo @ all, > > i am new in this domain(perlscript) and i have a question.i have a > array,i sort it,i get the last element of the array but i want to get > the next element after this one.how can i do this? > > for example: > > $arr1=("6,3,8,1") --->>my last element is 1 and mark that is the last > element > now i sort them ---->> $arr1=("1,3,6,8") > my last element is 1 and now i want to go to the next element in the > list,how can i do this?mbered The reason is unless you change how arrays are numbered, they start at zero and go from there. You can also use -1 to get the last element of an array as in $arr1[-1] would be 1 in the first example. $arr1[0] = 6 from your first example.
If you have any questions and/or problems, please let me know. Thanks. Wags ;) David R. Wagner Senior Programmer Analyst FedEx Freight 1.719.484.2097 TEL 1.719.484.2419 FAX 1.408.623.5963 Cell http://fedex.com/us > if i do something like this:$next=$last+1; --->>in this case > $next will > be 2 and this is not my third element in my list,i want the 3. > BR, > Phil > > here is my code: > > @arr[1]=("3,7,13,1,19,5,9"); > @array=split(/,/,@arr[1]); > $i=0; > while(@array[$i]) > { > $i=$i+1; > } > print"Anzahl:$i\n"; > @sorty=sort(Nummernsort @array); > sub Nummernsort{ > if($a<$b){ > return -1; > }elsif($a==$b){ > return 0; > }else{ > return 1; > } > } > > print "sort:@sorty\n"; > $last=$array[$i-1]; > print "last:$last\n"; > $next=? > print"nextt=$next\n"; > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/