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.8';
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 $ENV{ENV
} = ''; # necessary on SUSE
140 my $distro = `/usr/bin/lsb_release -s -d`; chomp $distro;
141 my $kernel = `/bin/uname -a`; chomp $kernel;
142 $ret .= "\nOS: $distro";
143 $ret .= "\nKernel: $kernel";
146 local $Data::Dumper
::Maxdepth
;
147 $Data::Dumper
::Maxdepth
= $depth_level;
149 $ret .= Dumper
($obj);