1 # This file is part of Email-Reminder.
3 # Email-Reminder is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License as
5 # published by the Free Software Foundation; either version 3 of the
6 # License, or (at your option) any later version.
8 # Email-Reminder is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with Email-Reminder; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 package EmailReminder
::Utils
;
20 # Utility subroutines for the Email-Reminder program
27 our $VERSION = '0.7.5';
28 our $USER_CONFIG_FILE = '.email-reminders';
29 our $SPOOL_DIRECTORY = '/var/spool/email-reminder';
63 $node = $node->getElementsByTagName($tag_name, 0)->item(0);
66 $node = $node->getFirstChild;
69 return $node->getNodeValue;
74 my ($node, $tag_name, $new_value) = @_;
76 my $subnode = $node->getElementsByTagName($tag_name, 0)->item(0);
77 if (!defined($subnode))
79 $subnode = $node->getOwnerDocument()->createElement($tag_name);
80 $node->appendChild($subnode);
81 $subnode->addText($new_value);
85 my $textnode = $subnode->getFirstChild();
86 if (!defined($textnode))
88 $subnode->addText($new_value);
92 $textnode->setNodeValue($new_value);
98 # Returns the proper English qualifier for this number
102 return unless defined($number);
104 if ($number >= 11 && $number <= 13) {
106 } elsif ($number % 10 == 1) {
108 } elsif ($number % 10 == 2) {
110 } elsif ($number % 10 == 3) {
117 # Returns the traditional name for this occurence of the anniversary
118 # if applicable (e.g. Silver, Golden, Diamond)
119 # (see http://www.the-inspirations-store.com/acatalog/anniversary.html)
122 my $occurence = shift;
124 return unless exists $names{$occurence};
125 return "($names{$occurence}) ";
128 # Return some general-purpose debugging info
132 my $depth_level = shift;
134 my $ret = "\nEmail-reminder: ".$EmailReminder::Utils
::VERSION
;
135 $ret .= "\nPerl: $] ($^O)";
138 $ENV{PATH
} = ''; # remove potentially tainted path
139 my $distro = `/usr/bin/lsb_release -s -d`; chomp $distro;
140 my $kernel = `/bin/uname -a`; chomp $kernel;
141 $ret .= "\nOS: $distro";
142 $ret .= "\nKernel: $kernel";
145 local $Data::Dumper
::Maxdepth
;
146 $Data::Dumper
::Maxdepth
= $depth_level;
148 $ret .= Dumper
($obj);