MoonPoint Support Logo

 


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
April
Sun Mon Tue Wed Thu Fri Sat
 
25 26 27
28 29 30        
2019
Months
AprMay Jun
Jul Aug Sep
Oct Nov Dec


Fri, Nov 07, 2014 10:40 pm

Installing YAML Perl module

YAML, which is a recursive acronym for ""YAML Ain't Markup Language", is a human-readable data serialization format that incorporates concepts from programming languages such as C, Perl, and Python. To install the YAML Perl module type perl -e shell -MCPAN at a shell prompt and then at the cpan prompt, type install YAML.
# perl -e shell -MCPAN
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.

cpan[1]> install YAML

Once it is installed you can view documentation on it by issuing the command perldoc YAML. If you just want to see if it is installed, you can issue that command. If it is, you will see the documentation. If it isn't installed, you will see a message "No documentation found" followed by the module name.

You can also use the -l argument to perldoc, which will report the location of the Plain Old documentation, abbreviated pod, file for the module, if one is present or also report "No documentation found", if the module can't be found. Be sure to capitalize "YAML" or you will see the "No documentation found" message.

# perldoc -l yaml
No documentation found for "yaml".
# perldoc -l YAML
/usr/local/share/perl5/YAML.pod

[/languages/perl] permanent link

Sun, Nov 02, 2014 1:09 pm

CGI.pm missing from CentOS system

When I tried accessing a website on a CentOS 7 server that I had recently set up as a web server using Apache, when I attempted to view the site, which I transferred from a CentOS 5 system, I saw the following error message in my browser.

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@example.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Checking the httpd error log, I saw the following entries for the problem:

[Sun Nov 02 11:31:21.399775 2014] [cgi:error] [pid 18794] [client 94.228.34.209:55416] AH01215: Can't locate CGI.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /home/jdoe/public_html/blog/blosxom line 92.
[Sun Nov 02 11:31:21.399911 2014] [cgi:error] [pid 18794] [client 94.228.34.209:55416] AH01215: BEGIN failed--compilation aborted at /home/jdoe/public_html/blog/blosxom line 92.
[Sun Nov 02 11:31:21.401265 2014] [cgi:error] [pid 18794] [client 94.228.34.209:55416] End of script output before headers: blosxom

When I searched the system for CGI.pm, I found it was not present.

# find / -name CGI.pm -print 2>/dev/null
#

The file was present on a backup from the CentOS 5 system at /usr/lib/perl5/5.8.8/CGI.pm.

Since it wasn't installed, I tried installing it.

# perl -e shell -MCPAN
Can't locate CPAN.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.

But that failed because CPAN.pm wasn't installed, either.

# find /usr/lib/perl5 -name CPAN.pm -print 2>/dev/null
# whereis CPAN.pm
CPAN:[root@frostdragon conf]# locate CPAN.pm
#

So I installed the perl-CPAN package with yum.

# yum install perl-CPAN

After the installation, I checked on the package and the location of CPAN.pm.

# rpm -qi perl-CPAN
Name        : perl-CPAN
Epoch       : 0
Version     : 1.9800
Release     : 283.el7
Architecture: noarch
Install Date: Sun 02 Nov 2014 12:02:15 PM EST
Group       : Development/Languages
Size        : 762403
License     : GPL+ or Artistic
Signature   : RSA/SHA256, Fri 04 Jul 2014 12:15:45 AM EDT, Key ID 24c6a8a7f4a80eb5
Source RPM  : perl-5.16.3-283.el7.src.rpm
Build Date  : Tue 17 Jun 2014 01:42:20 PM EDT
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://www.perl.org/
Summary     : Query, download and build perl modules from CPAN sites
Description :
Query, download and build perl modules from CPAN sites.
# whereis CPAN.pm
CPAN: /usr/share/man/man3/CPAN.3pm.gz
#

I was then able to install CGI.pm.

#  perl -e shell -MCPAN

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes] yes

 <install_help>

Warning: You do not have write permission for Perl library directories.

To install modules, you need to configure a local Perl library directory or
escalate your privileges.  CPAN can help you by bootstrapping the local::lib
module or by configuring itself to use 'sudo' (if available).  You may also
resolve this problem manually if you need to customize your setup.

What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')
 [local::lib] sudo

Autoconfigured everything but 'urllist'.

Now you need to choose your CPAN mirror sites.  You can let me
pick mirrors for you, you can select them from a list or you
can enter them by hand.

