--- Andre` Niel Cameron <[EMAIL PROTECTED]> wrote: > Can anyone think of a cleaner way to do this: > push(@Joiner, $ReadData[3]); > push(@Joiner, $PlayerData{'PlayerHeld'}); > push(@Joiner, $PlayerData{'PlayerCarried'}); > push(@Joiner, $PlayerData{'PlayerEquipped'}); > push(@Joiner, $PlayerData{'PlayerWielded'}); > > $PlaceHolder= join(":", @Joiner); > > @CurrentObjects= split(/:/, $PlaceHolder); > > # &MainFrames_Page; > > $tempdisplay= join(", ", @CurrentObjects);
The push statements can be replaced by assigning a new list to @Joiner: @Joiner = ( @Joiner, $ReadData[3], @PlayerData{ qw/ PlayerHeld PlayerCarried PlayerEquipped PlayerWielded / } }; That final construct, by the way, is called a hash slice. I am a bit concerned about the following two lines in your code: $PlaceHolder= join(":", @Joiner); @CurrentObjects= split(/:/, $PlaceHolder); In theory, you can replace them with this: $PlaceHolder = join ':', @Joiner; # same as what you have. I like to avoid extra parens @CurrentObjects = @Joiner; However, that second statement might behave differently than your code if any of the original values in @Joiner contained colons. Personally, I would rethink what you are doing. If you want to join items together and then split them again, you may want to revisit your data structures. You are likely to face data corruption if you start getting colons in places where you didn't expect them. > See what I am doing is getting objects from all the area then I will check > against what the user types in. Thats why I am using an array not a hash. > If the user has the object thay can do the action if not I need to pop up a > dialog box saying no object, while on that topic anyone know the dialogbox > syntax in perl or does it work differently? That depends. If you're doing this through CGI, then you're really looking at a JavaScript function, not Perl. If you're doing this through Tk or some other GUI system that works with Perl, you might want to check out comp.lang.perl.tk or a similar newsgroup. I also suspect that you are not using strict (I could be mistaken in that). If this is the case, you might want to read http://www.perlmonks.org/index.pl?node_id=108286 for a bit more information on the subject. Cheers, Curtis "Ovid" Poe ===== Senior Programmer Onsite! Technology (http://www.onsitetech.com/) "Ovid" on http://www.perlmonks.org/ __________________________________________________ Do You Yahoo!? Buy the perfect holiday gifts at Yahoo! Shopping. http://shopping.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]