[19770] in Perl-Users-Digest
Perl-Users Digest, Issue: 1965 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 19 18:05:35 2001
Date: Fri, 19 Oct 2001 15:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1003529109-v10-i1965@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 19 Oct 2001 Volume: 10 Number: 1965
Today's topics:
\Z regexp behavior different with $& in program (Jason Secosky)
ActiveState Install to Win NT Fails <djmoore@uh.edu>
Re: ActiveState Install to Win NT Fails <djberge@qwest.com>
Re: ActiveState Install to Win NT Fails <djmoore@uh.edu>
Re: Ask Help for : Create a file with Read & Write Perm <jimbo@soundimages.co.uk>
Re: extract file extention from file name <jimbo@soundimages.co.uk>
File with Blank lins as seperator (Tim Moore)
Re: File with Blank lins as seperator <jeff@vpservices.com>
Re: File with Blank lins as seperator <jeff@vpservices.com>
Re: File with Blank lins as seperator <uri@sysarch.com>
Fork messes up parent file handle? <je@brighton.ac.uk>
Re: Fork messes up parent file handle? (Chris Fedde)
how to use a function as function'sparam? <mario.lat@libero.it>
Re: how to use a function as function'sparam? <mjcarman@home.com>
Re: how to use a function as function'sparam? <dtweed@acm.org>
lookingglass.pl <wilbert.van.diemen@hetnet.nl>
Opening files... <nathan.randle@ntlworld.com>
Re: Opening files... (Chris Fedde)
Re: Opening files... <tony_curtis32@yahoo.com>
Re: Opening files... <peter_icaza@REMOVE2REPLYuhc.com>
perl/dbi error kills server (Todd Smith)
Problem installing DBD <david345@toast.com>
Re: serial comm on Win2000 <brian_helterline@hotmail.com>
Re: serial comm on Win2000 <brian_helterline@hotmail.com>
SOAP Web Services Mailing List <bill.leigh@leighly.fsnet.co.uk>
Truncation of array through reference <rog@stanford.edu>
Re: Truncation of array through reference (Tad McClellan)
Unistalling a package <wusyk@americasm01.nt.com>
what happened to <peter_icaza@REMOVE2REPLYuhc.com>
Re: what happened to <uri@sysarch.com>
Re: what happened to (Randal L. Schwartz)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Oct 2001 12:22:29 -0700
From: secosky@attglobal.net (Jason Secosky)
Subject: \Z regexp behavior different with $& in program
Message-Id: <64a73ed6.0110191122.51c961d7@posting.google.com>
. When using \Z in a regexp match, the behavior differs when $& is
and isn't used in the perl script. I am using perl 5.6.1 under HPUX
10.20. The scripts and output I see are below. The only difference
is that one contains $& and one does not.
Script #1:
$match = "a\nb\n";
$match =~ /a\Z/m;
print ":$&:$-[0]:$match\n";
Output:
:::a
b
Script #2:
$match = "a\nb\n";
$match =~ /a\Z/m;
print ":$-[0]:$match\n";
Output:
:0:a
b
. I don't believe the regular expression should find a match, but
$-[0] being 0 in script #2 indicates that a match was found. The
thing I can't figure out is that the test for this in re_tests (line
540) is ignored when $& isn't in the code, so it's like this is a
known issue. Unfortunately I can't find anything saying why these two
scripts would behave differently. What am I missing?
Jason
------------------------------
Date: Fri, 19 Oct 2001 13:12:16 -0500
From: DaveMoore <djmoore@uh.edu>
Subject: ActiveState Install to Win NT Fails
Message-Id: <1kq0ttoi8uq08gsg1f0c1ngvea55rdbkh0@4ax.com>
I haven't been able to get ActiveState Perl (or Python either,
for that matter) to install on Windows NT for several builds
now. MSIEXEC quits with "ActivePerl Build 629 ended prematurely
because of an error. Your system has not been modified." The
error is not identified.
If I run from the command line and ask for a log, the relevant
entries seem to be here:
MSI (s) (8E:AF): MainEngineThread is returning 1603
MSI (c) (42:A8): Back from server. Return value: 1603
Action ended 18:16:59: ExecuteAction. Return value 3.
MSI (c) (42:A8): Doing action: FatalErrorDlg
Action start 18:16:59: FatalErrorDlg.
Action 18:16:59: FatalErrorDlg. Dialog created
Action ended 18:17:07: FatalErrorDlg. Return value 2.
Action ended 18:17:07: INSTALL. Return value 3.
I'm running WinNT 4.0 SP5, and MSIEXEC 1.2. I'm using an
Admin account. Plenty of hard drive space, plenty of RAM.
No PERL-related environment variables or Registry entries.
I don't know the last version of PERL that worked for me,
but the last build of Python that works is 210.
I feel like I'm overlooking something obvious, but can't
find in the docs.
Help?
--
Dave Moore == djmoore@uh.edu == I speak for me.
In the wrong hands, sanity is a dangerous weapon.
------------------------------
Date: Fri, 19 Oct 2001 13:27:05 -0500
From: "Mr. Sunblade" <djberge@qwest.com>
Subject: Re: ActiveState Install to Win NT Fails
Message-Id: <3c_z7.318$4O4.121231@news.uswest.net>
"DaveMoore" <djmoore@uh.edu> wrote in message
news:1kq0ttoi8uq08gsg1f0c1ngvea55rdbkh0@4ax.com...
> I haven't been able to get ActiveState Perl (or Python either,
> for that matter) to install on Windows NT for several builds
> now. MSIEXEC quits with "ActivePerl Build 629 ended prematurely
> because of an error. Your system has not been modified." The
> error is not identified.
Ack. Send this one to ActiveState. They've always gotten back to me with
problems, though sometimes it took a few days.
In the meantime, what about using their package install, which doesn't use
MSI, instead?
Regards,
Mr. Sunblade
------------------------------
Date: Fri, 19 Oct 2001 13:39:42 -0500
From: DaveMoore <djmoore@uh.edu>
Subject: Re: ActiveState Install to Win NT Fails
Message-Id: <pks0ttc8fllgd4bc49lct42t0f027mv2jl@4ax.com>
On Fri, 19 Oct 2001 13:27:05 -0500, "Mr. Sunblade" <djberge@qwest.com>
wrote:
>
>"DaveMoore" <djmoore@uh.edu> wrote in message
>news:1kq0ttoi8uq08gsg1f0c1ngvea55rdbkh0@4ax.com...
>> I haven't been able to get ActiveState Perl (or Python either,
>> for that matter) to install on Windows NT for several builds
>> now. MSIEXEC quits with "ActivePerl Build 629 ended prematurely
>> because of an error. Your system has not been modified." The
>> error is not identified.
>
>Ack. Send this one to ActiveState. They've always gotten back to me with
>problems, though sometimes it took a few days.
>
>In the meantime, what about using their package install, which doesn't use
>MSI, instead?
>
Dang, I knew I'd forgotten to say something. I tried that, and it,
too, fails silently. It's a perl script, so I suppose I could
comb through and pepper it with diagnostic prints, but since this
is the failsafe backup, it would be nice if it JUST WORKED. Also,
I'd like to have the uninstall capability.
If nothing turns up here, I'll pester ActiveState, and forward the
reply to the group.
--
Dave Moore == djmoore@uh.edu == I speak for me.
In the wrong hands, sanity is a dangerous weapon.
------------------------------
Date: Fri, 19 Oct 2001 20:19:52 +0100
From: "jimbo" <jimbo@soundimages.co.uk>
Subject: Re: Ask Help for : Create a file with Read & Write Permissions
Message-Id: <p1%z7.3973$dp4.20805@NewsReader>
"Stéphane" <ange324@free.fr> wrote
I'm sure you are, but in case I've missed something, you are aware you
are doing two different things here, yes?
> {open (OUTPUT,">>file.txt") or die "Can't open log: $!";}
mode is here ^^
> {open (OUTPUT,">file.txt")or die "Can't open log: $!";} => no
mode is here ^
If MODE is '<' or nothing, the file is opened for input. If MODE is
'>', the file is truncated and opened for output, being created if
necessary. If MODE is '>>', the file is opened for appending, again
being created if necessary. You can put a '+' in front of the '>' or
'<' to indicate that you want both read and write access to the
file; thus '+<' is almost always preferred for read/write
updates--the '+>' mode would clobber the file first.
The key point here is, in the first flavour you get what you want, an
open file for appending. You really don't require the second call.
The reason why is aptly explained in the text above, straight from
'perldoc -f open', which you can get to as well.
So, there 'ya have it. If you can open the file for appending, and
that is what you want to do, then you only need your first open and
the second is irrelevant.
jimbo
;-)
------------------------------
Date: Fri, 19 Oct 2001 20:02:22 +0100
From: "jimbo" <jimbo@soundimages.co.uk>
Subject: Re: extract file extention from file name
Message-Id: <%M_z7.4132$Rq2.17450@NewsReader>
"peter" <peter_icaza@REMOVE2REPLYuhc.com> wrote
> long.file.name.1
You don't need a regex, if you don't want one. How about this:
my $name = '1.name.file.long';
# I changed it because the single digit '1' looked lonely all by
itself printed later
my $ext = [reverse split /\./, $name];
print $ext->[0] if scalar @$ext > 1;
produces the output
long
So, there 'ya go. Not all problems are regex problems. This also
prevents filenames which don't contain an extension from being printed.
Perl *isn't* just for regex's anymore. Hey, maybe it never was?
jimbo
;-)
------------------------------
Date: 19 Oct 2001 12:40:32 -0700
From: timm@open-tech.com (Tim Moore)
Subject: File with Blank lins as seperator
Message-Id: <1ab6e421.0110191140.60b85de3@posting.google.com>
have a file that has multiple lines for each user, and then each user
is seperated by a blank line.
i.e.
"user=username1"
"pass=vfnergjkhdf"
"address=xxxxxxxxx"
"location=vvvvvvvvv"
"passwordexpires=200112011234"
"user=username2"
"pass=kjdfghkjdfhg"
"address=xxxxxx"
"location=vvvvvvvvv"
"passwordexpires=200112011234"
etc.......
how can i load this into an array sperating each user?
tried this:
-----------------------------------------------------------------------
open (FH, "< ./outputtest") || die ("Cant open the OUTPUT $!");
@records="";
while(<FH>) {
while(<FH>) {
($variable, $value) = split (/:/);
$record={ $variable => $value } ;
until(!$_);
}
push (@records ,$record)
until eof(FH);
}
foreach $item(@records) {
print "$item is the item\n";
if ($item->{cn} =~ m/.timm(.*)/) {
print "The Variable was $variable\n";
print "The value was $value\n";
}
}
HELP PLEASE !!!!! ASAP
------------------------------
Date: Fri, 19 Oct 2001 12:47:59 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: File with Blank lins as seperator
Message-Id: <3BD0836F.D1502754@vpservices.com>
Tim Moore wrote:
>
> have a file that has multiple lines for each user, and then each user
> is seperated by a blank line.
>
> i.e.
> "user=username1"
> "pass=vfnergjkhdf"
> "address=xxxxxxxxx"
> "location=vvvvvvvvv"
> "passwordexpires=200112011234"
>
> "user=username2"
> "pass=kjdfghkjdfhg"
> "address=xxxxxx"
> "location=vvvvvvvvv"
> "passwordexpires=200112011234"
>
> etc.......
>
> how can i load this into an array sperating each user?
my $records;
local $/ = "\n\n";
my $count=0;
while (<DATA>) {
for (split /\n/) {
my($key,$value)=split /=/;
push @{$records->[$count]}, {$key => $value};
}
$count++;
}
use Data::Dumper; print Dumper $records;
--
Jeff
------------------------------
Date: Fri, 19 Oct 2001 13:00:30 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: File with Blank lins as seperator
Message-Id: <3BD0865E.EDFA7787@vpservices.com>
Jeff Zucker wrote:
>
> [snip]
Or even simpler:
my $records;
local $/ = "\n\n";
while (<DATA>) {
my $row;
for (split /\n/) {
my($key,$value)=split /=/;
$row->{$key} = $value;
}
push @$records, $row;
}
use Data::Dumper; print Dumper $records;
--
Jeff
------------------------------
Date: Fri, 19 Oct 2001 20:20:03 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: File with Blank lins as seperator
Message-Id: <x7r8rz4c10.fsf@home.sysarch.com>
>>>>> "JZ" == Jeff Zucker <jeff@vpservices.com> writes:
JZ> Jeff Zucker wrote:
>>
>> [snip]
JZ> Or even simpler:
JZ> my $records;
JZ> local $/ = "\n\n";
JZ> while (<DATA>) {
JZ> my $row;
JZ> for (split /\n/) {
JZ> my($key,$value)=split /=/;
JZ> $row->{$key} = $value;
JZ> }
JZ> push @$records, $row;
JZ> }
JZ> use Data::Dumper; print Dumper $records;
untested:
{
local $/ = "\n\n";
@records = map { { /^(.+)=(.+)$/gm } } <DATA> ;
}
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 19 Oct 2001 19:40:40 +0100
From: John English <je@brighton.ac.uk>
Subject: Fork messes up parent file handle?
Message-Id: <3BD073A8.59553E8@brighton.ac.uk>
I have a script which reads lines from a config file and forks off
a seaparate child process for each line:
while (<IN>) {
$pid = fork;
if ($pid) {
&do_parent_stuff;
}
elsif (defined($pid)) {
&do_child_stuff;
last;
}
else {
die "horribly";
}
}
close IN;
(Other stuff, like zombie reaping, is done but not shown here...)
What happens is that when a child processes is forked off, the
parent goes round the loop again and reads the next line from the
file, except that the file handle has magically been reset to the
beginning of the file (or a few bytes from the beginning), and
instead of forking off about a dozen processes I end up forking
about two thousand of them! (FWIW, this is using Perl 5.6.1 on
Solaris 8 on a Sun machine.)
Interestingly, the script terminates after a lengthy but finite
time -- it doesn't seem to go on doing this forever, but what
it does on any particular occasion is pretty nondeterministic.
If I only have a couple of lines in the config file, it seems to
work fine.
I've worked around it by sucking the config file into an array and
then processing the array in the loop, but I'd like an explanation
of what's going wrong here, because I hate fixing problems when I
don't understand what's causing them, and this one's a forking weird
one... ;-)
TIA,
-----------------------------------------------------------------
John English | mailto:je@brighton.ac.uk
Senior Lecturer | http://www.comp.it.bton.ac.uk/je
Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS **
University of Brighton | -- see http://burks.bton.ac.uk
-----------------------------------------------------------------
------------------------------
Date: Fri, 19 Oct 2001 18:49:20 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Fork messes up parent file handle?
Message-Id: <QA_z7.191$1L8.199864832@news.frii.net>
In article <3BD073A8.59553E8@brighton.ac.uk>,
John English <je@brighton.ac.uk> wrote:
>I have a script which reads lines from a config file and forks off
>a seaparate child process for each line:
>
> while (<IN>) {
> $pid = fork;
> if ($pid) {
> &do_parent_stuff;
> }
> elsif (defined($pid)) {
> &do_child_stuff;
> last;
> }
> else {
> die "horribly";
> }
> }
> close IN;
>
>(Other stuff, like zombie reaping, is done but not shown here...)
>
You probably want the child to exit(0) after the do_child_stuff rather than
last.
Good Luck!
--
This space intentionally left blank
------------------------------
Date: Fri, 19 Oct 2001 20:02:31 GMT
From: "_Mario Latens" <mario.lat@libero.it>
Subject: how to use a function as function'sparam?
Message-Id: <20011019.215852.352118606.1207@localhost.localdomain>
I'd like tu use a function g(x)
I'd like to pass this function to another function: f(g(x))
how can I do that?
how can I call this function g in the "f function"?
Can you write a short and simple example?
Thank you in advance, Mario.
------------------------------
Date: Fri, 19 Oct 2001 15:37:12 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: how to use a function as function'sparam?
Message-Id: <3BD08EF8.63272513@home.com>
_Mario Latens wrote:
>
> I'd like tu use a function g(x)
> I'd like to pass this function to another function: f(g(x))
> how can I do that?
> how can I call this function g in the "f function"?
> Can you write a short and simple example?
That depends; do you want to pass the return value of g() to f(), or do
you want to pass the function itself?
To pass the return value, just provide it as an argument:
#!/usr/bin/perl -w
use strict;
print f(g('x'));
sub f {
return "f got '@_'";
}
sub g {
return "g got '@_'";
}
__END__
f got 'g got 'x''
To pass the function itself, use a reference:
#!/usr/bin/perl -w
use strict;
print f(\&g, 'x');
sub f {
my $sub = shift;
return "Called sub with '@_', got: [" . $sub->(@_) . "]"
}
sub g {
return "g got '@_'";
}
__END__
Called sub with 'x', got: [g got 'x']
-mjc
------------------------------
Date: Fri, 19 Oct 2001 21:18:41 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: how to use a function as function'sparam?
Message-Id: <3BD09754.BDCA6E2B@acm.org>
sub g {print "G";}
sub f {
my ($rsub) = @_;
print "F";
&$rsub();
}
f(\&g);
-- Dave Tweed
------------------------------
Date: Fri, 19 Oct 2001 23:43:57 +0200
From: "Wilbert van Diemen / Rudy van Doorn" <wilbert.van.diemen@hetnet.nl>
Subject: lookingglass.pl
Message-Id: <9qq74i$quj$1@news1.xs4all.nl>
Hi everybody,
Does anybody know a place on the net with information about lookingglass.pl,
a perl-program that can automatically upload all the files in a directory
(and the maps in this directory) on the basis of a conf-file.
I keep getting an error about:
"Can't use an undefined value as an ARRAY reference at LookingGlass.pl line
278, <> chunk 1."
On this line 278 is:
my ($maxsub) = scalar(@{@local_files[1]}) -1;
Anybody an idea?
Thanks in advance.
Wilbert van Diemen
------------------------------
Date: Fri, 19 Oct 2001 19:13:03 +0100
From: "Nathan Randle" <nathan.randle@ntlworld.com>
Subject: Opening files...
Message-Id: <pan.2001.10.19.19.13.03.61.2034@ntlworld.com>
I have started a script recently that uses the open command as shown
below:
open(FILE,$file) or die("Can't open the file: $!");
$file is the name of a file that I wish to open. the problem is with
using a variable like that. I have tried without the variable and it
works fine but once it is added the server can't find the file.
Any ideas?
Thx, Nathan.
------------------------------
Date: Fri, 19 Oct 2001 18:51:03 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Opening files...
Message-Id: <rC_z7.192$1L8.204690432@news.frii.net>
In article <pan.2001.10.19.19.13.03.61.2034@ntlworld.com>,
Nathan Randle <nathan.randle@ntlworld.com> wrote:
>I have started a script recently that uses the open command as shown
>below:
>
>open(FILE,$file) or die("Can't open the file: $!");
>
>$file is the name of a file that I wish to open. the problem is with
>using a variable like that. I have tried without the variable and it
>works fine but once it is added the server can't find the file.
>
Try chomp($file); before the open.
Good Luck!
--
This space intentionally left blank
------------------------------
Date: Fri, 19 Oct 2001 13:52:39 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Opening files...
Message-Id: <87zo6njwco.fsf@limey.hpcc.uh.edu>
>> On Fri, 19 Oct 2001 19:13:03 +0100,
>> "Nathan Randle" <nathan.randle@ntlworld.com> said:
> I have started a script recently that uses the open
> command as shown below:
> open(FILE,$file) or die("Can't open the file: $!");
> $file is the name of a file that I wish to open. the
> problem is with using a variable like that. I have tried
> without the variable and it works fine but once it is
> added the server can't find the file.
> Any ideas?
You need to show some functional example code that
exhibits the behaviour you describe. The extract you
included above has no context.
hth
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: Fri, 19 Oct 2001 14:59:41 -0400
From: peter <peter_icaza@REMOVE2REPLYuhc.com>
Subject: Re: Opening files...
Message-Id: <3BD0781D.B47FD27F@REMOVE2REPLYuhc.com>
you might have "something else" in the $file that you dont realize. try
printing the var out between brackets. something like... print <$file>
peter
------------------------------
Date: 19 Oct 2001 12:06:33 -0700
From: todd@designsouth.com (Todd Smith)
Subject: perl/dbi error kills server
Message-Id: <d2e0e3dd.0110191106.5b48b664@posting.google.com>
Has anybody ever had a certain perl/dbi/mysql error that results in an
eating of the processor resources until the server is practically
frozen? It never dies, I can still ping it, but it doesn't have enough
processor left to serve websites, or run telnet or ftp.
login.cgi is a very simple log-in script, it's just supposed to be a
test script so I can set up the database before I build the real
scripts, but it's giving me the most problems.
Todd.pm is a collection of database related subs that I've used in
lots of scripts before, and I didn't change anything for this one. But
I put it here anyway.
So the problem is, It seems to be going into some kind of infinite
loop, although there aren't any loops in the code. I've dealt with
lots of db errors before, but never one that kills my server before it
dies and gives an error message. I even used setpriority to put the
nice level at 19, and it still freezes it.
Since I've used Todd.pm before many times, I'm sure any problem would
have to be in login.cgi.
Thanks for any help!
-------------------login.html----------------------
<html>
<body>
<form action="login.cgi" method=post>
username <input name=username><Br>
password <input name=password><br>
<input type=submit>
</form>
</body>
</html>
---------------------------------------------------
-------------------login.cgi-----------------------
#!/usr/local/bin/perl
use Todd;
sub rl;
sub getcrypt;
content;
$username = get_one "username", "users", ["username", "password"],
[$cgi{'username'}, $cgi{'password'}];
if ($username) {
$dbh->do(qq{update users set loggedin = "$time", uid = "$uid"
where username = "$username"});
} else {
print "That username isn't registered."
exit;
}
@a = a..z;
$uid = getcrypt.getcrypt.getcrypt.getcrypt.getcrypt;
$time = time;
print "You're logged in. Your unique key is [$uid].";
sub rl { $a[int(rand(26))] };
sub getcrypt {
$salt = rl.rl;
$word = rl.rl.rl.rl.rl.rl.rl.rl.rl.rl.rl.rl;
$crypt = crypt $word, $salt;
}
-----------------------------------------------------
--------------Todd.pm--------------------------------
#!/usr/local/bin/perl
setpriority("PRIO_PROCESS", $$, 19);
sub err($);
$SIG{__DIE__} = sub{ err($_[0]) };
use CGI;
sub content;
sub db_connect;
sub email($$$$);
sub get_one($$$$);
sub get_row($$$);
sub get_rows($$$;$);
sub get_table($;$);
sub give_cookie($);
sub interpolate($$);
sub refresh_to($);
sub show_file($);
%cgi = ();
my $cgi = new CGI;
for ($cgi->cookie) {
$cookie{$_} = $cgi->cookie($_);
}
for ($cgi->param) {
$cgi{$_} = $in{$_} = $cgi->param($_);
}
$dbname = "name";
$dbhost = "127.0.0.1";
$dbuser = "user";
$dbpass = "pass";
sub db_connect {
return if ref $dbh;
$sth->finish if ref $sth;
use DBI;
$dbh=DBI->connect(
"DBI:mysql:database=$dbname;hostname=$dbhost",
$dbuser, $dbpass, {RaiseError=>1});
}
sub give_cookie($) {
$c = shift;
for $name (keys %$c) {
$cookie = $cgi->cookie(
-name => $name,
-value => $c->{$name}
);
push @cookies, $cookie;
}
print $cgi->header(-cookie=>[@cookies]);
}
sub get_one($$$$) {
my ($ret_column, $table, $match_column, $variable) = @_;
$table =~ /\w\w/ or err "Table [$table] is not correct";
if (ref $match_column) {
$condition = join ' and ',
map {
qq{
$match_column->[$_] =
'$variable->[$_]'
}
} 0..$#{$match_column}
} else {
$condition = "$match_column = '$variable'";
}
my $ret;
db_connect;
my $sth = $dbh->prepare("select $ret_column from $table where
$condition");
$sth->execute;
($ret) = $sth->fetchrow_array;
$sth->finish;
return $ret;
}
sub get_table($;$) {
my ($table, $options) = @_;
my @ret;
db_connect;
my $sth = $dbh->prepare("select * from $table $options");
$sth->execute;
while ($hr = $sth->fetchrow_hashref) {
push @ret, $hr;
}
$sth->finish;
return @ret;
}
sub err($) {
content;
show_file "header";
$message = $_[0] || '';
print <<STOP;
<center>
<table border=1>
<tr bgcolor=red>
<th>Error</th>
</tr>
<tr>
<td>$message</td>
</tr>
</table>
</center>
STOP
show_file "footer";
exit;
}
sub show_file($) {
open I, $_[0] or err "Problem opening $_[0]: $!";
print while <I>;
close I;
}
sub interpolate($$) {
content;
$file = shift;
$vars = shift;
open I, "$file" or err "Problem opening $file: $!";
while (<I>) {
s/%(.+?)%/$vars->{$1} || ''/eg;
print;
}
close I;
}
sub refresh_to($) {
content;
print <<REFRESH;
<html>
<head>
<meta http-equiv="refresh" content="0; url=$_[0]">
</head>
<body bgcolor=white>
<b>Please wait while the next page is loading...
<br><br>
<b>It may take a few seconds...</b>
</body>
</html>
REFRESH
}
sub email($$$$) {
($f, $t, $s, $b) = @_;
open M, "|/usr/lib/sendmail -t";
print M "To: $t\n";
print M "From: $f\n";
print M "Subject: $s\n";
print M "\n";
print M $b;
close M;
}
sub content {
print "Content-type: text/html\n\n" unless $pct++;
}
sub get_rows($$$;$) {
my ($table, $match_column, $variable, $options) = @_;
if (ref $match_column) {
$condition = join ' and ',
map {
qq{
$match_column->[$_] =
'$variable->[$_]'
}
} 0..$#{$match_column}
} else {
$condition = "$match_column = '$variable'";
}
my @ret;
db_connect;
my $sth = $dbh->prepare("select * from $table where
$condition");
$sth->execute;
while ($hr = $sth->fetchrow_hashref) {
push @ret, $hr;
}
$sth->finish;
return @ret;
}
sub get_row($$$) {
my ($table, $match_column, $variable) = @_;
if (ref $match_column) {
$condition = join ' and ',
map {
qq{
$match_column->[$_] =
'$variable->[$_]'
}
} 0..$#{$match_column}
} else {
$condition = "$match_column = '$variable'";
}
my @ret;
db_connect;
my $sth = $dbh->prepare("select * from $table where
$condition");
$sth->execute;
$ret = $sth->fetchrow_hashref;
$sth->finish;
return $ret;
}
END {
$sth->finish if ref $sth;
$dbh->disconnect if ref $dbh;
}
1;
-------------------------------------------------------------------------
------------------------------
Date: 19 Oct 2001 16:29:41 -0400
From: Dave K. <david345@toast.com>
Subject: Problem installing DBD
Message-Id: <9qq2fl$hon$1@panix3.panix.com>
I'm trying to install the DBD::mysql Perl module, but I'm getting an
error I'm not sure how to deal with. It has to do with the linker
flags -lz and -lgz.
I assume that these flags refer to libz and libgz, but I've come
across stuff to suggest that -lz really refers to zlib, not libz.
Which is it?
I was not able to find either libz or libgz at the Debian packages
site. A Google search was no help. Where can I find these libraries,
in either .deb or tar.gz/.tgz form?
Thanks,
Dave
P.S. Below is the full output from perl Makefile.PL and make.
This is an experimental version of DBD::mysql. For production
environments you should prefer the Msql-Mysql-modules.
I will use the following settings for compiling and testing:
testpassword (default) =
testhost (default) =
testuser (default) =
nocatchstderr (default) = 0
libs (guessed) = -L/usr/local/mysql/lib -lmysqlclient -lz -lgz
cflags (guessed) = -I/usr/local/mysql/include
testdb (default) = test
To change these settings, see 'perl Makefile.PL --help' and
'perldoc INSTALL'.
Note (probably harmless): No library found for -lgz
Using DBI 1.20 installed in /usr/local/lib/perl5/site_perl/5.6.1/i586-linux/auto/DBI
Writing Makefile for DBD::mysql
make:
cc -c -I/usr/local/lib/perl5/site_perl/5.6.1/i586-linux/auto/DBI -I/usr/local/mysql/include -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"2.0902\" -DXS_VERSION=\"2.0902\" -fpic -I/usr/local/lib/perl5/5.6.1/i586-linux/CORE dbdimp.c
cc -c -I/usr/local/lib/perl5/site_perl/5.6.1/i586-linux/auto/DBI -I/usr/local/mysql/include -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"2.0902\" -DXS_VERSION=\"2.0902\" -fpic -I/usr/local/lib/perl5/5.6.1/i586-linux/CORE mysql.c
Running Mkbootstrap for DBD::mysql ()
chmod 644 mysql.bs
rm -f blib/arch/auto/DBD/mysql/mysql.so
LD_RUN_PATH="/usr/local/mysql/lib:/usr/lib" /usr/local/bin/perl myld cc -shared -L/usr/local/lib dbdimp.o mysql.o -o blib/arch/auto/DBD/mysql/mysql.so -L/usr/local/mysql/lib -lmysqlclient -lz
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
An error occurred while linking the DBD::mysql driver. The error
message seems to indicate that you don't have a libz.a, libgz.a,
libz.so or libgz.so. This is typically resolved by:
1.) You may try to remove the -lz or -lgz flag from the libs list
by using the --libs switch for "perl Makefile.PL".
2.) On Red Hat Linux install libz-devel
3.) On other systems, please contact the mailing list
Msql-Mysql-modules@lists.mysql.com
For further hints, see INSTALL.html, section Linker flags.
make: *** [blib/arch/auto/DBD/mysql/mysql.so] Error 1
------------------------------
Date: Fri, 19 Oct 2001 12:48:52 -0700
From: "Brian Helterline" <brian_helterline@hotmail.com>
Subject: Re: serial comm on Win2000
Message-Id: <9qq039$pjb$1@hpcvnews.cv.hp.com>
"harris" <harris_m@yahoo.com> wrote in message
news:af968c64.0110181048.31edb018@posting.google.com...
> Hi,
> I tried using Win32API::CommPort module to send and receive some text
> data over serial port.
>
> My test prog as follows (which fails)-
>
> use Win32API::CommPort;
>
> $PortName = "COM2";
> $PortObj = new Win32API::CommPort ($PortName) || die "Can't open
> $PortName: $^E\n";
>
>
> Reason to fail is "CommPort.pm" uses Win32::API and it can not find
> Win32::API module file.
>
> I searched for API.pm on my machine as well on CPAN but could not find
> it.
>
> My perl version is ActiveState Perl 5.6.1 for Win32 multithread
>
> Question:
> 1. Any one tried to use Win32API::CommPort and had similar problem?
> Any solution found?
> 2. Any one tried serial comm on Win2000 using Perl?
> Thank you,
> Harris M.
Get Win32:API at
http://dada.perl.it/
and use SerialPort, not CommPort
------------------------------
Date: Fri, 19 Oct 2001 13:40:55 -0700
From: "Brian Helterline" <brian_helterline@hotmail.com>
Subject: Re: serial comm on Win2000
Message-Id: <9qq34s$r6v$1@hpcvnews.cv.hp.com>
"harris" <harris_m@yahoo.com> wrote in message
news:af968c64.0110181048.31edb018@posting.google.com...
> Hi,
> I tried using Win32API::CommPort module to send and receive some text
> data over serial port.
>
> My test prog as follows (which fails)-
>
> use Win32API::CommPort;
>
> $PortName = "COM2";
> $PortObj = new Win32API::CommPort ($PortName) || die "Can't open
> $PortName: $^E\n";
>
>
> Reason to fail is "CommPort.pm" uses Win32::API and it can not find
> Win32::API module file.
>
> I searched for API.pm on my machine as well on CPAN but could not find
> it.
>
> My perl version is ActiveState Perl 5.6.1 for Win32 multithread
>
> Question:
> 1. Any one tried to use Win32API::CommPort and had similar problem?
> Any solution found?
> 2. Any one tried serial comm on Win2000 using Perl?
> Thank you,
> Harris M.
Harris,
You sould be using Win32:SerialPort for talking to com ports (on Windows).
SerialPort uses the lower level functions found in Win32API::CommPort.
Here's the trick: (or history lesson)
The SerialPort module uses the original Win32API module by Aldo Calpini
(http://dada.perl.it) but that has been upgraded to the newer naming
convention: Win32::API. The SerialPort module has not - it still want
Win32API::CommPort, not Win32::API::CommPort.
You can still get Win32API from CPAN as part of the SerialPort module.
(Search for Win32-SerialPort)
Enjoy.....
-brian
------------------------------
Date: Fri, 19 Oct 2001 21:41:15 +0100
From: "Bill Leigh" <bill.leigh@leighly.fsnet.co.uk>
Subject: SOAP Web Services Mailing List
Message-Id: <9qq3mu$sp5$1@newsg2.svr.pol.co.uk>
The following mailing list sends out a weekly email
about web services you can use within any of the
following languages: Delphi, ASP.NET,VB, C++,
ASP, Perl, Linux, Unix, Windows, Cobol, Fortran,
Paradox:
http://www.salcentral.com/salnet/subscribe.htm
Newsletter contains independant information from 100's
of companies around the world about web services being
offered over the internet.
Bill Leigh
------------------------------
Date: Fri, 19 Oct 2001 10:42:39 -0700
From: Roger Levy <rog@stanford.edu>
Subject: Truncation of array through reference
Message-Id: <Pine.GSO.4.33.0110191034350.7149-100000@elaine31.Stanford.EDU>
Hi friends,
I discovered what is to me a pretty non-intuitive fact just now, and I was
wondering about the explanation. I was trying to do array truncation
through references, and it turns out that if I have @ARRAY, and $A points
to it, then
$#$A, $#ARRAY, and $#{\@ARRAY}
are the same thing. To me this was pretty non-intuitive, since ARRAY
can't be used equivalently to \@ARRAY in general. So should I think of
the above as
I) not being able to use ARRAY as a reference to @ARRAY is a special fact;
or
II) being able to use $#ARRAY as $#{\@ARRAY} is a special fact;
or
III) something more complicated is going on?
Enlightenment would be much appreciated.
Many thanks,
Roger
------------------------------
Date: Fri, 19 Oct 2001 21:46:20 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Truncation of array through reference
Message-Id: <slrn9t154n.uo7.tadmc@tadmc26.august.net>
Roger Levy <rog@stanford.edu> wrote:
>Hi friends,
>
>I discovered what is to me a pretty non-intuitive fact just now, and I was
>wondering about the explanation. I was trying to do array truncation
>through references, and it turns out that if I have @ARRAY, and $A points
>to it, then
>
>$#$A,
access via a reference ( a special case of $#{$A} )
>$#ARRAY,
access via a name
> and $#{\@ARRAY}
access via a reference
>are the same thing. To me this was pretty non-intuitive, since ARRAY
>can't be used equivalently to \@ARRAY in general.
@ARRAY can be used equivalently to @{\@ARRAY} or @{$A} or @$A.
They are applications of "Use Rule 1" in
perldoc perlreftut
s/\@/$#/ for all 4 above, and you have the same as your examples.
>So should I think of
>the above as
>
>I) not being able to use ARRAY as a reference to @ARRAY is a special fact;
ARRAY is a bare word. It is not associated with ANY variable,
so I don't follow that one...
>II) being able to use $#ARRAY as $#{\@ARRAY} is a special fact;
the first is accessing via a name, the second is accessing
via a reference.
>III) something more complicated is going on?
There are two ways of "getting to" a variable, via a name or
via a reference.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 19 Oct 2001 17:35:52 -0400
From: "Usyk, Walter [SKY:1P67:EXCH]" <wusyk@americasm01.nt.com>
Subject: Unistalling a package
Message-Id: <3BD09CB8.88796C2@americasm01.nt.com>
How do you uninstall a package using perl -MCPAN -e shell?
Do I just erase that pacakge from the perl lib directory and then
re-install it?
Thanks for your help
--
Walter Usyk - Tools Developer
Software Development Environment Tools (1P67)
email: wusyk@nortelnetworks.com
ESN: 398-4603
Tel: (613) 768-4603
------------------------------
Date: Fri, 19 Oct 2001 15:02:42 -0400
From: peter <peter_icaza@REMOVE2REPLYuhc.com>
Subject: what happened to
Message-Id: <3BD078D2.5245B4F3@REMOVE2REPLYuhc.com>
Abigail,(sp), tom and randal et al? i was away for a while and now i
dont see them respond to posts any more.
thanks,
peter
------------------------------
Date: Fri, 19 Oct 2001 19:10:38 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: what happened to
Message-Id: <x7u1wv4f8s.fsf@home.sysarch.com>
>>>>> "p" == peter <peter_icaza@REMOVE2REPLYuhc.com> writes:
p> Abigail,(sp), tom and randal et al? i was away for a while and now i
p> dont see them respond to posts any more.
tom hasn't been here for years. randal and abigail are still around here
on occassion.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: 19 Oct 2001 12:31:49 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: what happened to
Message-Id: <m1adyn1l5m.fsf@halfdome.holdit.com>
>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:
>>>>> "p" == peter <peter_icaza@REMOVE2REPLYuhc.com> writes:
p> Abigail,(sp), tom and randal et al? i was away for a while and now i
p> dont see them respond to posts any more.
Uri> tom hasn't been here for years. randal and abigail are still around here
Uri> on occassion.
I post a lot more to PerlMonks.org and the perl-beginners list now.
As well as the template-toolkit list, mod_perl, and everything else
I'm interested in. I don't do *quite* as much with CLPM any more.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
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.
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 1965
***************************************