473,659 Members | 2,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

perl -d interfering with program execution?

Greetings,

I've been having issues while debugging programs. The problems only
appear when using the '-d' switch and I get the impression it has to do
with UTF8 and regex matching but I don't know how to deal with it.

One particular example is a program which uses the DBI to connect to a
database, which will run fine normally but will hang during the call to
DBI->connect() when running under the debugger.

In order to demonstrate the problem, I inserted a couple of bread crumbs
in the DBI.pm file, in the connect() method (at the <=== comments):

1) Just after the DSN is set (around line 460):
$dsn ||= $ENV{DBI_DSN} || $ENV{DBI_DBNAME } || '' unless $old_driver;

print STDERR "DSN: $dsn\n"; # <=== output DSN as passed to connect()
2) Just after the "dbi:driver " prefix is extracted from the DSN (near line
470):

# extract dbi:driver prefix from $dsn into $1
$dsn =~ s/^dbi:(\w*?)(?:\ ((.*?)\))?://i
or '' =~ /()/; # ensure $1 etc are empty if match
fails

print STDERR "DSN: $dsn\nDriver: '$1'\n"; # <=== output modified DSN
# and extracted driver

Running the program therefore outputs some info on the dsn and driver to
stderr. A normal program run outputs:

$ perl ./myapp.pl
DSN: dbi:mysql:datab ase=mydb;host=l ocalhost
DSN: database=mydb;h ost=localhost
Driver: 'mysql'
The problem appears when calling the program with -d. Here the program is
loaded in the debugger and simply 'c'ontinued.

$ perl -d ./myapp.pl

Loading DB routines from perl5db.pl version 1.19 Editor support
available.

Enter h or `h h' for help, or `man perldebug' for more help.

main::(./myapp.pl:2): my $numTrials = shift || "1";
DB<1> c

DSN: dbi:mysql:datab ase=mydb;host=l ocalhost
DSN: dbi:mysql:datab ase=mydb;host=l ocalhost
Driver: ''
This is where the program hangs. It seems the (same) dsn did NOT match
the regex this time--the DSN is unchanged and the driver variable is
empty. Hitting ctrl-C will abort the loop and land me somewhere in a
UTF8-related sub, like:

utf8::SWASHGET(/usr/lib/perl5/5.8.0/utf8_heavy.pl:3 08): 308:
for ($key = $min; $key <= $max; $key++) {

And all this only happens with 'perl -d'. I tried tweaking a few
environment variables, like LANG and SUPPORTED, setting them as
$ export LANG=en_US
$ export SUPPORTED=en_US :en

in a vain attempt to avoid UTF-8 altogether. This had no effect.

Does anyone know how to resolve or work around this problem?
Thanks in advance for any assistance.


In case it's relevant, here's the output of 'perl -V' on this Red Hat
Linux 9 (Shrike) system:
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.20-2.48smp, archname=i386-linux-thread-multi
uname='linux stripples.devel .redhat.com 2.4.20-2.48smp #1 smp thu feb
13 11:44:55 est 2003 i686 i686 i386 gnulinux ' config_args='-des
-Doptimize=-O2 -march=i386 -mcpu=i686 -g -Dmyhostname=loc alhost
-Dperladmin=root @localhost -Dcc=gcc -Dcf_by=Red Hat, Inc.
-Dinstallprefix=/usr -Dprefix=/usr -Darchname=i386-linux
-Dvendorprefix=/usr -Dsiteprefix=/usr
-Dotherlibdirs=/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=3pm -Duseperlio
-Dinstallusrbinp erl -Ubincompat5005 -Uversiononly
-Dpager=/usr/bin/less -isr' hint=recommende d, useposix=true,
d_sigaction=def ine usethreads=defi ne use5005threads= undef
useithreads=def ine usemultiplicity =define useperlio=defin e
d_sfio=undef uselargefiles=d efine usesocks=undef use64bitint=und ef
use64bitall=und ef uselongdouble=u ndef usemymalloc=n,
bincompat5005=u ndef
Compiler:
cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_P IDS
-DDEBUGGING -fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOU RCE -D_FILE_OFFSET_B ITS=64 -I/usr/include/gdbm',
optimize='-O2 -march=i386 -mcpu=i686 -g', cppflags='-D_REENTRANT
-D_GNU_SOURCE -DTHREADS_HAVE_P IDS -DDEBUGGING -fno-strict-aliasing
-I/usr/local/include -I/usr/include/gdbm' ccversion='',
gccversion='3.2 .2 20030213 (Red Hat Linux 8.0 3.2.2-1)',
gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8,
byteorder=1234 d_longlong=defi ne, longlongsize=8, d_longdbl=defin e,
longdblsize=12 ivtype='long', ivsize=4, nvtype='double' , nvsize=8,
Off_t='off_t', lseeksize=8 alignbytes=4, prototype=defin e
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib
/usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lpthread -lc -lcrypt -lutil
libc=/lib/libc-2.3.1.so, so=so, useshrplib=true , libperl=libperl .so
gnulibc_version ='2.3.1'
Dynamic Linking:
dlsrc=dl_dlopen .xs, dlext=so, d_dlsymun=undef , ccdlflags='-rdynamic
-Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS
USE_LARGE_FILES PERL_IMPLICIT_C ONTEXT Locally applied patches:
MAINT18379
Built under linux
Compiled at Feb 18 2003 22:19:53
@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
--
Pat Deegan,
http://www.psychogenic.com/
Registered Linux User #128131

Jul 19 '05 #1
3 2430
Pat Deegan wrote:
# extract dbi:driver prefix from $dsn into $1
$dsn =~ s/^dbi:(\w*?)(?:\ ((.*?)\))?://i
or '' =~ /()/; # ensure $1 etc are empty if match fails
print STDERR "DSN: $dsn\nDriver: '$1'\n"; # <=== output modified DSN


That's not the way to do it. I'd use m/()()/ instead of s///.

$raw_dsn="dbi:f oo(bar):xyz";
if (my ($driver,$dsn) = $raw_dsn =~ /^dbi:(\w*?)(?:\ ((.*?)\))?:(.*)/i) {
print STDERR "DSN: $dsn\nDriver: '$driver'\n";
} else {
warn "Unable to parse '$raw_dsn'";
}

-Joe
Jul 19 '05 #2
1) Don't post to multiple groups. (Crossposting is OK, multiposting is not.)
2) Use comp.lang.perl. misc, not comp.lang.perl for posting.
Jul 19 '05 #3
Answers are in comp.lang.perl. misc, not in this newsgroup.
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

