What do you think of material that has this material? How would you present it to students in an "Intro to Perl Programming" course?
What would you do about it if you were employed by the company that wrote it? What about if you contracted to them? ================================================================ Changing the $#array also changes the length of the array Example: Similar to using the pop function @teams = ("redsox","yankees", "bluejays","rockies","giants","mariners"); print "Last element int he Array: $#teams\n"; print "Total elements in the Array: " ,$#teams+1,"\n"; print "\@teams has " .($#teams + 1). " elements\n"; $teams = $teams[$#teams--]; print "\@teams now has " .($#teams + 1). " elements"; ================================================================ This funciton is useful for loopping through the array @teams = ("redsox","yankees", "bluejays","rockies","giants","mariners"); for($i=0; $i < $#teams+1; $i++) { print "Loop: $teams[$i]\n"; } ================================================================ To grow or shrink the array, you simply change the value of the last index in the array - Use he $#array function to get the last item and change it Example: @grow = (1,2,3); $#grow = 10; $grow[4] = 300; print "Elements ".($#grow+1)."\n"; print join(", ",@grow),"\n"; Output: Elements 11 1, 2, 3, , 300, , , , , , - Get better performance behind the scenes by creating the array and growing it to the required length first instead of building it element by element. ================================================================ It is possible to empty an array by setting its length to a negative number Example: @array = (1,2,3); @#array = -1; ================================================================ * Creating a Perl script that loads elements into an array one at a time can make the program run slower, so it might be beneficial to preallocate the memory needed for the hash Example keys(%classes) = 52; $classes{'asp'} = 'Active Server Pages' $classes{'vb'} = 'Visual Basic' $classes{'html'} = 'HyperText markup Language'; $classes{'perl'} = "Practical Extraction and Reporting Language'; ================================================================ -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED]