PERL

Make WWW::Mechanize do not exit on GET Errors

2010
02
Mar

When using PERL and WWW::Mechanize, your script can stop if there is some error in GETing a URL (such as 404 Not Found, 403 Permission Denied). Instead of resuming, the script terminates. If you want the script to continue resuming, you have to pass

autocheck => 0

in the Mechanize class constructor as shown below

my $mech = WWW::Mechanize->new(autocheck => 0);

Read More

Perl Script to Fetch PNR Status reservation on train from Indian Railways

2010
04
Feb

The code below is a perl script that fetches the PNR status from the indianrail.gov.in website and displays it on the command line.

Warning: No one is authorised to make any type of commercial usage like putting web advertisements or SMS service and Reproducing/Transmitting/Storing in its database, any content of www.indianrail.gov.in website, without prior written permission from Indian Railways. Violators will be severely prosecuted.

Read More

Perl Script to send Free SMS to any mobile number in INDIA using way2sms

2009
02
Dec
9

The following script sends SMS to any number in INDIA using the free service provided by Way2Sms.com
Requires WWW::Mechanize and Compress::Zlib libraries.

Please remember to fill the username and password in the fields that is mentioned in the script.


#!/usr/bin/perl
 
use WWW::Mechanize;
use Compress::Zlib;
 
my $mech = WWW::Mechanize->new();
 
my $username = ""; #fill in username here
my $keyword = "";  #fill in password here
 
my $mobile = $ARGV[0];
my $text = $ARGV[1];
 
$deb = 1;
 

Read More

Perl script to remove a directory and contents recursively

2009
26
Nov
2

This is the script for sandeep when he asked me how to delete a directory in perl. rmdir function only removes empty directories. So we need to remove the contents of the directory before removing the directory. So if the directory contains more directories / folders we would have to recursively delete all the directories under the directory. Well so here is the code just to do that.

Read More

Syndicate content