All pastes #1286311 Raw Edit

wotd.pl - 1.2.0.0

public text v1 · immutable
#1286311 ·published 2008-12-15 23:06 UTC
rendered paste body
#!/usr/bin/perl
################################################################################
#                                                                              #
# ############################################################################ #
# # Title       : wotd.pl                                                    # #
# # Description : Word-of-the-day! script based on code from randword.pl     # #
# #               (grabs a word from zokutou.co.uk then displays it).        # #
# #               Currently just prints a word to the command line when      # #
# #               invoked.                                                   # #
# # Coded by    : Justin "HEYO--!" Lee                                       # #
# # Version     : 01.02.00.00                                                # #
# # Date        : 2008-12-15                                                 # #
# # License     : GNU General Public License v.2                             # #
# #               Copyright (C) 2008  Justin Lee  <kool.name at gmail.com>   # #
# ############################################################################ #
#                                                                              #
# ############################################################################ #
# # This program is free software; you can redistribute it and/or            # #
# # modify it under the terms of the GNU General Public License version 2    # #
# # as published by the Free Software Foundation.                            # #
# #                                                                          # #
# # This program is distributed in the hope that it will be useful,          # #
# # but WITHOUT ANY WARRANTY; without even the implied warranty of           # #
# # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            # #
# # GNU General Public License for more details.                             # #
# #                                                                          # #
# # You should have received a copy of the GNU General Public License        # #
# # along with this program; if not, write to the Free Software              # #
# # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA            # #
# # 02110-1301, USA.  Or, see: <http://www.gnu.org/licenses/>                # #
# ############################################################################ #
#                                                                              #
################################################################################

 #################
 # GENERAL NOTES #
##################
# This script requires a copy of
# HTML::Scrape by pc486.  He can
# be found on IRC Aniverse or at
# <tristan.willy at gmail.com>.
#
# It also requires a copy of Dean's
# HTML::Scrape::Tie::Word (lol).  You
# can find him at the same place or
# at <kool.name at gmail.com>.
#
# Just drop them in your personal lib,
# or in perl's lib if you're lazy.
# If you use perl's lib, you need
# to comment out the "use lib" line
# (see CONFIG NOTES).

 # config #
use constant {
  URL => 'http://www.zokutou.co.uk/randomword/index.php',
  LIB => join('/',split(/(?:\\|\/)+/,$ENV{'USERPROFILE'}),'library','perl'),
  GET => 1,
  TSM => 'ZOKUTOU',
};

 ################
 # CONFIG NOTES #
#################
# URL: Don't change unless you're really
#      adventurous, you'll need to change
#      the scrape engine as well (see $s
#      in the TIESCALAR subroutine).
#
# LIB: Change this to whatever your
#      "personal" lib is, where you put
#      HTML::Scrape. If you put in in
#      perl's lib (either), then just
#      comment out the < use lib LIB; >
#      line.
#
# GET: How many words to get at once, it's
#      limited to 3. If you put it higher
#      the script will ignore GET and only
#      grab one at a time.
#
# TSM: The scrape machine to use. For now
#      the only choices are 'ZOKUTOU' and,
#      well... 'ZOKUTOU'.

 # script #
use lib LIB;
use strict;
use warnings;
use HTML::Scrape::Tie::Word; # (yay!)

die unless (
  tie my $word,                  # what we're gonna tie() to
      'HTML::Scrape::Tie::Word', # module we're using
      ( URL, TSM, GET )          # it's config
);

print 'Random word: ' . $word;
untie $word;