On Nov 24, Paul Harwood said:
>The problem is that the value in $thread can be duplicated therefore it
>will write over anything else contained there. That's the problem I am
>having.
>
>-----Original Message-----
>
>> if ($_ =~ /(T[0-9A-F]+) <MSM> SCTS\((.+)\)/)
>> {
>> my $thread = $1;
>>
>> push @{$server{$thread}}, $2
>> unless grep $_ eq $2, @{$server{$thread}};
>>
>>
>> }
There's no overwriting going on. You're using push(), which means that
you'll never lose data, you'll only get more and more.
Here's a similarly-functioning block of code:
my @stuff = (
'T123 Here is a message',
'T237 Here's a different one',
'T123 Here's one for the first thread',
'T237 Here's a different one', # <-- duplicate, not entered
);
for (@stuff) {
chomp;
my ($thread, $data) = split ' ', $_, 2;
push @{ $server{$thread} }, $data
unless grep $_ eq $data, @{ $server{$thread} };
}
At the end of this, $server{T123} has two messages, and $server{T237} has
only one.
Explain how you think your code has a problem.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]