Would you like me to automatically choose some CPAN mirror
sites for you? (This means connecting to the Internet) [yes] yes
Trying to fetch a mirror list from the Internet
Fetching with LWP:
http://www.perl.org/CPAN/MIRRORED.BY

Looking for CPAN mirrors near you (please be patient)
........................... done!

New urllist
  http://cpan-du.viaverio.com/
  http://mirror.cogentco.com/pub/CPAN/
  http://httpupdate25.cpanel.net/CPAN/

Autoconfiguration complete.

commit: wrote '/root/.cpan/CPAN/MyConfig.pm'

You can re-run configuration any time with 'o conf init' in the CPAN shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.

cpan[1]>

At the cpan[1] prompt, I entered install CGI. Note: You need to use uppercase letters, not "cgi"

After the installation completed, I typed "exit" at the CPAN prompt. I was then able to reload the page in the browser without getting the "Internal Server" error; I did not have to restart Apache.

References:

  1. Perl CGI:Can't locate CGI.pm
    Date: June 5, 2005
    LinuxQuestions.org
  2. perl CPAN not installed by default
    Date: February 4, 2012
    DirectAdmin

[/languages/perl] permanent link

Mon, Oct 07, 2013 5:16 pm

Perl Module XML::Parser

I installed the Perl module XML::Parser, which is a Perl module for parsing XML documents.
# perl -MCPAN -e shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.7602)
ReadLine support available (try 'install Bundle::CPAN')

cpan> install XML::Parser
...
cpan> exit

After exiting from cpan, I checked on the module installation:

# perldoc -l XML::Parser
/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/XML/Parser.pm

During the installation I was advised that a later version of CPAN was available for the system, so I updated it as well, which took quite awhile. I accepted the default answers for all of the yes/no questions posed during the installation.

cpan> install Bundle::CPAN
...
cpan> reload cpan
.......................................................................................................................................................................................................
199 subroutines redefined


cpan> exit

[/languages/perl] permanent link

Mon, Oct 07, 2013 4:53 pm

Which Perl modules are installed on a system

There are a number of methods you can use to determine which Perl modules are installed on a system. I use a script, list-modules.pl. To use the script change the permissions on it so that it can be executed with chmod 755 list-modules.pl. The script produces an HTML file as output. You can use perl list-modules.pl >list-modules.html to produce the file or you can put the script in your cgi-bin directory on a webserver and access it via a browser to see the installed modules on the system (example output).

Another script that can be run from a shell prompt to show you the installed Perl modules on a system is find-modules.pl. To use it, you can change the permissions with chmod and then simply use ./find-modules.pl. (example output).

Another means of checking for installed Perl modules is through Lister.pm, which was developed by Brian D. Foy and which can be found at GitHub at app-module-lister (example output). Lister.pm can be run at a shell prompt with perl Lister.pm, after changing permissions on the file, e.g. chmod 755 Lister.pm, or you can also make the results available through a webpage, for instance, if you don't have access to a shell prompt on a webserver via SSH, by putting the file in a cgi-bin directory on the server and renaming the file to something like Lister.cgi, if scripts need the .cgi extension on the server. It can provide version information for some modules.

Another method is to use the perldoc module_name command, if perldoc is installed on the system. You should see documentation information if a module is installed, but the message "No documentation found for module_name", if the module isn't installed.

$ perldoc XML::Parser
No documentation found for "XML::Parser".

You can also use the -l argument to perldoc, which will report the location of the file for the module, if one is present or also report "No documentation found", if the module can't be found.

# perldoc -l LWP::Simple
/usr/lib/perl5/vendor_perl/5.8.8/LWP/Simple.pm

Note: The perldoc method will show modules installed via CPAN, but may not show modules that have been installed manually.

References:

  1. List Perl Modules
    Date: November 28, 2005
    MoonPoint Support
  2. How do I get a list of installed CPAN modules?
    Date: September 22, 2008
    Stack Overflow
  3. App-Module-Lister
    The CPAN Search Site

[/languages/perl] permanent link

Mon, May 28, 2012 9:02 pm

Perl Sleep Function

Perl has a function sleep that will cause a Perl script to wait, i.e., "sleep" a specified number of seconds before going on to the next step in a script.

Syntax

sleep EXPR

Definition and Usage

