Please, use <code> </code> tags when posting your code.

As to the question, a quick fix solution you could try is getting the data from the database sorted descending by time, so that the newest times come first. Then, you can push the first occurence of a job name onto a list of data rows, and when the while loop ends, you can print the rows.

# I'm not sure if it's the correct statement # for getting the data sorted newest first, test it first &DBEXEC("select proc_eventvu.job_name, jobst.status, proc_eventvu.stam +p, proc_eventvu.text from proc_eventvu, jobst where proc_eventvu.joid = jobst.joid and proc_eventvu.event in (112,$eventnumber) and jobst.status = $statusnumber order by proc_eventvu.stamp desc"); my %already_processed; my @results_lol; while(@status = &dbnextrow($dbproc)) { $name = ($status[0]); $jstatus = &JOBSTATUS($status1); $estamp = ($status2); $etext = ($status3); # only the job data for a jobname # that wasn't processed before # make it to the result list unless (defined $already_processed{$name}) { push @results_lol, [($name, $jstatus, $estamp, $etext)]; $already_processed{$name} = 1; } } # here, if you want the rows sorted by name, you could # write some necessary code for my $row_ref (@results_lol) { my ($name, $jstatus, $estamp, $etext) = @$row_ref; write; }

It's untested, but try if it works. And I wholeheartedly second the suggestion about  use strict; use warnings;, as well as the advice about the JOBSTATUS subroutine.

Regards,
Luke


In reply to Re: Help with removing dupes from a string with perl by 1Nf3
in thread Help with removing dupes from a string with perl by CG_man

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.