[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Merging elements



On Thu, Oct 12, 2000 at 02:54:34AM +0800, robinmcf@altern.org wrote:

> $in=~tr/ //s; #take out any unwanted extra spaces
> @raw_data = split(/\s/,$in); #load the data into an array for manipulation

What's wrong with split(' ', $in)??


> # because the values are unique and the keys
> # aren't, it's better if we build a hash
> # using the unique info as the key (less brain strain)

Why are you going to all the trouble of creating a hash with the keys and
values backwards, when you're going to end up reversing the hash anyway?

Especially when you're basing your assumption that all the values are
unique on a very small sample of input data.

Just build the hash the right way in the first place.

I would not recommend using this approach to solve the problem.


Ronald

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org