Category:
Author/Contact Info Val Polyakov vpolyakov@katrillion.com
Description: This module is to go with my "Tool for sending out newsletters". A user on here pointed out to me that my newsletter tool doesn't work without this.. and I forgot to include it there. So, here it is. =)
package Queue;

use strict;

sub new
{
        my $proto = shift;
        my $class = ref($proto) || $proto;
        my $self = {};
        ($self->{dir}) = @_;
        bless ($self, $class);
        return $self;
}

sub get_dir { my $self = shift; return $self->{dir} }

sub new_tag
{
        my $self = shift;
        return $self->{dir} . "/" . time . "-" . int(rand(100000));
}

sub next
{
        my $self = shift;
        return glob($self->{dir} . "/*");
}

sub next_by_ext
{
        my $self = shift;
        my $ext = shift;
        return glob($self->{dir} . "/*" . $ext);
}

sub dequeue
{
        my $self = shift;
        my $filename = shift;
        return unlink $filename;
}

1;
Replies are listed 'Best First'.
•Re: Queue.pm
by merlyn (Sage) on Aug 23, 2002 at 15:28 UTC