Causes the script to sleep for EXPR seconds, or forever if no EXPR. May be interrupted if the process receives a signal such as "SIGALRM". Returns the number of seconds actually slept. You probably cannot mix "alarm" and "sleep" calls, because "sleep" is often implemented using "alarm".

On some older systems, it may sleep up to a full second less than what you requested, depending on how it counts seconds. Most modern systems always sleep the full amount. They may appear to sleep longer than that, however, because your process might not be scheduled right away in a busy multitasking system.

For delays of finer granularity than one second, you may use Perl’s "syscall" interface to access setitimer(2) if your sys- tem supports it, or else see "select" above. The Time::HiRes module (from CPAN, and starting from Perl 5.8 part of the stan- dard distribution) may also help.

Example

my $sleeptime = 3; # Number of seconds to "sleep"
sleep($sleeptime);

Note

If you use sleep alone without any value given to it for the sleep period, then the script will sleep indefinitely.

[/languages/perl] permanent link

Mon, May 28, 2012 3:16 pm

Wide Character in Print Warning from Perl Script

When I ran a Perl script I wrote to download webpages from a website, I kept getting two warning messages printed for the same line whenever I ran the script.
Wide character in print at ./get_webpage.pl line 39.
Wide character in print at ./get_webpage.pl line 39.

I found at Unicode-processing issues in Perl and how to cope with it, written by Ivan Kurmanov, that the problem can occur when a file has Unicode characters in it. Unicode is a "computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world's writing systems."

Unicode can be implemented by different character encodings. The most commonly used encodings are UTF-8, UTF-16 and the now-obsolete UCS-2. UTF-8 uses one byte for any ASCII characters, which have the same code values in both UTF-8 and ASCII encoding, and up to four bytes for other characters. UCS-2 uses a 16-bit code unit (two 8-bit bytes) for each character but cannot encode every character in the current Unicode standard. UTF-16 extends UCS-2, using two 16-bit units (4 x 8 bit) to handle each of the additional characters.

The webpages I was downloading were encoded using UTF-8, which I confirmed by viewing the source code for one of the webpages I was downloading. In the "head" section of the webpage, I saw the following meta tag.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Line 39 in my Perl script, which printed the webpage, was as follows:

print WEBPAGE $page;

Prior to that line I had the following line:

open(WEBPAGE,">$first_fname") || die "$page$n could not be opened";

The variable first_fname is the name for the file holding the first page saved to disk.

To resolve the problem, I followed the suggestion offered by Ivan to use open FILE, ">:utf8", $filename;. I therefore changed the line in my script to the following:

open(WEBPAGE,">:utf8",$first_fname) || die "$page$n could not be opened";

For subsequent pages, I used an id number followed by ".html" for the filename for the webpages with the id number changing based on the contents of the webpage downloaded. I enclosed ">:utf8" and "$id.html" in double quotes to get the script to run without producing the "wide character in print" warning nor any error messages.


     if ($n == 1) {
       # First page will be named differently, e.g., index.html
       open(WEBPAGE,">:utf8",$first_fname) || die "$page$n could not be opened";
     }
     else {
       open(WEBPAGE,">:utf8", "$id.html") || die "$page$n could not be opened";
     }
     print WEBPAGE $page;
     close(WEBPAGE);
     $n++;

[/languages/perl] permanent link

Sun, May 27, 2012 10:51 pm

Downloading Webpages with Perl Using Get

I had written a Perl script to dowload specific webpages from a site and peform some processing on the downloaded copies of the webpages. When I moved the script to another system, I received the error message below when I ran it.
Can't locate LWP/Simple.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at ./get_webpage.pl line 5.
BEGIN failed--compilation aborted at ./get_webpage.pl line 5.

The script uses the get command from the LWP::Simple Perl module, which allows me to download a webpage similar to how I would use the GNU wget command from a shell prompt to download webpages. I wanted to use the Perl script, instead of wget, though, since I wanted to examine the webpages for specific links and then download other pages based on specific URLs present in the downloaded web pages.

When I checked for the presence of the LWP::Simple module, which provides support for the get, command on the system on which the script worked, I saw the following:

$ perldoc -l LWP::Simple
/usr/lib/perl5/vendor_perl/5.8.8/LWP/Simple.pm
$ cd /home/joe/www/support/languages/perl

When I checked on the system on which the script failed, I saw the following:

$ perldoc -l LWP::Simple
You need to install the perl-doc package to use this program.

