[28449] in Perl-Users-Digest
Perl-Users Digest, Issue: 9813 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 6 14:10:16 2006
Date: Fri, 6 Oct 2006 11:10:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 6 Oct 2006 Volume: 10 Number: 9813
Today's topics:
perl print behavior different on window/unix jbilla2004@gmail.com
Re: Please help me pass an array from VBA to Perl and p david.f.jenkins@usa.net
Re: Problems at writing multiple files vladimir.giron@gmail.com
Script that shows IP address of a server. <superbaby@myjaring.net>
Unique in-depth problem <idgarad@gmail.com>
Unit-testing and mock objects <eugene.morozov@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Oct 2006 09:20:38 -0700
From: jbilla2004@gmail.com
Subject: perl print behavior different on window/unix
Message-Id: <1160151638.271704.3620@k70g2000cwa.googlegroups.com>
Hi all,
I'm getting some strange behavior with print in perl - it seems to
mangle the strings on linux while printing (the strings are in
iso-8859-15). Running the same script on WinXP (under cygwin) yields
the expected behavior (not to mangle!). Any ideas? One can use the
octal representation to make the linux version on linux appear ok (look
at the d=E9cima string below) but it appears corrupted on windows
(whereas the windows created file looks fine on windows & linux)
Appreciate any comments.
thanks!!
------------------------------
Script:
#!/usr/bin/perl -w
%NAME_ES =3D (
"trlr" =3D> "tr\x{00e1}iler",#"tr=E1iler",
"6th" =3D> "sexta",
"7th" =3D> "s\x{00e9}ptima",#"s=E9ptima",
"10tha" =3D> "d\x{00e9}cima",#"d=E9cima"),
"10th" =3D> "d=E9cima",
"15th" =3D> "quince",
);
open( TST, "> test.dat" ) || die "Unable to open test.dat";
foreach $k ( sort keys %NAME_ES ) {
print TST "Key: $k\tValue: $NAME_ES{$k}\n";
print "Key: $k\tValue: $NAME_ES{$k}\n";
}
close(TST);
--------
Output (linux) opened using xemacs on linux:
Key: 10th Value: d=C3=A9cima
Key: 10tha Value: d=E9cima
Key: 15th Value: quince
Key: 6th Value: sexta
Key: 7th Value: s=E9ptima
Key: trlr Value: tr=E1iler
-----
output (linux) opened using xemacs on windows (ftped using bin mode)
Key: 10th Value: d=C3=83=C2=A9cima
Key: 10tha Value: d=C3=A9cima
Key: 15th Value: quince
Key: 6th Value: sexta
Key: 7th Value: s=C3=A9ptima
Key: trlr Value: tr=C3=A1iler
-----
output (windows) opened using xemacs on windows
Key: 10th Value: d=E9cima
Key: 10tha Value: d=E9cima
Key: 15th Value: quince
Key: 6th Value: sexta
Key: 7th Value: s=E9ptima
Key: trlr Value: tr=E1iler
-----
output (windows) opened using xemacs on linux (ftped using bin mode)
Key: 10th Value: d=E9cima
Key: 10tha Value: d=E9cima
Key: 15th Value: quince
Key: 6th Value: sexta
Key: 7th Value: s=E9ptima
Key: trlr Value: tr=E1iler
---
perl -V (linux)
Summary of my perl5 (revision 5.0 version 8 subversion 0)
configuration:
Platform:
osname=3Dlinux, osvers=3D2.4.21-37.el.centos3.xfs.0smp,
archname=3Di386-linux-thread-multi
uname=3D'linux sillage.bis.pasteur.fr 2.4.21-37.el.centos3.xfs.0smp
#1 smp tue oct 4 11:56:53 cest 2005 i686 athlon i386 gnulinux '
config_args=3D'-des -Doptimize=3D-O2 -g -pipe -march=3Di386 -mcpu=3Di686
-Dmyhostname=3Dlocalhost -Dperladmin=3Droot@localhost -Dcc=3Dgcc -Dcf_by=3D=
Red
Hat, Inc. -Dinstallprefix=3D/usr -Dprefix=3D/usr -Darchname=3Di386-linux
-Dvendorprefix=3D/usr -Dsiteprefix=3D/usr
-Dotherlibdirs=3D/usr/lib/perl5/5.8.0 -Duseshrplib -Dusethreads
-Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db
-Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3D3pm -Duseperlio
-Dinstallusrbinperl -Ubincompat5005 -Uversiononly -Dpager=3D/usr/bin/less
-isr'
hint=3Drecommended, useposix=3Dtrue, d_sigaction=3Ddefine
usethreads=3Ddefine use5005threads=3Dundef useithreads=3Ddefine
usemultiplicity=3Ddefine
useperlio=3Ddefine d_sfio=3Dundef uselargefiles=3Ddefine usesocks=3Dund=
ef
use64bitint=3Dundef use64bitall=3Dundef uselongdouble=3Dundef
usemymalloc=3Dn, bincompat5005=3Dundef
Compiler:
cc=3D'gcc', ccflags =3D'-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=3D64 -I/usr/include/gdbm',
optimize=3D'-O2 -g -pipe -march=3Di386 -mcpu=3Di686',
cppflags=3D'-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-I/usr/include/gdbm'
ccversion=3D'', gccversion=3D'3.2.3 20030502 (Red Hat Linux 3.2.3-53)',
gccosandvers=3D''
intsize=3D4, longsize=3D4, ptrsize=3D4, doublesize=3D8, byteorder=3D1234
d_longlong=3Ddefine, longlongsize=3D8, d_longdbl=3Ddefine, longdblsize=
=3D12
ivtype=3D'long', ivsize=3D4, nvtype=3D'double', nvsize=3D8, Off_t=3D'of=
f_t',
lseeksize=3D8
alignbytes=3D4, prototype=3Ddefine
Linker and Libraries:
ld=3D'gcc', ldflags =3D' -L/usr/local/lib'
libpth=3D/usr/local/lib /lib /usr/lib
libs=3D-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
perllibs=3D-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
libc=3D/lib/libc-2.3.2.so, so=3Dso, useshrplib=3Dtrue, libperl=3Dlibper=
l=2Eso
gnulibc_version=3D'2.3.2'
Dynamic Linking:
dlsrc=3Ddl_dlopen.xs, dlext=3Dso, d_dlsymun=3Dundef, ccdlflags=3D'-rdyn=
amic
-Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
cccdlflags=3D'-fPIC', lddlflags=3D'-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS
USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
Locally applied patches:
MAINT18379
Built under linux
Compiled at Dec 20 2005 14:22:45
@INC:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
.
-----
perl -V (windows)
Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
Platform:
osname=3Dcygwin, osvers=3D1.5.18(0.13242),
archname=3Dcygwin-thread-multi-64int
uname=3D'cygwin_nt-5.1 inspiron 1.5.18(0.13242) 2005-07-02 20:30 i686
unknown
unknown cygwin '
config_args=3D'-de -Dmksymlinks -Duse64bitint -Dusethreads
-Uusemymalloc -Dopt
imize=3D-O3 -Dman3ext=3D3pm -Dusesitecustomize'
hint=3Drecommended, useposix=3Dtrue, d_sigaction=3Ddefine
usethreads=3Ddefine use5005threads=3Dundef useithreads=3Ddefine
usemultiplicity=3Dde
fine
useperlio=3Ddefine d_sfio=3Dundef uselargefiles=3Ddefine usesocks=3Dund=
ef
use64bitint=3Ddefine use64bitall=3Dundef uselongdouble=3Dundef
usemymalloc=3Dn, bincompat5005=3Dundef
Compiler:
cc=3D'gcc', ccflags =3D'-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing
-pipe -I/usr
/local/include',
optimize=3D'-O3',
cppflags=3D'-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing -pipe
-I/usr/local/inc
lude'
ccversion=3D'', gccversion=3D'3.4.4 (cygming special) (gdc 0.12, using
dmd 0.125
)', gccosandvers=3D''
intsize=3D4, longsize=3D4, ptrsize=3D4, doublesize=3D8, byteorder=3D123=
45678
d_longlong=3Ddefine, longlongsize=3D8, d_longdbl=3Ddefine, longdblsize=
=3D12
ivtype=3D'long long', ivsize=3D8, nvtype=3D'double', nvsize=3D8,
Off_t=3D'off_t', lsee
ksize=3D8
alignbytes=3D8, prototype=3Ddefine
Linker and Libraries:
ld=3D'ld2', ldflags =3D' -s -L/usr/local/lib'
libpth=3D/usr/local/lib /lib /usr/lib
libs=3D-lgdbm -ldb -lcrypt -lgdbm_compat
perllibs=3D-lcrypt -lgdbm_compat
libc=3D/usr/lib/libc.a, so=3Ddll, useshrplib=3Dtrue, libperl=3Dlibperl.a
gnulibc_version=3D''
Dynamic Linking:
dlsrc=3Ddl_dlopen.xs, dlext=3Ddll, d_dlsymun=3Dundef, ccdlflags=3D' -s'
cccdlflags=3D' ', lddlflags=3D' -s -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_64_BIT_INT
USE_LARGE_FILES USE_SITECUSTOMIZE
PERL_IMPLICIT_CONTEXT
Locally applied patches:
SPRINTF0 - fixes for sprintf formatting issues - CVE-2005-3962
Built under cygwin
Compiled at Dec 30 2005 02:44:25
%ENV:
CYGWIN=3D""
------------------------------
Date: 6 Oct 2006 08:26:58 -0700
From: david.f.jenkins@usa.net
Subject: Re: Please help me pass an array from VBA to Perl and populate it. Newbie at wits' end!
Message-Id: <1160148418.209210.229680@m73g2000cwd.googlegroups.com>
Dr.Ruud wrote:
> david.f.jenkins@usa.net schreef:
>
> > I'm aware of that.
>
> Of what? Don't top-post.
Let me request that you refrain from *telling* me what not to do. You
might ask, instead - much more polite.
> > I have created the Perl ActiveX control I need, and can safely travel
> > back and forth from VBA to Perl. What I *need* is help on the
> > mechanics of getting String array information back from the called
> > control. I am unable to figure out how to do this either through a
> > passed argument, or through VBA access of the control's poperties.
> >
> > Right now, I'm pretty much dead in the water. I just can't believe
> > that this is not a problem that myriads of others have already faced
> > and overcome.
>
>
> Maybe this helps:
>
> SOAP::Lite
> http://search.cpan.org/src/BYRNE/SOAP-Lite-0.69/examples/COM/
> ("when you return an array reference from a subroutine, it is
> automatically converted into an array in the host language")
A few pointers (no pun intended) that may help - thanks!
> Scriptlets
> http://www.foo.be/docs/tpj/issues/vol3_4/tpj0304-0009.html
Been there ... many times. Has some helpful tips, but doesn't solve my
PerlCtrl problems/questions. How do I define the COM interface for the
array reference I'm returning form Perl, e.g.? I must confess, though,
that upon re-reading, I've seen some stuff I didn't pick up on the
first few times I read that article. Another sleepless night looms ...
> PDK:
> http://www.foo.be/docs/tpj/issues/vol5_3/tpj0503-0011.html
No help: single string-oriented
> (all from the first few hits of google: vba perl string return)
And are you insinuating that I should be more creative with my
Googling? I've spent many evenings on this problem and Google and I
are on inimate terms - both Web searches and News Group searches.
Since I have *no* problem passing strings back and forth (my problem is
arrays, remember? (See my previous posts for repeated references to
arrays.)) I have generally seen fit to include "array" in most of my
searching.
> Affijn, Ruud
>
> "Gewoon is een tijger."
------------------------------
Date: 6 Oct 2006 08:51:19 -0700
From: vladimir.giron@gmail.com
Subject: Re: Problems at writing multiple files
Message-Id: <1160149879.829143.179970@b28g2000cwb.googlegroups.com>
Mark Clements wrote:
> vladimir.giron@gmail.com wrote:
> > I have a problem at writing multiple files. I have this code where I
> > write several XML files (the number of files it's dynamic). I use a
> > loop and in Linux works fine but the problem is Windows.
> >
> > For example lets say that I want to write a long essay into 1 file,
> > Windows and Linux do it as it should be, the problem comes when I want
> > to write that same essay (divided into 5 parts) in 5 files. Linux works
> > fine but windows skips the first part (the first file is not written)
> > and the remaining parts are written well.. if I want to write the essay
> > into 10 files, the first three are not written and as the number of
> > files grows so does the number of files not written.
>
> Are the files created but have no content?
>
> > Does anyone knows why could this be? Next is the part of the code where
> > I write into the files.
>
> Is possible you need to set binmode, but would depend on your data.
>
> Mark
I found the problem! After a few weeks with the bug I found what it
was.. I was using a relative path so while the files were been read and
written they weren't stored into the folder I told it but into the
folder of the essay. When just one file was written the file was stored
into the right place but with several just the last ones where stored
into the place I told the program. Weird!
Mark, thanks for your input.
------------------------------
Date: Sat, 07 Oct 2006 01:31:48 +0800
From: Blue <superbaby@myjaring.net>
Subject: Script that shows IP address of a server.
Message-Id: <45269303_1@news.tm.net.my>
First of all, I am not a Perl programmer. I have searched Google for 40
minutes but could not find this simple code.
I need a simple script that show the IP address of the server (where the
script is residing).
I believe this is something very simple but I just could not find it.
Can someone please help?
Thanks.
------------------------------
Date: 6 Oct 2006 10:32:31 -0700
From: "Idgarad" <idgarad@gmail.com>
Subject: Unique in-depth problem
Message-Id: <1160155950.958332.58250@m73g2000cwd.googlegroups.com>
I have a real challenge:
I need to work with, manage, and render a timeline. The problem? The
dates range, in years, from 0 to 1452652!! So I have a few hurdles:
1: Standard date libraries don't work. These dates are vastly out of
epoch ranges.
2: I have to render events on a timeline. Requirements are open but it
has to be able to handle rendering the whole damn thing at once (i.e
zooming in is ok.) but effectivly I have to either use SVG or Flash to
do this. Resolution goes to the day so:
YEAR|YEAR| etc..
MONTH|MONTH|MONTH|MONTH| etc..
1|2|3|4|etc...
-----------
XXXXXXXXXXXXXX YYYYYYYYYY ZZZZZZZZZZZZZZZZZZZZ
I originally did this via tables with colspans etc. but complicated
entries with 800+ events in a month (I was only rendering a single
year) could take up to 3 hours to display on a browser. SVG or Flash is
gonna be needed.
Dear God! What to do!? So the questions are really this:
Q1: What options do I have in Perl for handling dates of this nature
Q2: What graphical format is going to be able to handle, assuming I
dedicated 10px per day (so each year would be at leasy 3650px wide),
handling something of that scale? (Lets assume a limited viewport is
acceptable so we don't have to display the whole thing at once...)
Think of this as a History of the World Gnatt chart of sorts. I mean
what options, if any, are there for this kind of problem? I can batch
the process (It does not have to be real-time thank god!) but must be
doable within an 16 hour window utilizing a standard desktop (p4, 2ghz
lets say). This would eventually end up on a server but the constraint
is can start a friday night and must be done before Sunday 11:30pm so I
am working with Worst Case Scenario here.
------------------------------
Date: 6 Oct 2006 09:33:12 -0700
From: "jmv" <eugene.morozov@gmail.com>
Subject: Unit-testing and mock objects
Message-Id: <1160152392.151384.17770@h48g2000cwc.googlegroups.com>
Hello,
I have a problem creating mock objects for the unit tests. I'm writing
a unit tests for the rather old proprietary OO application that has all
sort of code smells.
The code I want to test looks like this:
=cut=
use Corp::System; # exports runCommand()
use Logcheck;
sub new { ... }
sub createUser {
...
my $exitval = runCommand("useradd ...");
...
Logcheck::createLogDir();
...
}
=cut=
I want to override the runCommand method from Corp::System module. I've
found only one way to do it. In my unit test module I write:
=cut=
BEGIN {
use Corp::System;
package Corp::System;
sub runCommand { push @COMMANDS, shift; return 0; }
1;
}
=cut=
But this method is very boring, unelegant and error-prone, because sub
createUser, which I'm testing, uses subroutines from a lot of modules
and there're numerous dependencies between them.
Is there more elegant and flexible method for testing such classes
without refactoring them? In any case, tests should exist before
refactoring.
Eugene
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9813
***************************************