From nobody Wed Jun 26 07:01:06 2002 Newsgroups: comp.lang.perl.modules Subject: Re: DBI question References: Date: 26 Jun 2002 07:01:06 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 33 "Jeung Hun Han" writes: > $dbh=DBI->connect("DBI:mysql:mydatabase:myhost",user,pass,{PrintError=>0, > RaiseError=>0, AutoCommit=>0}); > $sth=$dbh->prepare("select * from mytable where .."); > $load_sth->execute(); I assume this should be: $load = $sth->execute; > $dbh->commit; > $dbh->disconnect; > But I always got message like this. > DBI::db=HASH(0x81671a0)->disconnect invalidates 1 active statement > handle (either destroy statement handles or call finish on them > before disconnecting) at ./ol line 1234. > How can I delete the message? Just do exactly what it says -- call finish on the statement handle when you're done getting data from it: $sth->finish; Then you can disconnect cleanly from the database. -- Aaron From nobody Wed Jun 26 07:21:36 2002 Newsgroups: comp.lang.perl.modules Subject: Re: Programming problem. References: Date: 26 Jun 2002 07:21:34 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 52 "Laurence Turpin" writes: > The following program is creates and displays an array of hashes. > Could somebody advise me on what is wrong with it. When I run it I > get the following error message: > Use of uninitialized value in split at C:\Documents and > Settings\Laurence Turpin\My Documents\aoh.pl line 25, line 2 > If I remove the the -w from the first line it runs fine. Actually, it runs fine either way (at least on Unix). That message is a warning, not an error, so it doesn't keep the script from running. Here's the problem (the warning is generated on the 'split' line): > sub getnextpair { > my @arr = (); > $_ = ; This line fills $_ with the next line from filehandle FH. When the end of the file is reached, it will be undefined. So at the next line: > @arr = split( /=/, $_ ); split is being called on an undefined value. That's probably not what you want, so -w warns you. You should probably do something like this: unless( $_ = ){ return undef; } And then in the main program where you call the subroutine, check for that and exit if the subroutine returns undef. Better, redesign the program around this loop: while(){ } And the end-of-file issue will be handled for you. By the way, what does this have to do with modules? -- Aaron From nobody Sun Jul 7 10:24:16 2002 Newsgroups: comp.lang.perl.modules Subject: Re: DBD::Mysql Advice needed References: Date: 07 Jul 2002 10:24:13 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 33 chacrint@hotmail.com (Chacrint Charinthorn) writes: > Or basically which of the followings is the correct DBD::Mysql > Module. I don't think either one is incorrect. > Msql-Mysql-modules-1.2219.tar.gz This one contains DBD drivers for both mSQL and MySQL. You can select one or both when you install it. > DBD-mysql-2.1017.tar.gz This one is presumably newer, and only contains the DBD driver for MySQL. I just run cpan and type "install DBD::mysql", and that's always worked. > > I am now trying to install the DBD::Mysql but I don't know which > > of the following shall I use and what are the key differences > > between the two. I have tried to install the DBD-mysql-2.1017 but > > I had problems when "make test". That's most likely because when 'make test' runs, it tries to read/write a test database, and either the database doesn't exist or the test script doesn't have the right permissions to it. You can either skip the 'make test' step (in cpan, say 'force install DBD::mysql'), or create a database for the test script to access. -- Aaron From nobody Sun Jul 7 20:11:07 2002 Newsgroups: comp.lang.perl.modules Subject: Re: Installing PerlMagick on Linux problem References: Date: 07 Jul 2002 20:11:03 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 20 Mark Worsdall writes: > I am trying to install the PerlMagick module on my home system. > Magick.xs:76: magick/api.h: No such file or directory > make: *** [Magick.o] Error 1 Have you installed ImageMagick? That's the system of C libraries that PerlMagick hooks into. If you've installed binaries, make sure you've installed the developer's package, if there is one. It might be included in your distribution, or you can get it from www.imagemagick.org. If you haven't installed ImageMagick yet, do so, and that might even install PerlMagick as part of the process (I forget). -- Aaron From nobody Mon Jul 8 08:35:54 2002 Newsgroups: comp.lang.perl.modules Subject: Re: Problem: Net::Ping - Pingreply time? References: Date: 08 Jul 2002 08:35:52 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 23 NetRisk writes: > I'm trying to get the Ping reply time out of Net::Ping > Is this possible I don't see it in the man page. > and how if not how can I get hold of the replytime from a > ping? On my system, I can do: ping -c 1 host|grep round-trip|cut -d ' ' -f 4|cut -d '/' -f 2 You might need to alter that for the exact syntax your ping program returns. And of course, if I were calling this from within a perl program, I'd parse the return from ping with a perl regex instead of grep|cut|cut. -- Aaron From nobody Mon Jul 8 14:36:32 2002 Newsgroups: comp.lang.perl.modules Subject: Re: DBD::Mysql Advice needed Date: 08 Jul 2002 14:36:30 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 39 chacrint@hotmail.com (Chacrint Charinthorn) writes: > /dsk2/dbd : perl testdbd.cgi > error opening libmysqlclient.so10 at Is this verbatim? That should be libmysqlclient.so.10. If you cut and pasted this, then it looks like the module has a typo somewhere that should be reported to the module's author. Otherwise: > Perhaps a required shared library or dll isn't installed where > expected Do this: /sbin/ldconfig -v | grep libmysqlclient.so.10 If it shows up in the output of ldconfig, then try your test script again. Often you need to reload the libraries with ldconfig after installing libraries. If ldconfig doesn't find it, then do: locate libmysqlclient.so.10 If you have that file, then ldconfig isn't searching the right path for it. Add the path where 'locate' finds it to /etc/ld.so.conf, and run the /sbin/ldconfig... command above again. If locate doesn't find libmysqlclient.so.10 on your system at all, you need to install the mysql client package. Your OS's package manager probably has it separate from the server package. Make sure you install any development package while you're at it. If you install mysql from source, you'll get everything. -- Aaron From nobody Tue Jul 9 08:51:08 2002 Newsgroups: comp.lang.perl.modules Subject: Re: DBD::Mysql Advice needed Date: 09 Jul 2002 08:51:06 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 24 chacrint@hotmail.com (Chacrint Charinthorn) writes: > I am on SCO Openserver 5.0.4 there is no ldconfig here so I use the > find command to locate the file and it is found at: Sorry, I thought I saw you mention Linux. > /usr/local/lib/mysql/libmysqlclient.so10 > ls -l /usr/local/lib/mysql/libmysqlclient.so10 > lrwxrwxrwx 1 root sys 24 Jun 22 23:20 > /usr/local/lib/mysql/libmy > sqlclient.so10 -> libmysqlclient.so.10.0.0 > echo $LD_RUN_PATH > /usr/lib > I tried adding /usr/local/lib/mysql/ to LD_RUN_PATH but it still has > the same errors Did you export or setenv LD_RUN_PATH? -- Aaron From nobody Wed Jul 17 17:44:11 2002 Newsgroups: comp.lang.perl.modules Subject: Re: Net:;Telnet References: Date: 17 Jul 2002 17:44:11 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 15 dchanco68@yahoo.com (doug chanco) writes: > First off let me say that this is a GREAT and useful module! I am > just wondering if a version to work with ssh is in the pipline OR if > there is another way/module to work with machines that don't allow > telnet but only ssh? # perl -e shell -MCPAN cpan> readme Net::SSH cpan> readme NET::SSH::Perl -- Aaron From nobody Thu Jul 18 20:08:39 2002 Newsgroups: comp.lang.perl.modules Subject: Re: Net::SMTP and qmail References: Date: 18 Jul 2002 20:08:39 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 30 "Marek Wojcik" writes: > From time to time my mod_perl script using Net::Smtp module stops > sending email. As a mailbox I use qmail server. After rebooting > everything gets back to normal. Some debuging info I have inserted > below. Can anybody help? I don't know what is going on. It looks to me like your qmail-smtpd (or the super-server it runs under) is failing to respond or timing out. Here's how to find out. Next time this happens, try telnetting to port 25 on whatever server you're sending to with Net::SMTP, and send an email manually. You do that like this: telnet mail.server.name 25 mail rcpt data Put the text of your message here. . The single period on a line by itself ends the message. If this works, then your qmail-smtpd is ok, and the problem may be with your script or module. If this doesn't work, then something is going wrong with your qmail setup, in which case you should probably ask on a qmail mailing list or newsgroup. -- Aaron From nobody Sun Jul 21 17:42:59 2002 Newsgroups: comp.lang.perl.modules Subject: Re: Some problems concerning modules References: Date: 21 Jul 2002 17:42:57 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 47 Cecil Westerhoff writes: > I want to work with LWP, so I installed the required modules. But I > have some strange problems. > The first three steps I had to do as a normal user and the last as > root. Is this normal? Yes. You have to be root to install the modules where perl will look for them by default. > When I want to execute a delivered script, I have to use (for > example) perl uri-test. Just uri-test gives: bad intrepeter. But > what is standing on the first line is correct. Make sure the script is executable (chmod 755 uri-test). Also, make sure the script doesn't have any ^M's at the end of the first line. Those can cause a problem. > I installed libnet. But I keep getting the message: 'Net::FTP not > located'. How did you install it? It apparently didn't end up in the right location. Try this: As root, type: perl -e shell -MCPAN This will fire an interactive session with the CPAN system. If this is your first time, it'll ask you a bunch of questions. You can probably just accept the defaults, except where it lets you choose mirror sites -- pick a few close to you. Once that's done and it gives you the cpan> prompt, type: cpan> install Bundle::LWP Then: cpan> install Bundle::libnet That'll take care of everything for you. -- Aaron From nobody Mon Jul 29 08:19:03 2002 Newsgroups: comp.lang.tcl,comp.lang.perl.modules Subject: Re: Expect matching help References: <19a14a2c.0207281537.3da69f88@posting.google.com> Date: 29 Jul 2002 08:18:58 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 39 mdrons@yahoo.com (Mike) writes: > I have been using the following to match my router login prompt for > some time. It is perl expect. $session->expect($ExpectTimeout, > ['-re', '^\S+#']) This searches for one or more non-whitespace characters, followed by a '#'. > I have not had any issues. Now we have add a banner to the router > that contains text surrounded by #. Here is an exmaple... > ########################## > # Company X Router # > # etc, etc, etc... # > ########################## > router# > How can I match this? > I have tried '^\S+$Router\S+#' But have had no luck. Any help? Let's break yours down: ^ beginning of string \S+ one or more non-whitespace characters $Router the contents of the scalar variable $Router (probably not what you want \S+ one or more non-whitespace characters # bang I'd just use something like this: 'router\#'. I'm not sure if the # must be escaped, but I usually escape non-alphanumerics just to be sure. -- Aaron From nobody Mon Jul 29 17:28:44 2002 Newsgroups: comp.lang.perl.modules Subject: Re: BZip2 module for Win32? References: Date: 29 Jul 2002 17:28:42 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 21 "Edward Wildgoose" writes: > I hope this is the correct place to ask. Does anyone have a working > module for handling BZip2 streams under Win32 and Linux please? Look at IO::Filter::bzip2. I haven't used it, but it appears to do what you want. > I haven't managed to get the CPan module to work on either Windows > or Linux, and actually I need the partial flush functionality anyway > so that I can use it to compress a network connection. I'd suggest getting CPAN working before trying to do much with modules. It makes things so much easier. With CPAN, you could simply have asked it for matches for /bzip2/, and found what I did above in a few seconds. -- Aaron From nobody Fri Aug 2 04:29:55 2002 Newsgroups: comp.lang.perl.modules Subject: Re: libnet upgrade without configuring again References: Date: 02 Aug 2002 04:29:55 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 12 Robert Lopez writes: > Can libnet be upgraded via cpan without going through > the complete configuration all over again. ie is there > a way to use the current configuration? Yes. Just do it, and it'll ask you. -- Aaron From nobody Sat Aug 10 07:48:05 2002 Newsgroups: comp.lang.perl.modules Subject: Re: Failed to install Image::Magick References: <719273dc.0208100317.3490f6c4@posting.google.com> Date: 10 Aug 2002 07:48:05 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 14 woody_young@hotmail.com (Woody Young) writes: > I have a RedHat 7.3 machine with Perl 5.6.1 installed. I tried to > use CPAN to install Image::Magick and I got the following error: > Magick.xs:76:24: magick/api.h: No such file or directory There's probably a devel RPM that you need to install to give you the header files. On Mandrake it's libMagick5-devel-something. -- Aaron From nobody Fri Aug 16 17:20:34 2002 Newsgroups: comp.lang.perl.modules Subject: Re: how to use File::Find again References: Date: 16 Aug 2002 17:20:16 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 82 "Dick Penny" writes: > 1) file::find is ment to recurse completely the WHOLE directory tree > given a starting point > 2) thus, you cannot stop it, jump out if you find a target. Is this > correct? I'm not sure. Setting File::Find::prune to true may cause it to skip the rest of the current directory, but I don't know a way to get it to stop entirely. In lieu of that, you could use a global variable to at least save cycles, as I do below. > In the following snippet (which I cannot get to stop at a find) > there are Q's by the #'s. > use strict; > use File::Find; > > sub wanted > { > return if !-d "$File::Find::dir/$_"; This always fails because File::Find chdir's into $File::Find::dir when calling the wanted routine. You're testing for the full path while you're already chdir'd into the directory. So it should be: return if !-d "$_"; > return if $_ != 'Temp'; #this return is never taken even though Temp > exists, why? You're comparing text strings with a numerical operator, so it's always true as long as they're both non-empty. Should be: return if $_ ne 'Temp'; > print "found dir=$File::Find::dir/$_\n"; # I expect only 1 print, I > get many, why? Your comparison on the previous line always fails, so this line is always reached. > my $startdir = qw/ c:\\ /; > File::Find::find (\&wanted, $startdir); > print "\n\ndone, name=$File::Find::name"; #does not print anything, am > expecting to see the one item found As far as I know, $File::Find::name only exists within the wanted() routine. If you want to use it outside the routine, you'll need to assign it to another variable. > From this example I am expecting one line, something like: > c:/WINNT/Temp (possibly with \ instead, possibly in lower case) I think this will do what you want. Perhaps someone knows how to get Fine::Find::find to stop in mid-search, but this at least avoids running through the entire wanted routine each time. use strict; use File::Find; my $search = "testing3"; # Directory to search for my $startdir = "News2"; # Directory to start searching in my $match; # Global variable for saving match sub wanted { return if $match; # skip wanted if I've found it already return if( ! -d "$_"); # skip all non-directories if( $_ eq $search ){ # see if it matches $match = $File::Find::name; # save it if it does } } File::Find::find(\&wanted, $startdir); print $match ? "Done: match = $match\n" : "Done: No match found for '$search'.\n"; -- Aaron From nobody Tue Aug 27 17:22:32 2002 Newsgroups: comp.lang.perl.modules Subject: Re: Net::Telnet Issue References: Date: 27 Aug 2002 17:22:30 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 40 "Phillip" writes: > I am trying to use Net::Telnet to telnet into an MFU server and set > up some filtering rules. The telnet part works fine but the problem > I am having is that the server does not prompt for any > information. Its just like telneting into a pop3 server where you > have to type: > user blah > pass blahpass > etc... > Does anyone know of a good way to do this with Net::Telnet or any > other module for that matter? I tried using the print() function but > it seems to be timing out. I may just be using it wrong though as I > am new to this module. First of all, telnet to the server manually and see what it does say to let you know it's ready. Then do something like this: use Net::Telnet; my $t = new Net::Telnet( Timeout => 30 ); $t->open('server'); $t->waitfor('/Hello message/'); $t->print("user blah"); $t->print("pass blahpass"); And so on. If the server sends any sort of OK message after each command, stick in a waitfor() to catch it. If you want to catch what came before a match, assign the results to a variable like so: my( $prematch, $match ) = $t->waitfor('/done/'); This will assign the text that was transmitted before the match to $prematch, and the text that matched the waitfor() value to $match. -- Aaron From nobody Fri Sep 13 18:02:48 2002 Newsgroups: comp.lang.perl.modules Subject: Re: Net::NNTP References: <3D821477.4050007@centurytel.net> Date: 13 Sep 2002 18:02:04 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 23 Chris Muller writes: > Here's my code: > $info = $nntp->head($first); > print ("MESSAGE $first: $info\n");; > Here's the output: > MESSAGE 10437: ARRAY(0x1d3fa48) The head() routine returns a reference to an array, where each item in the array is one line of the headers returned. So do something like this: $info = $nntp->head($first); print "\nMESSAGE $first:\n"; print for (@$info); -- Aaron From nobody Wed Dec 4 08:12:03 2002 Newsgroups: comp.lang.perl.modules Subject: Strange error using CGI::Session and DBI Date: 04 Dec 2002 08:12:02 -0600 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 71 I've been beating my head against this one for hours; it looks like a stupid-user error on my part, but I can't find anything. Here's the start of my program: #!/usr/bin/perl5 -w use strict; use CGI; use CGI::Session qw(-api3); use DBI; use vars qw($PROFILE); my ($cgi, $session, $dbh); $cgi = new CGI; my %f; for ($cgi->param()){ next if /^stage$/ or /^Login$/; $f{$_} = $cgi->param($_) if( ! / /); } my $sid = $cgi->cookie('CGISESSID') || $cgi->param('CGISESSID'); my $stage = $cgi->url_param('stage') || $cgi->param('stage') || ''; $dbh = DBI->connect("DBI:mysql:database", "user", "pass"); $session = new CGI::Session("driver:MySQL", $sid || undef, {Handle=>$dbh}); Most everything up until this point is taken verbatim from the CGI::Session docs, except for a little code I use to parse my CGI params. But it doesn't save the CGI::Session; instead, it gives me three error lines like this: Use of uninitialized value during global destruction. Use of uninitialized value during global destruction. Use of uninitialized value during global destruction. I managed to track the error down to the following subroutine. If I comment out the two lines commented below, the errors go away and the session is saved. sub save_quote { $dbh->do(qq[ INSERT INTO PDFQuotes ( ] . join( ', ', keys %f ) . qq[ ) VALUES ( ] . join( ', ', map { $dbh->quote($_) } values %f ) . qq[ ) ] ) or print $DBI::errstr; my $stt = $dbh->prepare(qq| SELECT LAST_INSERT_ID() FROM PDFQuotes | ); $stt->execute or die $DBI::errstr; my($quote) = $stt->fetchrow_array; $stt->finish; # $session->param('qq', $quote); # print "Saved quote $quote and session ", $session->id(); } Here's the weird part -- I still get the errors even if I comment out the call to this subroutine. I even tried putting an 'exit' statement right after the 'new CGI::Session' call above, and it *still* errors and doesn't save a session. Those lines in the save_quote subroutine should never be executed, but somehow they cause a problem unless I comment or delete them. Any ideas? Am I missing something obvious because I've been staring at this too long? Thanks, -- Aaron