I decided just to proceed with the installation of the LWP::Simple module by running the command perl -MCPAN -e shell. Since it was the first time I had run it, I was prompted to answer a number of questions. I hit Enter to accept the default answer for all of the questions. When the configuration process was completed, I entered install LWP::Simple at the cpan prompt. When the module was installed, I entered exit.

$ sudo bash
[sudo] password for joe: 
root@Saturn:~/Documents/bin# perl -MCPAN -e shell

CPAN.pm requires configuration, but most of it can be done automatically.
If you answer 'no' below, you will enter an interactive dialog for each
configuration option instead.

Would you like to configure as much as possible automatically? [yes] 

 <install_help>

Warning: You do not have write permission for Perl library directories.

To install modules, you need to configure a local Perl library directory or
escalate your privileges.  CPAN can help you by bootstrapping the local::lib
module or by configuring itself to use 'sudo' (if available).  You may also
resolve this problem manually if you need to customize your setup.

What approach do you want?  (Choose 'local::lib', 'sudo' or 'manual')
 [local::lib] 

Autoconfigured everything but 'urllist'.

Now you need to choose your CPAN mirror sites.  You can let me
pick mirrors for you, you can select them from a list or you
can enter them by hand.

Would you like me to automatically choose some CPAN mirror
sites for you? (This means connecting to the Internet) [yes] 
Trying to fetch a mirror list from the Internet
Fetching with HTTP::Tiny:
http://www.perl.org/CPAN/MIRRORED.BY

Looking for CPAN mirrors near you (please be patient)
.............................. done!

New urllist
  http://httpupdate3.cpanel.net/CPAN/
  http://httpupdate23.cpanel.net/CPAN/
  http://mirrors.rit.edu/CPAN/

Autoconfiguration complete.

Attempting to bootstrap local::lib...

Writing /home/joe/.cpan/CPAN/MyConfig.pm for bootstrap...
commit: wrote '/home/joe/.cpan/CPAN/MyConfig.pm'
Fetching with HTTP::Tiny:
http://httpupdate3.cpanel.net/CPAN/authors/01mailrc.txt.gz
Going to read '/home/joe/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with HTTP::Tiny:
http://httpupdate3.cpanel.net/CPAN/modules/02packages.details.txt.gz
Going to read '/home/joe/.cpan/sources/modules/02packages.details.txt.gz'
  Database was generated on Mon, 28 May 2012 01:35:04 GMT
  HTTP::Date not available
..............
  New CPAN.pm version (v1.9800) available.
  [Currently running version is v1.960001]
  You might want to try
    install CPAN
    reload cpan
  to both upgrade CPAN.pm and run the new version without leaving
  the current session.


..............................................................DONE
Fetching with HTTP::Tiny:
http://httpupdate3.cpanel.net/CPAN/modules/03modlist.data.gz
Going to read '/home/joe/.cpan/sources/modules/03modlist.data.gz'
............................................................................DONE
Going to write /home/joe/.cpan/Metadata
Running make for A/AP/APEIRON/local-lib-1.008004.tar.gz
Fetching with HTTP::Tiny:
http://httpupdate3.cpanel.net/CPAN/authors/id/A/AP/APEIRON/local-lib-1.008004.tar.gz
Fetching with HTTP::Tiny:
http://httpupdate3.cpanel.net/CPAN/authors/id/A/AP/APEIRON/CHECKSUMS
Checksum for /home/joe/.cpan/sources/authors/id/A/AP/APEIRON/local-lib-1.008004.tar.gz ok

  CPAN.pm: Going to build A/AP/APEIRON/local-lib-1.008004.tar.gz

Attempting to create directory /home/joe/perl5

*** Module::AutoInstall version 1.03
*** Checking for Perl dependencies...
*** Since we're running under CPAN, I'll just let it take care
    of the dependency's installation later.
[Core Features]
- ExtUtils::MakeMaker ...loaded. (6.57_05 >= 6.31)
- ExtUtils::Install   ...loaded. (1.56 >= 1.43)
- Module::Build       ...loaded. (0.38 >= 0.36)
- CPAN                ...loaded. (1.960001 >= 1.82)
*** Module::AutoInstall configuration finished.
Checking if your kit is complete...
Looks good
Writing Makefile for local::lib
Writing MYMETA.yml
cp lib/POD2/PT_BR/local/lib.pod blib/lib/POD2/PT_BR/local/lib.pod
cp lib/lib/core/only.pm blib/lib/lib/core/only.pm
cp lib/local/lib.pm blib/lib/local/lib.pm
cp lib/POD2/DE/local/lib.pod blib/lib/POD2/DE/local/lib.pod
Manifying blib/man3/POD2::PT_BR::local::lib.3pm
Manifying blib/man3/lib::core::only.3pm
Manifying blib/man3/local::lib.3pm
Manifying blib/man3/POD2::DE::local::lib.3pm
  APEIRON/local-lib-1.008004.tar.gz
  /usr/bin/make -- OK
