
mhx
Enthusiast
/ Moderator
Jun 3, 2002, 12:01 AM
Post #7 of 8
(2626 views)
|
|
Re: [$0.05$] duplicates in an array?
[In reply to]
|
Can't Post
|
|
try it at http://test-me.netfirms.com/cgi-bin/sort.pl This doesn't give me any output at all... I'm sure there's a problem with the input string itself if you don't terminate the last line with a newline sequence. If you do this using a Windows-based browser, your input will be: Since you split on '\n', your array becomes:
@input_done = ( "foo\r", "bar\r", "foo\r", "bar" ); My code only removes _exact_ duplicates, and "bar\r" and "bar" are indeed different, although it's not visible. Thus, you'll get the following output: To make a long story short, try to change your split line to:
@input_done = split /\r?\n/, $input; which will allow an optional '\r' in front of the '\n' and try again. Hope this helps. -- mhx
At last with an effort he spoke, and wondered to hear his own words, as if some other will was using his small voice. "I will take the Ring," he said, "though I do not know the way."-- Frodo
|