Priority queue: Difference between revisions
m
→{{header|Perl}}: future-proof for 5.36
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: future-proof for 5.36) |
|||
Line 5,981:
=={{header|Perl}}==
===Using a Module===
There are a few implementations on CPAN. Following uses <code>Heap::Priority</code>[http://search.cpan.org/~fwojcik/Heap-Priority-0.11/Priority.pm]
<syntaxhighlight lang="perl">use
use
use feature 'say';
use Heap::Priority;
my $h =
$h->highest_first(); # higher or lower number is more important
Line 5,995 ⟶ 5,997:
["Tax return", 2];
say while ($_ = $h->pop);</syntaxhighlight>
{{out}}
<pre>
Make tea
Feed cat
Clear drains
Tax return
Solve RC tasks
</pre>
===IBM card sorter version===▼
<syntaxhighlight lang="perl">#!/usr/bin/perl▼
▲===IBM card sorter version===
use warnings; # in homage to IBM card sorters :)
|