'YAML' not installed, will not store persistent state
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl -I/home/joe/perl5/lib/perl5/i686-linux-gnu-threa
d-multi-64int -I/home/joe/perl5/lib/perl5 "-MExtUtils::Command::MM" "-e" "test_h
arness(0, 'inc', 'blib/lib', 'blib/arch')" t/classmethod.t t/coderefs_in_inc.t t
/de-dup.t t/install.t t/lib-core-only.t t/pipeline.t t/stackable.t
t/classmethod.t ...... Name "File::Spec::rel2abs" used only once: possible typo 
at t/classmethod.t line 20.
t/classmethod.t ...... 1/? Attempting to create directory t/var/splat
t/classmethod.t ...... ok   
t/coderefs_in_inc.t .. ok   
t/de-dup.t ........... ok   
t/install.t .......... skipped: Install Capture::Tiny to test installation
t/lib-core-only.t .... ok   
t/pipeline.t ......... ok   
t/stackable.t ........ ok     
All tests successful.
Files=7, Tests=29, 41 wallclock secs ( 0.17 usr  0.04 sys +  1.32 cusr  0.14 csys =  1.67 CPU)
Result: PASS
  APEIRON/local-lib-1.008004.tar.gz
  /usr/bin/make test -- OK
Running make install
Installing /home/joe/perl5/lib/perl5/POD2/PT_BR/local/lib.pod
Installing /home/joe/perl5/lib/perl5/POD2/DE/local/lib.pod
Installing /home/joe/perl5/lib/perl5/lib/core/only.pm
Installing /home/joe/perl5/lib/perl5/local/lib.pm
Installing /home/joe/perl5/man/man3/local::lib.3pm
Installing /home/joe/perl5/man/man3/lib::core::only.3pm
Installing /home/joe/perl5/man/man3/POD2::PT_BR::local::lib.3pm
Installing /home/joe/perl5/man/man3/POD2::DE::local::lib.3pm
Appending installation info to /home/joe/perl5/lib/perl5/i686-linux-gnu-thread-multi-64int/perllocal.pod
  APEIRON/local-lib-1.008004.tar.gz
  /usr/bin/make install  -- OK
Tried to deactivate inactive local::lib '/home/joe/perl5'

local::lib is installed. You must now add the following environment variables
to your shell configuration files (or registry, if you are on Windows) and
then restart your command line shell and CPAN before installing modules:

Use of uninitialized value $deactivating in numeric eq (==) at /home/joe/perl5/l
ib/perl5/local/lib.pm line 354.
Use of uninitialized value $deactivating in numeric eq (==) at /home/joe/perl5/l
ib/perl5/local/lib.pm line 356.
Use of uninitialized value $interpolate in numeric eq (==) at /home/joe/perl5/li
b/perl5/local/lib.pm line 366.
export PERL_LOCAL_LIB_ROOT="/home/joe/perl5";
export PERL_MB_OPT="--install_base /home/joe/perl5";
export PERL_MM_OPT="INSTALL_BASE=/home/joe/perl5";
export PERL5LIB="/home/joe/perl5/lib/perl5/i686-linux-gnu-thread-multi-64int:/home/joe/perl5/lib/perl5";
export PATH="/home/joe/perl5/bin:$PATH";

Would you like me to append that to /home/joe/.bashrc now? [yes] 


commit: wrote '/home/joe/.cpan/CPAN/MyConfig.pm'

You can re-run configuration any time with 'o conf init' in the CPAN shell
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.960001)
Enter 'h' for help.

cpan[1]> install LWP::Simple
<text snipped> cpan[2]> exit

I was then able to successfully run the Perl script.

[/languages/perl] permanent link

Sun, Nov 13, 2011 8:22 pm

file_upload Perl Script

The PHP code I had been using to upload files to a website would not allow me to upload files more than a few MB in size, likely due to the MAX_FILE_SIZE setting for HTTP_POST_VARS. I decided I would use a Perl script, instead, for uploading files to the site.

