Please see attached sample Perl Script.
Debugging Perl Inside Eclipse
Refer: http://perlmaven.com/padwalker
$ sudo apt-get install libpadwalker-perl
In Eclipse
Help, Install New Software
Refer: http://www.epic-ide.org/guide/ch01s02.php
For "Work with:", click "Add" button
Name: EPIC
Location: http://e-p-i-c.sf.net/updates
Choose "EPIC Main Components"
Next
Next
Accept
Finish
Install the software and restart
Make sure to create a special Perl workspace, and don't re-use your default workspace
Failed Notes from Archive
Run the following command, and kept hitting enter for all responses, added all repositories.
$ perl -MCPAN -e shell
Then run the following command in CPAN
cpan> install PadWalker
cpan> exit
Perl and SQLite Example along with MongoDB
Within Ubuntu using:SQLiteman
You'll need the DBI package, if not installed do the following within Ubuntu
sudo perl -MCPAN -e shell
cpan> install DBI
cpan> install DBD::SQLite module
Simple Perl script example, creating and inserting into a table: example1.pl
Installing Driver for MongoDB is just as easy, but be warned, it takes a long time to install.
sudo perl -MCPAN -e shell
cpan> install MongoDB::Connection
Using perl to get newest file in folder
$iisdir = '\\\\myfolder\\subfolder\\';
opendir LOGS, "$iisdir" or die "Directory error for IIS LOGS: $!\n";
my @files = grep /\.txt$/, readdir LOGS;
@files = sort { -M $a <=> -M $b } @files;
$active_log = $files[-1];
print "active log: $active_log\n\n";
Using PERL PPM through firewall proxy
Use the following in DOS prior to running PPM
REM If the proxy server requires a user name and password
REM include them in the following form:
REM http_proxy=http://username:password@proxy.example.org
set http_proxy=http://mlr:password@10.194.90.18:80
Installing Perl Packages, debugging with Eclipse
I'll need a little more research, and I may have already installed some things, don't remember.
Ran the following command, and kept hitting enter for all responses, added all repositories.
# perl -MCPAN -e shell
Then ran the following command in CPAN
cpan> install PadWalker
cpan> exit
You need to install PadWalker prior to installing Epic inside Eclipse for Perl debugging.
Simple Time Difference
#!/usr/bin/perl
use Time::Local;
print &daysFromNow('20','NOV','08');
exit 0;
# timegm returns seconds from 1970
# its format is (0,0,0,day 1..31,month 0..11,year)
sub daysFromNow
{
my $date2checkDD = $_[ 0 ];
my $date2checkMMM = $_[ 1 ];
my $date2checkYY = $_[ 2 ];
my $check_day = $date2checkDD;
my $check_month;
if ( $date2checkMMM eq 'JAN' ) { $check_month = 0; }
elsif ( $date2checkMMM eq 'FEB' ) { $check_month = 1; }
elsif ( $date2checkMMM eq 'MAR' ) { $check_month = 2; }
elsif ( $date2checkMMM eq 'APR' ) { $check_month = 3; }
elsif ( $date2checkMMM eq 'MAY' ) { $check_month = 4; }
elsif ( $date2checkMMM eq 'JUN' ) { $check_month = 5; }
elsif ( $date2checkMMM eq 'JUL' ) { $check_month = 6; }
elsif ( $date2checkMMM eq 'AUG' ) { $check_month = 7; }
elsif ( $date2checkMMM eq 'SEP' ) { $check_month = 8; }
elsif ( $date2checkMMM eq 'OCT' ) { $check_month = 9; }
elsif ( $date2checkMMM eq 'NOV' ) { $check_month = 10; }
elsif ( $date2checkMMM eq 'DEC' ) { $check_month = 11; }
my $check_year = "20$date2checkYY";
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime( time );
$time_1=timegm(0,0,0,$mday,$mon,$year);
$time_2=timegm(0,0,0,$check_day,$check_month,$check_year);
$seconds = $time_2 - $time_1;
$days = $seconds / 86400; # 60*60*24 = 86400
return $days;
}
