On Apr 10, 9:03 am, [EMAIL PROTECTED] (Gunnar Hjalmarsson) wrote: > [EMAIL PROTECTED] wrote: > > [EMAIL PROTECTED] into the middle of @players without removing any elements > > from @players. > > > so i've done the following... > > > #!/usr/bin/perl -w > > > # extracting elements using splice > > > @players = ("ryno", "fukudome", "grace", "banks", "santo", > > "soto", "marmol", "sori", "bigZ", "pie"); > > @dump = splice(@players, 0,2, "theriot", "sosa"); > > print "The original array is @players\n"; > > print "The players dumped after the splice are: @dump.\n"; > > print "The spliced array is now @players.\n"; > > > ...but I'm not sure I'm doing the splice correct, because the first > > line prints all the players including the ones stated in @dump. should > > i be using negative offset or length? > > Your post is confusing. Please state both the exact output you get and > the expected output. > > -- > Gunnar Hjalmarsson > Email:http://www.gunnar.cc/cgi-bin/contact.pl
So basically, I was trying to figure out how could you splice @dump into the middle of @players without removing any elements of @players, but I finally figured it out last night, I just couldn't find the original post to let every one know. my code.... #!/usr/bin/perl -w # extracting elements using splice @players = ("ryno", "fukudome", "grace", "banks", "santo", "soto", "marmol", "sori", "bigZ", "pie"); print "The original array is @players\n"; @dump = splice(@players, 4,0, "theriot", "sosa"); print "The players dumped after the splice are: @dump.\n"; print "The spliced array is now @players.\n"; $ ./splice.pl The original array is ryno fukudome grace banks santo soto marmol sori bigZ pie The players dumped after the splice are: . The spliced array is now ryno fukudome grace banks theriot sosa santo soto marmol sori bigZ pie. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/