I used a Perl script Uploading Files Using CGI and Perl Article written by Matt Doyle as the basis for my script with just some minor modifications. I changed the maximum allowed size for uploaded files from 5 MB to 15 MB. I also eliminated the code pertaining to the uploader's email address, since I didn't need that information, and removed all references to photos in the code, since I wanted to use the script for uploading any type of file not just photos. I added some code to provide file size information on the uploaded file when the upload completes, which I got from How do I display filesizes in a nice way? at Stuart's Useful Perl Pages.

When a file is uploaded, the script will now show something like the following when the upload is completed.

File upload completed!

File uploaded: opera-10.11.gcc4-static-qt3.pkg.gz
File size: 14.43 MB (15136905 bytes)

The Perl script, file_upload.cgi is available here

References:

  1. Uploading Files Using CGI and Perl Article
    By: Matt Doyle
    Date: March 14, 2008
    SitePoint >> Web Design, Web Development, Freelancing, Tech News and more
  2. How do I display filesizes in a nice way?
    Stuart's Useful Perl Pages
  3. How to get the size of a file in Perl using file test operators.
    Perl Programming & Tutorials from About.com

[/languages/perl] permanent link

Sun, Sep 11, 2011 11:16 pm

Album Thumbnail Generator

I needed to generate thumbnail images for some photos my wife took that I placed on the website, so I could send a webpage link to someone else so she could view the pages rather than me sending all of the images to her by email. I also needed a program to not only create the thumbnail images, but to create a webpage indexing all of the thumbnails and providing links from the thumbnails to the full-size images.

I was in a hurry and didn't want to spend a lot of time setting up software to do that nor spend a lot of time doing it manually. I thought I had installed an easy-to-use program on the system several years ago to do just that for a friend who wanted to post pictures of storm damage to his house, but I couldn't remember the name of the program nor how to access it. After looking on the system for his photos, I saw that I had used a Perl program, Album by David Ljung Madison. He also offers a number of other free scripts at his MarginalHacks website. There's an example of the output from his photo album generator script at DavePics.

Once I realized where the album Perl script was placed on my system, I was able to generate the thumbnails and associated HTML pages by just running the script while my working directory was the one in which the photos were located. E.g. /path_to_script/album. An index.html page was generated by the script containing all of the thumbnails, which are placed in a tn directory beneath the one containing the images. Clicking on a thumbnail then brought up a webpage containing the full-size image and navigation links to the additional images.

I thought I should make a note to my self here, so that if I forget the name of the program again, I have this blog entry to remind me of its name and how to use it to generate image thumbnails and webpages for the images.

[/languages/perl] permanent link

Thu, May 22, 2008 9:08 pm

perl-Calendar-Simple Package

I needed to install a calendar generation package on a Linux system. I had previously used pcal on another Linux system and decided to use it again, since I was familiar with it and found it met my requirements.

I looked for a pcal RPM package. I found that the perl-Calendar-Simple package contained a pcal program and decided to install it. I installed the package, which is available from http://packages.sw.be/perl-Calendar-Simple/ or RPM PBone. If you are using the RPMforge repository, you can install it with yum or another installer. To configure yum to use the RPMForge repository, see RPMForge Packages and Yum Priorites.

# yum install perl-Calendar-Simple

After I installed the package, I found it installed /usr/bin/pcal. That pcal program was a Perl script. I could use it to generate the current month's calendar by typing pcal or a specific month from the current year with pcal m, where m is a number representing a month, e.g. pcal 6 would display the month of June. Or you can use pcal mm, e.g. pcal 06 for June. That pcal can also generate a calendar for a specific month and year with pcal mm yyyy, e.g. pcal 06 2009 for the calendar for June 2009.

# pcal 06 2009

     June 2009
Su Mo Tu We Th Fr Sa
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30

But that pcal program didn't offer me as many options as I had with the cal program that was already installed on the system. I didn't need anything particularly fancy, but I did need the capability to generate a calendar in HTML format, which the Perl pcal script didn't provide.

References:

  1. RPMForge Packages and Yum Priorites
    MoonPoint Support
  2. Pcal
    MoonPoint Support
  3. PCAL and LCAL: PostScript Calendar Programs
    SourceForge.net
  4. pcal and lcal - pcal branch
    freshmeat.net

[/languages/perl] permanent link

Once You Know, You Newegg AliExpress by Alibaba.com

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo