#!/usr/bin/perl
use strict;
my $data = '2323424: 2434324, 3455543543';
my @ftr =();
my @values = ();
@values = split(/(\d+)/, $data);
foreach my $val (0 .. $#values) {
unless ( $values[$val] =~/^[0-9]+$/)
{
splice(@values, $val, 1);
}
}
print " @values\n";
exit 0;
Tuesday, May 15, 2012
split integer value from others character
Posted by AG at 12:04 AM 0 comments
Labels: Perl, split integer values
Wednesday, May 2, 2012
Perl CGI for beginner
Good post for beginner:
http://www.perlmonks.org/?node_id=44536
Website to download apache : httpd-2.0.64-win32-x86-openssl-0.9.8o.msi
http://httpd.apache.org/download.cgi#apache24
Posted by AG at 12:42 AM 0 comments
Friday, April 20, 2012
read text file and store line in array
Posted by AG at 12:59 AM 0 comments
Labels: Array, Perl, read txt file store in array
Thursday, April 12, 2012
verify whether variable is defined in perl
Posted by AG at 11:53 PM 0 comments
verify whether array is empty perl
Posted by AG at 11:42 PM 0 comments
Monday, April 2, 2012
split string by using regular expression
http://perlmeme.org/howtos/perlfunc/split_function.html
Posted by AG at 3:07 AM 0 comments
Labels: Perl
Wednesday, March 28, 2012
perl 2 array
my @num = qw (1 2 3 4 5); my @alp = qw (A B C D E); #One way for my $index (0 .. $#num) { print "$num[$index]-$alp[$index]\n"; } #Or print "$num[$_]-$alp[$_]\n" for (0 .. $#num);
Posted by AG at 12:20 AM 0 comments
Wednesday, March 21, 2012
Posted by AG at 11:12 PM 0 comments
Labels: Perl
Thursday, November 10, 2011
Array Perl
for my $i (0 .. $#x) {print "$i: $x[$i]\n";}
. $array[$#array] .
. scalar @array .
$#array
foreach (@array){$element = $_;print " $element\n"}
Monday, October 17, 2011
Extract Excel contents from perl
This code is used to calculate no. of w/s in excel file and read the worksheets' name.
my $sheetcnt = $Book->Worksheets->Count();
foreach (1..$sheetcnt){
print "\t" .$Book->Worksheets($_)->{Name} ."\n";
}
While last row and column can be read by using this:-
Finding the last Column and Row
my $LastRow = $Sheet->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious,
SearchOrder=>xlByRows})->{Row};
my $LastCol = $Sheet->UsedRange->Find({What=>"*",
SearchDirection=>xlPrevious,
SearchOrder=>xlByColumns})->{Column};
All of above code are use Win32::OLE without using complicated spreadsheet perl module.
Reference
1. http://www.perlmonks.org/?node_id=153486
2. http://www.ngbdigital.com/perl_ole_excel.html
3. http://perlguru.com/
Posted by AG at 7:56 PM 0 comments
Labels: Codes, Excel, Perl, Win32::OLE