[13337] in Perl-Users-Digest
Perl-Users Digest, Issue: 747 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 9 08:07:29 1999
Date: Thu, 9 Sep 1999 05:05:09 -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 Thu, 9 Sep 1999 Volume: 9 Number: 747
Today's topics:
Alternative to ELSIF statements <dave4000@my-deja.com>
Fine then. Re: Sorry, Re: Why, why, why, -w and use str <robertf@emerald.oz.net>
Re: Fine then. Re: Sorry, Re: Why, why, why, -w and use <revjack@radix.net>
Help! HTTP500 error when running Perl script on Frontpa <gilbert@yahoo.com>
Re: large dataset problem <s.trew@qub.ac.uk>
need help. look at my code <photo@photoshopsection.com>
Re: need help. look at my code <Mark@Mark.Com>
perl/sendmail: encoding special chars nikkk25@my-deja.com
problem with s///e structure <Chris.vanUffelen@BodSch.BenP.WAU.NL>
Re: Programmers Needed <contact@nativetongues.com>
Re: Programmers Needed <wyzelli@yahoo.com>
Re: race condition in forking server (keywords: waitpid <rgoldber@eb.com>
Re: ref to array of ref to arrays <mike@crusaders.no>
Re: Select Multiple Form Field via Perl into Oracle err <noway@jose.com>
Re: Smile... ("DarkCode")
Re: Smile... <krasnal@bigpond.com>
Re: Sorry, Re: Why, why, why, -w and use strict? <revjack@radix.net>
Uninitialised variable in sub - debugging and avoiding? (Rory C-L)
Re: Uninitialised variable in sub - debugging and avoid (Arved Sandstrom)
Using strict? <danny@blueberry.co.uk>
Re: WHAT IS THE BEST WAY <gellyfish@gellyfish.com>
Win32::ODBC help <carvdawg@patriot.net>
Re: Y2K bugs on the Internet <nikeighley@my-deja.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 09 Sep 1999 11:36:51 GMT
From: dave h <dave4000@my-deja.com>
Subject: Alternative to ELSIF statements
Message-Id: <7r864i$6pu$1@nnrp1.deja.com>
Firstly, I am new to Perl.
Secondly, I have many subroutines (40 +) each one prompting for
different information, and I prompt the user to select which option
(subroutine) to select. (1-46). At the moment I have 46 if else
statements to do this, eg.
<subroutines go here>
print ("\nEnter Option: ");
$option = <>;
chop $option;
if ($option ==1) {
do option1();
}
elsif ($option ==2) {
do option2();
}
...etc, etc, all the way to 46.
Can somebody tell me if there is a much easier way of doing this?
Thanks in advance
Dave.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 9 Sep 1999 10:44:45 GMT
From: "Robert Front" <robertf@emerald.oz.net>
Subject: Fine then. Re: Sorry, Re: Why, why, why, -w and use strict?
Message-Id: <7r832t$ma9$0@216.39.133.13>
revjack <revjack@radix.net> wrote in message
news:7r802c$rsf$1@news1.Radix.Net...
> Bart Simpson explains it all:
>
> :My ISP recommended using a phony address when posting to newsgroups
because
> :he says it cuts down on spam.
>
> Bad advice.
>
Why? If spammers search newsgroups for e-mail addresses, then it will cut
down on spam.
Well here is my real e-mail address. I'm not really Bart Simpson. (but you
knew that)
Just so you know, I'm not switching to my real address just to stay out of
Abigale's killfile. The only time she posts anything is to tell people
they're idiots and/or adding them to her killfile.
------------------------------
Date: 9 Sep 1999 11:46:11 GMT
From: revjack <revjack@radix.net>
Subject: Re: Fine then. Re: Sorry, Re: Why, why, why, -w and use strict?
Message-Id: <7r86m3$6cn$3@news1.Radix.Net>
Keywords: Hexapodia as the key insight
Robert Front explains it all:
:revjack <revjack@radix.net> wrote in message
:news:7r802c$rsf$1@news1.Radix.Net...
:> Bart Simpson explains it all:
:>
:> :My ISP recommended using a phony address when posting to newsgroups
:because
:> :he says it cuts down on spam.
:>
:> Bad advice.
:>
:Why? If spammers search newsgroups for e-mail addresses, then it will cut
:down on spam.
No, it won't. Spammers will keep sending spam.
[Followups set to news.admin.net-abuse.email]
------------------------------
Date: Thu, 9 Sep 1999 18:07:50 +0800
From: "gilbert" <gilbert@yahoo.com>
Subject: Help! HTTP500 error when running Perl script on Frontpage
Message-Id: <7r80t5$g3f1@imsp212.netvigator.com>
Please help, why I can't run the perl script on frontpage?
The following step have been done.
1. perl script was located at frontpage's cgi-bin, both cgi-bin & local are
checked with "Allow Script or Program to be run"
2. Frontpage pws was on.
3. regedit's ScriptMap .pl was added and pointed to local perl.exe %s %s.
------------------------------
Date: Wed, 8 Sep 1999 10:54:10 +0100
From: "Stephen Trew" <s.trew@qub.ac.uk>
Subject: Re: large dataset problem
Message-Id: <7r7vue$kml$1@news.qub.ac.uk>
I am reading it!
Many, many thanks for all the coding you have done.
One day I hope to help some other novice as you have done for me.
Stephen
--
---
<><
Stephen Trew
School of Geography, Queen's University, Belfast BT7 1NN
Tel. +44(0)28 90 273367, Fax. +44(0)28 90 321280
S.Trew@Bigfoot.com ICQ: 15302096
www.bigfoot.com/~S.Trew/Home-Page
------------------------------
Date: Thu, 9 Sep 1999 11:43:07 +0200
From: "Robert" <photo@photoshopsection.com>
Subject: need help. look at my code
Message-Id: <7r7v5o$otl$1@cubacola.tninet.se>
I have a file and I want to know if a date exists and a the $dep variable if
so the $state variable will be set to 1 but it donīt work.
Can someone see any wrong in the if statment?
$dep = $q->param('Dep');
$dep_date = $q->param('date');
$meters = 0;
$state = 2;
$BASE_DIR = "/import/user8/gotlogic/public_html";
$FILE_STORE = "${BASE_DIR}/admin/bokning/files.txt";
open (FILE, "$FILE_STORE")|| die &error;
@files = <FILE>;
close FILE;
foreach $l (@files)
{
@file = split (/:/,$l);
print "<br>$file[0] $file[1] $file[2]<br>\n";
if($file[1] == $dep_date && $file[2] eq $dep)
{
$state=1;
$meters = $file[0];
}
}
--
Robert Karlsson
==========================
http://www.photoshopsection.se
Founder and webmaster
------------------------------
Date: Thu, 09 Sep 1999 12:33:55 +0100
From: Mark <Mark@Mark.Com>
Subject: Re: need help. look at my code
Message-Id: <37D79B23.2C9EA0AA@Mark.Com>
Robert wrote:
> I have a file and I want to know if a date exists and a the $dep variable if
> so the $state variable will be set to 1 but it donīt work.
> Can someone see any wrong in the if statment?
>
> $dep = $q->param('Dep');
> $dep_date = $q->param('date');
> $meters = 0;
> $state = 2;
>
> $BASE_DIR = "/import/user8/gotlogic/public_html";
> $FILE_STORE = "${BASE_DIR}/admin/bokning/files.txt";
> open (FILE, "$FILE_STORE")|| die &error;
> @files = <FILE>;
> close FILE;
> foreach $l (@files)
> {
> @file = split (/:/,$l);
> print "<br>$file[0] $file[1] $file[2]<br>\n";
> if($file[1] == $dep_date && $file[2] eq $dep)
^^^ use eq, perhaps?
>
------------------------------
Date: Thu, 09 Sep 1999 10:14:55 GMT
From: nikkk25@my-deja.com
Subject: perl/sendmail: encoding special chars
Message-Id: <7r81aq$3pq$1@nnrp1.deja.com>
Hey everyone,
maybe you can help me out on this one.
When sending mail from a perl script (through sendmail), the special
characters are garbled. Can anyone direct me to a script that encodes
them appropriately?
Thanks,
nikkk
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 09 Sep 1999 11:16:07 +0200
From: Chris van Uffelen <Chris.vanUffelen@BodSch.BenP.WAU.NL>
Subject: problem with s///e structure
Message-Id: <37D77AD7.364D@BodSch.BenP.WAU.NL>
I've got the following problem:
My input data ($data) contains clauses like
<|partA||partB||partC|>
which should be removed from the text and
partA|B|C should be stored in variables.
I do this using a
$data =~ s/.../.../ge;
structure which indeed finds the clauses, and which
does store the three variables.
BUT, it replaces the clause for the number `3', which
I don't like so much.
So the question is: how do I prevent Perl from
writing the number of changes (3 in this case) to
$data.
(Again, I'm happy that the clause is removed, I'm
not happy with its replacement.)
cheers,
Chris
------------------------------
Date: Thu, 9 Sep 1999 11:16:40 +0100
From: "Martin" <contact@nativetongues.com>
Subject: Re: Programmers Needed
Message-Id: <7r819c$gn4$2@gxsn.com>
[SNIP]
> This guy runs the web-site: www.ybid2000.com he also ran (and very
> badly managed) www.atecsecure.com which went "under". I did all the
> design and lost many thousands of dollars on those two deals - he will
> expect people to work for nothing but keep them on the hope of future
> rewards but when you ask for payment he will go and ask for other
> designers and programmers.
>
> Be very wary of him.
>
Seems that everyone gets stung at least once with these scams... I was
lucky, we got hit by someone who had a partner dumb enough to sign a
contract and bounce a check before we took them to court... It ended more or
less happily but not before a lot of grief, threats and problems...
Unfortunately others were not so lucky.
Moral: Get a contract before you do a damned thing and be in the same
country as the contractor.
Hope life and work is treating you better now.
Martin
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
------------------------------
Date: Thu, 9 Sep 1999 20:24:05 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Programmers Needed
Message-Id: <glMB3.6$ZW5.1178@vic.nntp.telstra.net>
Martin <contact@nativetongues.com> wrote in message
news:7r819c$gn4$2@gxsn.com...
> [SNIP]
>
> Seems that everyone gets stung at least once with these scams... I was
> lucky, we got hit by someone who had a partner dumb enough to sign a
> contract and bounce a check before we took them to court... It ended more
or
> less happily but not before a lot of grief, threats and problems...
> Unfortunately others were not so lucky.
>
> Moral: Get a contract before you do a damned thing and be in the same
> country as the contractor.
>
Or at least make sure you get a down payment or deposit before doing more
than a couple of hours work. I am in Australia and it seems most good Perl
programmers are from other countries. Can you believe how hard it is to get
Money to the US?
Wyzelli
------------------------------
Date: Thu, 9 Sep 1999 05:42:13 -0500
From: RayG <rgoldber@eb.com>
Subject: Re: race condition in forking server (keywords: waitpid, reaper)
Message-Id: <Pine.GSO.3.96.990909054031.14840A-100000@cliff.eb.com>
On Wed, 8 Sep 1999 dud@sydney.net wrote:
> It seems that when multiple child processes terminate at the same time,
> REAPER is only being called once. As this sub is responsible for
> tracking the number of live children, the result is two child processes
> dying but only one tracked, therefore only one re-created.
the cookbook also mentions that the reaper should use a while loop to
avoid this very situation.
> sub REAPER
> {
> my $pid = waitpid(-1, &WNOHANG);
> if ($pid == -1) {
> # no child
> }
> elsif (WIFEXITED($?)) {
> $children--;
> delete $children{$pid};
> }
> $SIG{CHLD} = \&REAPER;
> }
>
> sub HUNTSMAN
> {
> local($SIG{CHLD}) = 'IGNORE';
> kill 'INT' => keys %children;
> exit;
> }
>
> to work-around the problem, we've added the clear_dead_children() sub
> before re-populating.
>
> sub clear_dead_children
> {
> my $pid;
> my $i;
> my %newchildren;
>
> %newchildren = %children;
> foreach $pid (keys %newchildren) {
> $i = waitpid($pid,&WNOHANG);
> if ($i == 0) {
> print "pid $pid is still running - keep up the good work\n";
> }
> elsif ($i == -1) {
> print "pid $pid doesn't exist - clearing\n";
> delete $children{$pid};
> $children--;
> }
> elsif ($i == $pid) {
> print "pid $pid is dead - clearing\n";
> delete $children{$pid};
> $children--;
> }
> }
> }
>
> the above works and clears the dead children so that correct number are
> re-populated.
>
> is anyone able to offer suggestions as to why REAPER would only be
> called the once (assuming that it is a race condition) or an opinion on
> the work-around applied?
>
> kind rgds,
> /dave
> --------------------
> David Roe
> davidroe@email.com
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>
>
------------------------------
Date: Thu, 9 Sep 1999 14:04:42 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: ref to array of ref to arrays
Message-Id: <OnNB3.147$5A3.491@news1.online.no>
kev <kevin.porter@fast.no> wrote in message
news:37D77668.8C254AE9@fast.no...
> Hi,
>
> I need to know how to get hold of the values from the results returned
> from the DBI method selectall_arrayref. The docs say it returns "a
> reference to an array containing references to arrays for each row of
> data fetched".
> This is a little beyond me. How do I read, say, the second row? Or the
> fourth column in the fifth row, etc?
First of all, you should read up on perlref
perldoc perlref
The value you receive is equivialent to this:
$arrayref = [
['foo', 'bar', 'baz'],
['comp', 'lang', 'perl', 'misc'],
['Larry', 'Randall', 'Tom'],
];
This is a reference to an array with a reference to an array as each
element.
To get the value 'lang' (the second column in the second row) you can
write:
$value = $arrayref->[1][1];
or
$value = $$arrayref[1][1];
depending on personal preference.
You can print out alle the values like this:
my $level = 0;
foreach $ref (@$arrayref) {
print $ref, "\n";
$level++;
foreach $value (@$ref) {
print ' ' x $level, $value, "\n";
}
$level--;
}
--
Trond Michelsen
------------------------------
Date: Thu, 9 Sep 1999 11:52:48 +0100
From: "xman" <noway@jose.com>
Subject: Re: Select Multiple Form Field via Perl into Oracle error
Message-Id: <AjMB3.14$e74.4017@news.enterprise.net>
Jim Cromie wrote in message <37D49FDE.E2B1CECC@bwn.net>...
>> In article <ej%w3.1$2B2.769@news.enterprise.net>,
>
>Im puzzled though why its not @categories_selected, which at least
>could hold more than one item.
This was just an example truncated from my original which uses an array to
fill many fields Jim
>
>Also,
>{ local $" = ',';
> $SQL = "insert .... VALUES( @categories ); ";
>}
>would separate elements by commas, as per SQL.
>
>Lastly,
>you could test numeric vs string value of each element, and quote the value
>accordingly. This might not be robust enough (see faq on numeric vs
string,
>I have no idea which faq tho)
Great many thnaks for your help
Ian
------------------------------
Date: Thu, 09 Sep 1999 04:11:55 -0600
From: mv@spam.dev.nul ("DarkCode")
Subject: Re: Smile...
Message-Id: <mv-0909990411550001@pool-207-205-234-233.dlls.grid.net>
Karl Schmidt <nospam@nospam.de> wrote:
> Y-to-K Date Change Project Status:
>
>
>
> Our staff has completed the 18 months of work on time and on budget.
> We have gone through every line of code in every program in every
everk everk everk
> system. We have analyzed all databases, all data fields, including
skstem analkzed
> backups and historic archives, and modified all data to reflect the
> change. We are proud to report that we have completed the "Y-to-K"
"K-to-K"
> date change mission, and have now implemented all changes to all
> programs and all data to reflect your new standards:
kour
> Januark, Februark, March, April, Mak, June, Julik, August, September,=20=
>
> October, November, December
>
> As well as:
>
> Sundak, Mondak, Tuesdak, Wednesdak, Thursdak, Fridak, Saturdak
>
>
>
> I trust that this is satisfactory, because to be honest, none of this
satisfactork
> Y to K problem has made any sense to me but I understand it is a
K
> global problem, and our team is glad to help in any way possible.
>
> And what does this year 2000 have to do with it? Speaking of which
kear
> what do you think we ought to do next year when the two digit year
kou kear kear
> rolls over from 99 to 00? We'll await your direction."
>
> Your Y-to-K Project Manager
K-to-K
>
> :-)
kou still have quite a few bugs in your code. ;-)
--
// DarkCode
// "My fellow programmers ask not what your compiler can
// can do for you but what you can do for your compiler."
// -- If Jonh F. Kennedy had been a programmer.
------------------------------
Date: Thu, 9 Sep 1999 20:49:55 +0930
From: "Michal" <krasnal@bigpond.com>
Subject: Re: Smile...
Message-Id: <oJMB3.14354$ei1.28828@newsfeeds.bigpond.com>
"DarkCode" <mv@spam.dev.nul> wrote in message
news:mv-0909990411550001@pool-207-205-234-233.dlls.grid.net...
> Karl Schmidt <nospam@nospam.de> wrote:
> > :-)
>
> kou still have quite a few bugs in your code. ;-)
kou still have quite a few bugs in Kour code :)
------------------------------
Date: 9 Sep 1999 09:53:16 GMT
From: revjack <revjack@radix.net>
Subject: Re: Sorry, Re: Why, why, why, -w and use strict?
Message-Id: <7r802c$rsf$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight
Bart Simpson explains it all:
:My ISP recommended using a phony address when posting to newsgroups because
:he says it cuts down on spam.
Bad advice.
:I dont mind being thought of as a lame loser if it slows down the spam some.
It doesn't slow down the spam at all. Think about it.
------------------------------
Date: 9 Sep 1999 09:09:16 GMT
From: campbell-lange@easynet.co.uk (Rory C-L)
Subject: Uninitialised variable in sub - debugging and avoiding?
Message-Id: <campbell-lange-0909991009290001@campbell-lange.easynet.co.uk>
Keywords: perl debugging uninitialised help
Help needed with finding and dealing with causes and results of
uninitialised values.
When I run a variant of the following code (with many more html table entries) I
get a set of uninitialised value warnings from the subroutine. Perl warns of
uninitialised values in the shifted value in the subroutine.
I have the following questions:
1)
Presumably nothing is being matched in the problem cases in map (line
6) and sent via $1 or $2 to the subroutine? What is the procedure for
warning of uninitialised values after the subroutine shift?
2)
How would I use the debugger to check the values being passed to the
subroutine?.
I have switched on 'Perl Debugger' in the MacPerl menu. I can
step but not print out any values. Help please!
main::htmlparse( File parse tv.pl:16):
16: $inner =~ s/<[^>|B]+>//gi; <---- how do I print out the
evaluation?
3)
Is there a module I should be using?
5)
I need some html help (as is probably obvious). Can anyone recommend
a mac|perl related mailing list or newsgroup?
##### UNDO an HTML table and DO it up again #######
1 : #!perl -w
2 :
3 : $in = q<TR><TD VALIGN="TOP" NOWRAP><FONT FACE="Ariel,Helvetica"
SIZE=2><B>7.00 AM </B></FONT></TD><TD><FONT FACE="Ariel,Helvetica"
SIZE=2><B>Children's BBC Breakfast Show</B> </FONT></TD></TR><TR><TD
VALIGN="TOP" NOWRAP><FONT FACE="Ariel,Helvetica"
SIZE=2><B> </B></FONT></TD><TD><FONT FACE="Ariel,Helvetica"
SIZE=2><B>Polka Dot Shorts.</B> Dotty fun in the Land of Roo with
Polkaroo and friends.</FONT></TD></TR><TR><TD VALIGN="TOP" NOWRAP><FONT
FACE="Ariel,Helvetica" SIZE=2><B>7.10 AM </B></FONT></TD><TD><FONT
FACE="Ariel,Helvetica" SIZE=2><B>Playdays.</B> Mr Jolly and the gang
visit the Roundabout Stop.</FONT></TD></TR><TR><TD VALIGN="TOP" NOWRAP><FONT
FACE="Ariel,Helvetica" SIZE=2><B>7.30 AM </B></FONT></TD><TD><FONT
FACE="Ariel,Helvetica" SIZE=2><B>Puppy's Further
Adventures.</B> Capers with the cuddly canines.</FONT></TD></TR>;
4 :
5 : @rows = split /<\/TR>/, $in;
6 : @nums = map { /(.*)<TD>(.*)/; [htmlparse($1), htmlparse($2)] } @rows;
7 :
8 : foreach $out (@nums) {
9 : print "$out->[0] \t $out->[1] </TD>\n" if defined $out->[0] and
$out->[1];
10 : }
11 :
12 :
13 : sub htmlparse {
14 : my $inner = shift;
15 : $inner =~ s/ //g;
16 : $inner =~ s/<[^>|B]+>//gi;
17 : return $inner;
18 : }
__END__
Compiler warnings:
File parse tv.pl; Line 15: Use of uninitialized value.
File parse tv.pl; Line 16: Use of uninitialized value.
(repeated several times)
--
Rory Campbell-Lange
The Campbell-Lange Workshop
------------------------------
Date: Thu, 09 Sep 1999 06:43:02 -0300
From: Arved_37@chebucto.ns.ca (Arved Sandstrom)
Subject: Re: Uninitialised variable in sub - debugging and avoiding?
Message-Id: <Arved_37-0909990643020001@dyip-21.chebucto.ns.ca>
In article <campbell-lange-0909991009290001@campbell-lange.easynet.co.uk>,
campbell-lange@easynet.co.uk (Rory C-L) wrote:
> 1)
> Presumably nothing is being matched in the problem cases in map (line
> 6) and sent via $1 or $2 to the subroutine? What is the procedure for
> warning of uninitialised values after the subroutine shift?
>
If there are cases where it is reasonable to expect that one of the $n
variables doesn't get matched, check the value to see if it's defined.
> 5)
> I need some html help (as is probably obvious). Can anyone recommend
> a mac|perl related mailing list or newsgroup?
>
I don't do HTML, but you're right, there are modules to help with this
stuff. Check the Perl Cookbook if you have access to it, or peruse the
CPAN to see what's available under HTML.
Strictly speaking the help you need at the moment is more along the lines
of writing regular expressions that do what you want them to. Not being
snarky in the slightest. Read the perlre manpage for starters.
Arved
------------------------------
Date: Thu, 09 Sep 1999 11:42:13 +0100
From: Danny <danny@blueberry.co.uk>
Subject: Using strict?
Message-Id: <37D78F04.D6F34C84@blueberry.co.uk>
My developers are currently being forced to use strict by the software
environment that they are programming in - apart from pre-declaring vars
is there any other obvious potential things that they should look for in
their code?
They are getting some odd occurencies where sometimes the perl script is
being executed and at other times it is not - any ideas?
Thanks
Danny
------------------------------
Date: 9 Sep 1999 10:05:37 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: WHAT IS THE BEST WAY
Message-Id: <37d77861_2@newsread3.dircon.co.uk>
ladlad@my-deja.com wrote:
> Hi,
> I need to find a text on a webpage that is on a remote server and
> return the searching result to a user.
> Can you recommend any good(best) way how to do it?
> The page can be quite large.
> Is it necessary to download the page first(via LWP)?
Yes.
/J\
--
"Mr Creutzfeldt and Mr Jakob: No-one had ever heard of these two eminent
medical men until someone had the
------------------------------
Date: Thu, 09 Sep 1999 06:31:36 -0400
From: "Harlan Carvey, CISSP" <carvdawg@patriot.net>
Subject: Win32::ODBC help
Message-Id: <37D78C88.1F53B25@patriot.net>
I've tried accessing Dave Roth's site and news server to post this, but
haven't
been successful...
I'm using NT 4.0 server SP5, AS build 519. I'm trying to use
Win32::ODBC to store
information read from the system.
If I gather the information, and use Win32::ODBC to just store the data,
everything works
fine (see example 1 below). If I use Win32::ODBC to get data from one
table and try to
store data in another table, it doesn't seem to work. I can see the
data printed to STDOUT,
but it doesn't appear in the table, and there are no error messages (see
example 2).
Any ideas would be greatly appreciated...
******************** Example 1 *******************************
#! c:\perl\bin\perl.exe
use Win32::ODBC;
use Win32::Lanman;
use Win32::TieRegistry(Delimiter=>"/");
$server = "MUSASHI";
\&Services($server);
sub Services {
my($server) = @_;
my($ins) = new Win32::ODBC("dsn=nt");
if
(Win32::Lanman::EnumServicesStatus("\\\\$server","",&SERVICE_WIN32,&SERVICE_STATE_ALL,\@services))
{
foreach $service (@services) {
$display = ${$service}{display};
$name = ${$service}{name};
$state = ${$service}{state};
$status = "Stopped" if ($state == 1);
$status = "Started" if ($state == 4);
$status = "Paused" if ($state == 7);
## Get account service is running under
if
(Win32::Lanman::QueryServiceConfig("\\\\$server","",$name,\%info)) {
$acct = $info{'account'};
}
else {
$acct = Win32::FormatMessage Win32::Lanman::GetLastError();
}
print "$display\t$status\t$acct\n";
# Note: this statement works fine. Everytime the script is run, the
db table
# is populated with all of the information shown below.
$ins->Sql("INSERT INTO ITEST2 (HostID, Service, Status, Account) ".
"VALUES ('$server','$display','$status','$acct')");
}
}
else {
$err = Win32::FormatMessage Win32::Lanman::GetLastError();
print "Error getting Services: $err<p>\n";
}
}
******************** Example 2 **********************************
#! c:\perl\bin\perl.exe
use Win32::ODBC;
use Win32::Lanman;
use Win32::TieRegistry(Delimiter=>"/");
$server = "MUSASHI";
\&RegistryKeyValues($server);
sub RegistryKeyValues {
my($server) = @_;
my($db) = new Win32::ODBC("nt");
# my($ins) = new Win32::ODBC($db);
my($ins) = new Win32::ODBC("nt");
if ($remote = $Registry->{"//$server/LMachine"}) {
# Get values to check from RegKeyValue table
# Write results to iRegValue table
$db->Sql("SELECT * FROM RegKeyValue");
while ($db->FetchRow()) {
my(%data) = $db->DataHash;
# print "$data{'ValueName'}\n";
$rkey = $data{'RegKey'};
$valkey = $data{'ValueName'};
$value = GetKeyValue($remote->{$rkey},$valkey);
print "$valkey\t$value\n";
#
# For some reason, this statement doesn't work, and no error message
# is returned. The db table is NOT populated
#
# $ins->Sql("INSERT INTO ITEST1 (HostID,RegKey,Value,Data)".
# "VALUES ('$server','$rkey','$valkey','$value')");
#
# Reference used: Joe Casadonte's article on Win32::ODBC in the TPJ #9
$stmt = "INSERT INTO ITEST1 (HostID,RegKey,Value,Data)".
"VALUES ('$server','$rkey','$valkey','$value')";
if (!$ins->Sql($stmt)) {
my($err) = $ins->Error;
print "$err\n";
}
}
}
else {
print "Could not connect to Registry\n";
}
}
sub GetKeyValue {
my($key,$valuename) = @_;
my(@vals,$test,$value);
$value = "Not Found";
if ($key) {
eval {
@vals = $key->ValueNames;
$test = 0;
map{$test = 1 if ($_ eq $valuename);}@vals;
$value = $key->GetValue($valuename) if ($test);
return $value;
};
}
else {
return $value;
}
}
------------------------------
Date: Thu, 09 Sep 1999 10:31:22 GMT
From: Nick Keighley <nikeighley@my-deja.com>
Subject: Re: Y2K bugs on the Internet
Message-Id: <7r829q$492$1@nnrp1.deja.com>
In article <7r313k$dcp$1@nnrp1.deja.com>,
finsol@ts.co.nz wrote:
> I have decided to respond to the feedback I have received regarding
> "Perl Y2K Bugs on the Internet" in one hit. This feedback relates to
> my article at URL:
> http://www.y2kinfo.com/journal/features/0899_amon.html
>
> and the internet Y2K bugs collated at URL:
> http://www.ts.co.nz/~finsol/y2k_examples.htm
<snip rambling artical>
did you notice you didn't get one *single* favourable reply? Does this
tell you something?
--
I've been told anything is possible- usually by
people who arn't going to do it.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 747
*************************************