splice() function in Perl is responsible for replacing/ removing elements from an array by specifying the element subscript positions
#!/usr/bin/perl print "content-type:text/html\n\n"; @browser = ("NS", "IE", "Opera"); splice(@browser, 1, 2); # removes elements from position 1 and 2 of the array print "@browser\n"; @browser = ("NS", "IE", "Opera"); splice(@browser, 1, 2, "NeoPlanet", "Mosaic"); # replaces elements present in position 1 and 2 of the array with the respective values specified thereof print "@browser\n";
Output: ------- NS NS NeoPlanet Mosaic
AllBlogToolsFacebook comments for blogger brought to you by AllBlogTools.com , Get Yours?