58
4484
by: @ | last post by:
A benchmark in 2002 showed PHP is much slower in shell or when Apache has Mod_Perl. With the new PHP kissing Java's ass, Perl is once again the #1 CGI choice. Java is for a big team in short time to develope something slow. ASP is a joke. PHP is a kid.
0
1718
by: Matt Johnson | last post by:
Hello, Recently we made some fairly significant upgrades...going from Solaris 5.6 to Solaris 5.8 (Solaris 8). Along with this, we decided to upgrade from perl 5.005_03 directly to perl 5.6.0. Although this was a fairly significant jump (especially in perl versions), our applications are such that the testing was fairly straight-forward and we did not run into many problems. However, I've run into one that I hope to find some answers...
1
2476
by: varala_kanth | last post by:
hello friends, iam new bie i run the perl program with in command mode with this following command perl <filename>.pl
1
5115
by: Hemant Kumar | last post by:
Hi, I need to run a n iterations of a dos program from perl. I am using System ("program args"); There are two interactions with DOS that I need to take care of though 1) The program spews output that goes to the DOS window. Is there a way to absorb it and process it from perl script? 2) Once the program reaches a certain point in execution, it requires
5
5764
by: John Smith | last post by:
Can someone point me to an example of how to implement and access the kind of object shown below? Most of the examples if found are an object that contains one other object. I need to create an object that contains a hash of sub-objects each sub-object is made up of a number of different objects and an array of an object type. Object1 contains scalars
7
2145
by: Ajar | last post by:
I want to write a program which will automatically login to my ISPs website, retrieve data and do some processing. Can this be done? Can you point me to any example python programs which do similar things? Regards, Ajar
4
1632
by: shyamkumars | last post by:
Hi, I would like to know how can I make a daemon program in perl,say DP . The said program need to call a a program say A, which will to parse huge text file. The run time of A may vary say 5 to 6 hrs on average. There will be a lot of execution request reach the daemon program(DP) parsing different text files. so I need this daemon program to schedule each request in proper interval of time. I need to call the program from a web...
17
6609
by: beginner | last post by:
Hi All, This is just a very simple question about a python trick. In perl, I can write __END__ in a file and the perl interpreter will ignore everything below that line. This is very handy when testing my program. Does python have something similar? Thanks, Geoffrey
1
2015
by: jasper123 | last post by:
Hello, I am developing a cgi-perl script that takes some value from a html form as input and stores them in a data file. I have a program called "irr" in my server, it is executed just by typing irr at the shell prompt. Upon execution the program first displays a line describing the types of input required and waits for the input in the next line.I intend to pass the inputs from the values stored in the data file by the script. The following is...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.