develooper Front page | perl.perl5.porters | Postings from March 2006

Using Perl to run Visual Basic code

Thread Next
From:
Dennis.P.Mulqueeny
Date:
March 24, 2006 14:57
Subject:
Using Perl to run Visual Basic code
Message ID:
97D4AE324A0FE447A425CF9283318168017BAA4B@msgswbmnmsp34.wellsfargo.com
I have a Perl script running under version 5.8.5 on a sun4-solaris
system.

I have coded it to process a very small subset of Visual Basic code that
is stored in an XML document.  I currently use an eval to run the code
reference (anonymous subroutine).  There are actually 5 separate scripts
in this XML document.  One of the script fields is:

<SCRIPT>' Data.Value function changed to specify number of characters to
pad input for Perl where needed
Dim year
Dim month
Dim day
Dim century

century = Left(Data.Value("Orig IR Chng Date CYY", 3), 1)
year = Right(Data.Value("Orig IR Chng Date CYY", 3), 2)
month = Left(Data.Value("Orig IR Chng Date MMDD", 4), 2)
day = Right(Data.Value("Orig IR Chng Date MMDD", 4), 2)

If IsNumeric(century) And IsNumeric(year) And IsNumeric(month) And
IsNumeric(day) Then

    century = 1900 + (100 * CLng(century))

    year = century + CLng(year)

    Target.Value = Application.MakeDate(month, day, year)

End If</SCRIPT>

My perl script  translates it into:
# Data.Value function changed to specify number of characters to pad
input for Perl where needed
my $year;
my $month;
my $day;
my $century;

$century = Left(DataValue("Orig IR Chng Date CYY", 3), 1);
$year = Right(DataValue("Orig IR Chng Date CYY", 3), 2);
$month = Left(DataValue("Orig IR Chng Date MMDD", 4), 2);
$day = Right(DataValue("Orig IR Chng Date MMDD", 4), 2);

if (IsNumeric($century) and IsNumeric($year) and IsNumeric($month) and
IsNumeric($day)) {

    $century = 1900 + (100 * CLng($century));

    $year = $century + CLng($year);

    $TargetValue = ApplicationMakeDate($month, $day, $year);

}

I return the Perl code as return sub { $PerlCode };  storing the code
reference in a hash element.  My eval statement is:
 eval $g_Layout{$column}{Script}() if
(exists($g_Layout{$column}{Script}));

It takes a long time to run (23 minutes to process 324,834 records) and
I get the "Out of memory!" error after about 700,000 records.  Is there
a better way of doing this so as to avoid the eval?

/mmrg/usr/local/bin/perl -V
Summary of my perl5 (revision 5 version 8 subversion 5) configuration:
  Platform:
    osname=solaris, osvers=2.8, archname=sun4-solaris
    uname='sunos mmrg2003 5.8 generic_108528-23 sun4u sparc
sunw,sun-fire-880 solaris '
    config_args='-Dcc=gcc'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='gcc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
    ccversion='', gccversion='3.3', gccosandvers='solaris2.8'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib '
    libpth=/usr/local/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Compile-time options: USE_LARGE_FILES
  Built under solaris
  Compiled at Sep  9 2004 14:39:03
  @INC:
    /mmrg/usr/local/lib/perl5/5.8.5/sun4-solaris
    /mmrg/usr/local/lib/perl5/5.8.5
    /mmrg/usr/local/lib/perl5/site_perl/5.8.5/sun4-solaris
    /mmrg/usr/local/lib/perl5/site_perl/5.8.5
    /mmrg/usr/local/lib/perl5/site_perl
    .

Dennis Mulqueeny
Servicing Portfolio Management
Wells Fargo Home Mortgage
7911 Forsyth Boulevard, Suite 500
M5001-061
Clayton, MO 63105
Work: (314) 719-8349
  Cell: (618) 567-7767


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About