HomePage » Perl


Information on Perl

Perl is an annoying son of a bitch. I have no idea why this language still exist today... Java is the only language needed on this planet. If you don't know it, learn it. I don't care what you can do with Perl. It's cool, maybe 10 years ago.

Installing Perl modules
For example, to install SOAP:Lite
perl -MCPAN -e 'install SOAP::Lite'
perl -MCPAN -e 'force("install","BSD::Resource");'


Checking if a specific module is installed
perl -MModule::Name -e 1


Listing installed modules
#!/usr/bin/perl
# list installed modules
use ExtUtils::Installed;
my $instmod = ExtUtils::Installed->new();
foreach my $module ($instmod->modules()) {
my $version = $instmod->version($module) || "???";
       print "$module -- $version\n";
}


Reinitialize CPAN config
perl -MCPAN -e shell
cpan> o conf init


reset URL list
cpan> o conf urllist
urllist
ftp://ftp.kernel.org/pub/CPAN/
Type 'o conf' to view configuration edit options
cpan> o conf urllist shift
cpan> o conf urllist push ftp://ftp-mirror.internap.com/pub/CPAN/
cpan> o conf urllist
cpan> o conf commit


Upgrading MCPAN
The only reason I know is that upgrading MCPAN will remove the annoying message saying the existing one is outdated.
perl -MCPAN -e shell
cpan>install Bundle::CPAN
cpan>reload cpan


Changing perl lib path
Example
export PERL5LIB=/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi


Using perl to sendmail directly to MX server
use Net::SMTP;
  #Create a new object with 'new'.
  $smtp = Net::SMTP->new("smtp.blah.com");
  #Send the MAIL command to the server.
  $smtp->mail("perlsucks\@blah.com");
  #Send the server the 'Mail To' address.
  $smtp->to("recipient\@blah.com");
  #Start the message.
  $smtp->data();
  #Send the message.
  $smtp->datasend("Subject: hello\n\n");
  $smtp->datasend("Test message.\n\n");
  #End the message.
  $smtp->dataend();
  #Close the connection to your server.
  $smtp->quit();
Comments [Hide comments/form]
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki