[13276] in Perl-Users-Digest
Perl-Users Digest, Issue: 686 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 31 10:07:22 1999
Date: Tue, 31 Aug 1999 07:05:11 -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 Tue, 31 Aug 1999 Volume: 9 Number: 686
Today's topics:
Re: $x=('a','b','c','d'); $x=('a'..'d'); $x=(($m,$n)= (Gabor)
Re: Amsterdam Perl Mongers Meeting (Leon Brocard)
Auto actions on popup_menu's <alister@ihug.co.nz>
Can you use data encryption within your perl script? jeremy_savage@my-deja.com
Can't use telnet with telnetd server <scarlzong@hotmail.com>
Re: File listing <meowing@banet.net>
Re: File listing (Gabor)
Format Problem: Saving CGI Objects (space = "+" not "%2 <sushant@hindustan.vnet.net>
How do I dereference in a sub? <jsjensen@Paramin.COM>
How to process file of this format (see inside) <pandpATibm.net>
Re: How to process file of this format (see inside) <jpeterson@office.colt.net>
More links about Perl (russian text only!) in the frien <zvyagin@my-deja.com>
Perl / C Memory <sam@khan.epita.fr>
Perl consuming 100% CPU on WinNT <sushant@hindustan.vnet.net>
Re: Perl Y2K Bugs on the Internet (Bbirthisel)
Problem with <!--#exec cgi=/scripts/script.pl%22--> in (McNally, Lisa)
Problem with <!--exec cgi="/scripts/script.pl"--> in II <lisa_mcnally@mail.crc.com>
Re: Request for Comments: www.perl.com (Chris Nandor)
Re: Request for Comments: www.perl.com (David Cantrell)
Re: Select Multiple Form Field via Perl into Oracle err (Jacqui Caren) (Jacqui Caren)
Re: test, please ignore <mike@crusaders.no>
Using grep to match complete words (Larry James)
Using PGP encryption within your perl program? jeremy_savage@my-deja.com
Why doesn't my undef an array? <iansmith@pepper.ncinter.net>
Re: Win32::ODBC <Joachim.Nock@sirona.de>
Re: write to a file in a loop <epimenta@my-deja.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 31 Aug 1999 08:09:53 -0400
From: gabor@vmunix.com (Gabor)
Subject: Re: $x=('a','b','c','d'); $x=('a'..'d'); $x=(($m,$n)=('a'..'d'))
Message-Id: <slrn7snhgh.4ke.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, John Lin <johnlin@chttl.com.tw> wrote :
# # Here is a quiz. Guess the outputs before you run it.
#
# @a=('a','b','c','d'); $x=@a; print "output1= @a,$x\n";
output1= a b c d,4
# $x=('a','b','c','d'); print "output2= $x\n";
output2= d
# @a=('b','c','d'); $x=('a',@a); print "output3= $x\n";
output3= 3
# @a=('a'..'d'); $x=@a; print "output4= @a,$x\n";
output4= a b c d,4 # same as output1
# $x=('a'..'d'); print "output5= $x\n";
output5=
#
# @a=(($m,$n)=('a'..'d')); $x=@a; print "output6= @a,$x\n";
output6= a b,2
# $x=(($m,$n)=('a'..'d')); print "output7= $x\n";
output7= ?
#
# print "output8= ",('a','b','c','d'),"\n";
output8= abcd
# print "output9= ",('a'..'d'),"\n";
output9= abcd # same as above
# print "output10= ",(($m,$n)=('a'..'d')),"\n";
output10= ab
#
# # How many answers did you get right?
Hmm, I don't get output7. I expected it to produce 2 but it produces
4. So I got 9 out of 10
------------------------------
Date: 31 Aug 1999 13:40:24 GMT
From: acme@tigger.netcraft.com (Leon Brocard)
Subject: Re: Amsterdam Perl Mongers Meeting
Message-Id: <slrn7snm4n.46t.acme@tigger.netcraft.com>
Eric Veldhuyzen typed out randomly:
] Met voldoende bier natuurijk!
Ack, ack, and don't I miss that Dutch beer...[1]
Leon
[1] Although real ale is a worth substitute...
--
Leon Brocard................................http://bath.pm.org/
leon@netcraft.com........................http://www.astray.com/
... Hard work has a future payoff. Laziness pays off now.
------------------------------
Date: Tue, 31 Aug 1999 23:08:40 +1200
From: "Aaron Lister" <alister@ihug.co.nz>
Subject: Auto actions on popup_menu's
Message-Id: <7qgdar$hfg$1@newsource.ihug.co.nz>
How do I have an action run automatically when an item is selected from a
popup_menu in a per/cgi script without using JavaScript?
------------------------------
Date: Tue, 31 Aug 1999 13:40:28 GMT
From: jeremy_savage@my-deja.com
Subject: Can you use data encryption within your perl script?
Message-Id: <7qgm0a$jrp$1@nnrp1.deja.com>
I am currently working on a project where I have
to use data encyption within my perl script. I
know how to open a dos session window using the
open command with a pipe, but I can't seem to run
any command once I start the PGP (data encryption)
process. Anyway, if anyone has performed data
encrytion from within their perl script can you
please let me know what encryption tool you used
and how you did it?
Thanks!
Jeremy Savage
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 31 Aug 1999 14:09:04 +0200
From: "Sune Carlzon" <scarlzong@hotmail.com>
Subject: Can't use telnet with telnetd server
Message-Id: <BBPy3.6$qd1.16749@uab.ericsson.se>
Hi,
I am trying to setup a script that via telnet issues a couple of commands
and stores the result for evaluation.
You can see the outline of the script below. I have tried the script against
an ordinary Sun Solaris telnet server
and it works quit fine (I have to hit return once first, haven't figured out
why) but when I try against a WinNT machine with a TelnetD server from
Pragma Systems I always get a timeout at the $tel->cmd command. I have tried
setting the cmd timeout parameter, setting the cmd prompt parameter and
changing the prompt in the telnet session but still no success.
Anyone that has any idea what's going wrong ?
regards,
use Win32;
use Net::Telnet ();
use Term::ReadLine;
if ( $ARGV[0] eq "unix" )
{
$tel=new Net::Telnet;
$tel->open("unix");
$tel->waitfor('/login/');
$tel->print("login");
$tel->waitfor('/Password/');
$tel->print("password");
$tel->waitfor('/aplab:/');
$host=$tel->host;
}
if ( $ARGV[0] eq "winnt" )
{
$tel=new Net::Telnet;
$tel->open("winnt");
$tel->waitfor('/login/');
$tel->print("administrator");
$tel->waitfor('/password/');
$tel->print("");
$tel->waitfor('/Domain/');
$tel->print("");
$tel->waitfor('/Choice/');
$tel->print("1");
$tel->waitfor('/C:/');
$host=$tel->host;
}
print "You have logged into $host!!!\n";
$tel->cmd('dir'),
exit;
------------------------------
Date: 31 Aug 1999 07:07:34 -0400
From: meow <meowing@banet.net>
Subject: Re: File listing
Message-Id: <87btboi4y1.fsf@slip-32-100-243-84.ma.us.ibm.net>
Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote:
>> There's definitely not consensus on whether dot-files should be left
>> out by default. It doesn't even hold across Unix versions, let alone
>> the other stuff out there.
> Which version of sh included dot-files in a * wild-card expansion?
Any system with bash has it. shopt -s dotglob
Some V7, everything older.
Macs don't care 'bout no dots.
VMS? well, just don't try to delete one, especially if you've got
FOO.BAR and .BAR in the same dorectory :P
DOS/Win don't care.
> It is to most unix users, who would be amazed to find the dozens of
> files they have gathered in their home directory over the years without
> realising it...
That would be a good thing. Seeing what's lurking under
$HOME/.netscape would prevent some of those puzzled looks over quotas.
And of course, just adding a ^[^.].* to that regexp would get rid of the
darned things if they really frighten people.
------------------------------
Date: 31 Aug 1999 08:15:43 -0400
From: gabor@vmunix.com (Gabor)
Subject: Re: File listing
Message-Id: <slrn7snhrf.4ke.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Sam Holden <sholden@pgrad.cs.usyd.edu.au> wrote :
# On 31 Aug 1999 02:04:10 -0400, meow <meowing@banet.net> wrote:
# >Abigail <abigail@delanet.com> wrote:
# >
# >
# >> {} opendir(DIR, $dirtosearch) or die $!;
# >> {} my @messofiles = grep { /$findwhat/ && -f "$dirtosearch/$_" } readdir(DIR);
# >> {} closedir(DIR);
# >
# >> The problem with that is that it will return files with names like
# >> ".foo.txt", which aren't matched by the shell "*.txt" wildcard.
# >
# >There's definitely not consensus on whether dot-files should be left
# >out by default. It doesn't even hold across Unix versions, let alone
# >the other stuff out there.
#
# Which version of sh included dot-files in a * wild-card expansion?
#
# >> specially not in this case, where the obvious Perl alternative is
# >> wrong.
# >
# >It's not at all clear that dot files should be hidden.
#
# It is to most unix users, who would be amazed to find the dozens of
# files they have gathered in their home directory over the years without
# realising it...
#
# Shell globbing ignores them, ls ignores them by default. Under unix you
# aren't going to see them without trying...
Balderdash. Both zsh and bash will let you see them nicely as they
should. The Bourne shell and csh won't glob them. It was merely a
design decision. dot files aren't inherently invisible.
------------------------------
Date: Tue, 31 Aug 1999 08:49:13 -0400
From: Sushant Gargya <sushant@hindustan.vnet.net>
Subject: Format Problem: Saving CGI Objects (space = "+" not "%20")
Message-Id: <37CBCF48.842D01AD@hindustan.vnet.net>
Hi Everyone,
I recently made some minor changes to our software package
(Ecommerce). In doing so, it seems like I must have screwed
something up.
The overall process is the following:
We save order information (CGI object) in a file like:
open(order,">>somefile");
$query->save(order);
Before we started having problems, the contents of the file were
saved correctly (url encoded). That is:
FIRSTNAME LASTNAME was initally being saved as:
FIRSTNAME%20LASTNAME
Now, it's being saved as:
FIRSTNAME+LASTNAME
In other words, any variable that has spaces between is saved
as "+" as oppose to "%20" (url code for the space).
Any ideas as to what could be causing this?? I would appreciate
any pointers....Also, please let me know if there any other piece of
information
that would be helpful.
Please direct all responses to sushant@hindustan.vnet.net
Regards,
-sushant
------------------------------
Date: Tue, 31 Aug 1999 07:48:53 -0600
From: "J. S. Jensen" <jsjensen@Paramin.COM>
Subject: How do I dereference in a sub?
Message-Id: <37CBDD44.A0DE69F@Paramin.COM>
When I try to dereference in a subroutine, it doesn't seem to work. Can
anyone tell me why? I guess code would be the best to describe this:
sub t {
my $ret = $_[0];
$$_[1] = $ret;
return $ret;
}
$foo = "foo";
print t("bar",\$foo) . $/;
print $foo . $/;
why is the output ``bar\nfoo\n'' when shouldn't it be ``bar\nbar\n'' ?
I can do this:
$bar = \$foo;
print $$bar;
and it works just fine, why won't it work in a sub when referencing the
@_ ?
Thanks...
--
J. S. Jensen
mailto:jsjensen@Paramin.COM
http://www.Paramin.COM
------------------------------
Date: Tue, 31 Aug 1999 14:01:41 +0100 (BST)
From: "Philip Nelson" <pandpATibm.net>
Subject: How to process file of this format (see inside)
Message-Id: <cnaqcvozarg.fhccqt0.pminews@news2.ibm.net>
I want to write a Perl script to process a file of the following format -
Header 1
Header 1 Detail Line 1
...
Header 1 Detail Line n
Header 2
Header 2 Detail Line 1
...
Header 2 Detail Line m
etc.
This is the output from a database trace program, where each event produces
about a dozen lines of output, and there are about 10 different types of
events.
What I want to do is produce one output file for each event type, with one
row per event - I'm going to load this into a database table for further
analysis.
TIA
Phil Nelson
DBA
Scottish Widows
(pandp@ibm.net)
------------------------------
Date: Tue, 31 Aug 1999 13:35:27 GMT
From: Jon Peterson <jpeterson@office.colt.net>
Subject: Re: How to process file of this format (see inside)
Message-Id: <zSQy3.41$xa4.433@news.colt.net>
Philip Nelson <pandpATibm.net> wrote:
> I want to write a Perl script to process a file of the following format -
> Header 1
> Header 1 Detail Line 1
> ...
> Header 1 Detail Line n
> Header 2
> Header 2 Detail Line 1
> ...
> Header 2 Detail Line m
One general approach might be to loop over each line in the file, determining
its type (header, detail, or separator) with a regular expression, and then
acting accordingly. For instance:
open (IN, '/path/to/file.name') or die "Opening error: $!"; #open file
my $Section; # Holds the current header type
my %Data; # Holds data keyed on $Section
while (<IN>)
{
if ($_ =~ /Header/) #if the line is a header...
{
chomp($_); #Get rid of newline character on the header line
$Section = $_; # $Section stores the current header;
}
elsif ($_ =~ /^\n$/) #if it's a blank line (ie contains only a newline)
{
undef $Section; # clear the section type not required, just
# to mark newlines we can use this for some
# simple error checks too
}
else
{
die "File format error!!" unless defined $Section; #see above
$Data{$Section} .= $_; #append the line to its section in a
# hash table.
}
}
close (IN);
# Now we have our data sorted by Header type, in the hash %Data. It's up to
# you to play with it, write it out, whatever, e.g.
@array_of_sections = keys %Data;
print "Details of Section 'foobar' are $Data{foobar}\n";
> Phil Nelson
> DBA
> Scottish Widows
Good to know my pension is safe with Perl!
------------------------------
Date: Tue, 31 Aug 1999 12:57:20 GMT
From: Aleksey Zvyagin <zvyagin@my-deja.com>
Subject: More links about Perl (russian text only!) in the friendly catalogue PINGWIN
Message-Id: <7qgjf9$hn6$1@nnrp1.deja.com>
More links about Perl (russian text only!) in the friendly catalogue
PINGWIN
http://pingwin.net.ru/node/perl/ - Perl directory
http://pingwin.net.ru/node/PerlLearning/ - How to begin to learn the
Perl
http://pingwin.net.ru/node/PerlModules/ - The Perl modules
******************************************************************
http://pingwin.net.ru/
PINGWIN - the unique, friendly link catalogue:
* The PERSONAL behaviour for an every visitor!
* The PERSONAL REMINDING about a newest links!
* More than 20000 links of russian and foreign internet resources,
about 1000 directories!
* Every visitor to be having own pocket of links!
* The rating order of links!
* And more, more, more ...
ATTENTION! Russian language only!!! (I think while...)
http://pingwin.net.ru/
******************************************************************
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 31 Aug 1999 14:35:29 +0000
From: samuel Lellouche <sam@khan.epita.fr>
Subject: Perl / C Memory
Message-Id: <u5u2pgdnm6.fsf@khan.i-did-not-set--mail-host-address--so-shoot-me>
Here is what i noticed;
(I'm on NetBSD 1.4 with perl, version 5.004_04 built for i386-netbsd)
here is test.c :
#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */
PerlInterpreter *my_perl; /***The Perl interpreter***/
int main(int argc, char **argv, char **env)
{
char *argv2[] = {"","client_init2.pl",0};
int argc2;
argc2 = 1;
while (1)
{
my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl, NULL, argc2, argv2, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
sleep (1);
}
}
i compile this with:
cc -o test test.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
as explained in the mans.
Here is the client_init2.pl:
print "Perl Execution\n";
i'm doing a top during the execution:
MEM
11639 netsoul 10 0 680K 928K sleep 0:00 0.00% 0.00% test
a few secs after
11639 netsoul 10 0 1788K 2036K sleep 0:00 0.00% 0.00% test
still a few secs later
11639 netsoul 10 0 2224K 2472K sleep 0:00 0.00% 0.00% test
the .pl file is very light.. this memory problem is much bigger when the
.pl includes some "require" and more code....
It seems to me that the perl interpreter dosn't free everything it uses...
Anyone got that problem already, or can tell me if i 'm doing anything
wrong...
merci.
sam@epita.fr
------------------------------
Date: Tue, 31 Aug 1999 08:27:09 -0400
From: Sushant Gargya <sushant@hindustan.vnet.net>
Subject: Perl consuming 100% CPU on WinNT
Message-Id: <37CBCA1D.83BF2DCE@hindustan.vnet.net>
Hi Everyone,
I work for a small company that does E-commerce. Most of
the package is written in Perl. We are using the latest perl
executables and the necessary modules. Despite of that I
see perl using 100% of cpu on NT. This creates side affects
such as the Microsoft IIS 4.0 not able to respond to http
request in time as all the cpu cycles have been hogged by perl.
I can look at the taskmgr and see the "perl.exe" taking up all
the cycles. For test purposes I even created some extremely
trivial perl scripts which seem to have similar behavior.
Any help/suggestion would be much much apreciated.
Please direct any responses directly to sushant@hindustan.vnet.net.
Regards,
-sushant
------------------------------
Date: 31 Aug 1999 13:56:34 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Perl Y2K Bugs on the Internet
Message-Id: <19990831095634.17669.00001919@ng-fd1.aol.com>
Hi John:
>Mark W. Schumann <catfood@apk.net> wrote:
>>>Worse - it didn't mention 'ctime' in relation to tm structs
>>>and on page 321 it actually *used* "19$year"!
>
>> Your example from the Pink Camel is indeed apalling if true.
>
>It's in there, in the "real programming examples" chapter (or whatever
>that was called). I had to see it to believe it myself.
Perhaps you should check the exact context in Pink Camel.
The "rest of the story" is relevant.
# These next few lines are legal in both Perl and nroff.
[snip]
';__END__ ##### From here on it's a standard manual page #####
.TH $PROG 1 "$month $mday, 19$year"
Maybe we should direct the Y2K police to read everything
ever generated via nroff ;-)
-bill
Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Tue, 31 Aug 1999 04:44:45 -0800
From: lisa_mcnally@mail.crc.com (McNally, Lisa)
Subject: Problem with <!--#exec cgi=/scripts/script.pl%22--> in IIS4
Message-Id: <i3Qy3.193$Zd.115288@WReNphoon3>
Hi -
I am having a problem calling my perl script from an HTML document using the
%22exec cgi%22 statement. If I call the script directly by using
http://server/scripts/script.pl? it works fine (the counter increments and
the digits are displayed). However if I use the <!--exec
cgi=%22/scripts/script.pl%22--> from within a HTML document nothing happens.
I am running IIS 4 on an NT 4.0 SP 5 server. The script ran fine before we
upgraded the server from IIS 3. Any ideas?? This one really has me
baffled.
Thanks in advance - Lisa
-**** Posted from RemarQ, http://www.remarq.com/?b ****-
Real Discussions for Real People
------------------------------
Date: Tue, 31 Aug 1999 09:21:09 -0400
From: "Lisa McNally" <lisa_mcnally@mail.crc.com>
Subject: Problem with <!--exec cgi="/scripts/script.pl"--> in IIS4
Message-Id: <7qgks4$jt0@hobbes.crc.com>
Hi -
I am having a problem calling my perl script from an HTML document using the
"exec cgi" statement. If I call the script directly by using
http://server/scripts/script.pl? it works fine (the counter increments and
the digits are displayed). However if I use the "<!--exec
cgi="/server/script.pl"-->" from within a HTML document nothing happens. I
am running IIS 4 on an NT 4.0 SP 5 server. The script ran fine before we
upgraded the server from IIS 3. Any ideas?? This one really has me baffled.
Thanks in advance - Lisa
------------------------------
Date: Tue, 31 Aug 1999 11:47:46 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Request for Comments: www.perl.com
Message-Id: <pudge-3108990747480001@192.168.0.16>
In article <37cb996d.316544757@news.insnet.net>, NukeEmUp@ThePentagon.com
(David Cantrell) wrote:
# On Fri, 27 Aug 1999 15:34:21 GMT, pudge@pobox.com (Chris Nandor) said:
#
# >Regardless of how useful it would be, there is such a thing as a private
# >news server. It doesn't have to be available to all of Usenet to be a
# >newsgroup.
#
# Private news servers are a Bad Idea, as many commonly used news
# clients are a right pain in the backside to configure for using more
# than one server
So a company that does not allow access to an external news server anyway
should use this as a reason not to set up a private news server
internally? Silliness.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Tue, 31 Aug 1999 13:10:37 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: Request for Comments: www.perl.com
Message-Id: <37cbd324.331319151@news.insnet.net>
On Tue, 31 Aug 1999 11:47:46 GMT, pudge@pobox.com (Chris Nandor) said:
>In article <37cb996d.316544757@news.insnet.net>, NukeEmUp@ThePentagon.com
>(David Cantrell) wrote:
>
># Private news servers are a Bad Idea, as many commonly used news
># clients are a right pain in the backside to configure for using more
># than one server
>
>So a company that does not allow access to an external news server anyway
>should use this as a reason not to set up a private news server
>internally? Silliness.
I couldn't agree more.
However, in this thread we are talking about how to improve the
service offered to users by www.perl.com. It is in that context that
my comments should be read.
Note that I referred to problems with setting up the client to use
MORE THAN ONE SERVER, which obviously doesn't apply in the case you
mention.
[Copying newsgroup posts to me by mail is considered rude]
--
David Cantrell, part-time Unix/perl/SQL/java techie
full-time chef/musician/homebrewer
http://www.ThePentagon.com/NukeEmUp
------------------------------
Date: Tue, 31 Aug 1999 12:54:17 GMT
From: Jacqui.Caren@ig.co.uk (Jacqui Caren) (Jacqui Caren)
Subject: Re: Select Multiple Form Field via Perl into Oracle error
Message-Id: <FHByIH.Kp8@ig.co.uk>
In article <ej%w3.1$2B2.769@news.enterprise.net>,
Simmo <simsi@hotmail.com.nospam> wrote:
>Hi,
>
>Apologies for submitting this to both groups but I'm relatively new to
>Oracle and i'm not sure which is relevant to this problem - it may even be
>an HTML thing although i probably need a Perl line or an SQL statement to
>rectify it:-).
>
>I have a web Form with a select multiple attribute which Perl takes and
>sends to an Oracle 8.1 table 'news'. If i select 1 item its fine...if i
>select more than one i get:
>
>DBD::Oracle::db prepare failed: ORA-01756: quoted string not properly
>terminated (DBD ERROR: OCIStmtPrepare) at news.pl line 855.
>
>....although my perl script suggests there is nothing unusual about the
>multiple FORM string, i have a sneaking suspicion that there's a funny
>character in there that i need to remove in the Perl script before Inserting
>into my table.
>
>Anyone come across this before? - i cant seem to find anything that sugegsts
>there *is* a character in there but....
>
>An example string i'm writing incidentally is:
>
>$categories_selected = $FORM{'categories'};
$categories_selected = $dbh->escape($FORM{'categories'});
should fix your problem...
>$SQL1 = "INSERT into news (type) VALUES ('$categories_selected')";
>my $sql = qq{ $SQL1 };
why do you do this? It has no real effect...
>my $sth=$dbh->prepare( $sql );
>$sth->execute();
If you can use bind variables you can do the following
my $sth = $dbh->prepare('insert into news (type) values (?)');
$sth->execute($FORM{categories});
$sth->finish();
Of course a much better approach would be something such as...
my $sth = $dbh->prepare('insert into news (type) values (?)');
die $dbh->errstr if $dbh->err;
foreach my $cat ($cgi->param('categories')) {
$sth->execute($cat);
warn $dbh->errstr if $dbh->err;
}#
$sth->finish();
die $dbh->errstr if $dbh->err;
this will create one entry for each button clicked - and 'warn' you
if an entry could not be created for some reason...
Jacqui
--
Paul Ingram Group Ltd,140A High Street,Godalming GU7 1AB United Kingdom
Email: J.Caren@ig.co.uk Fax: +44 1483 862801 Phone: +44 1483 862800
A rather special Perl vacancy :-) http://www.ig.co.uk/about/jobs.html
Use SmartCards in e-commerce systems? http://www.smartaxis.com/
------------------------------
Date: Tue, 31 Aug 1999 13:29:16 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: test, please ignore
Message-Id: <y0Py3.203$Rs6.1579@news1.online.no>
Peter Wilkinson <peterw@innate.co.uk> wrote in message
news:936097141.6382.0.nnrp-10.c3ada081@news.demon.co.uk...
OK, you're ignored.
*plonk*
--
Trond Michelsen
------------------------------
Date: 31 Aug 1999 13:57:51 GMT
From: ljames@apollo.apollo3.com (Larry James)
Subject: Using grep to match complete words
Message-Id: <7qgn0v$a15$1@hera.buffalointer.net>
I have a grep script to check for the presents of a word in a list
of words. My problem is that if the current word is "hello" and the
list has a word "hello2" because "hello2" has "hello" included, this
will show up as found.
My script goes as:
---------------
for i in wordlist
do
if [ ! "`grep $i uniquewords`" ]
then
echo adding $i...
echo $i >>uniquewords
fi
done
---------------
Thanks in advance for any suggestions or comments.
-- L. James
--
______________________________________________________________________
Apollo III Communications (Buffalo's First ISP) Larry James
716_896_0738 Office 716_896_0766 Fax Consultant/Programmer
http://www.apollo3.com/~ljames ljames@apollo3.com Buffalo, New York
------------------------------
Date: Tue, 31 Aug 1999 13:40:27 GMT
From: jeremy_savage@my-deja.com
Subject: Using PGP encryption within your perl program?
Message-Id: <7qgm08$jro$1@nnrp1.deja.com>
I am currently working on a project where I have
to use data encyption within my perl script. I
know how to open a dos session window using the
open command with a pipe, but I can't seem to run
any command once I start the PGP (data encryption)
process. Anyway, if anyone has performed data
encrytion from within their perl script can you
please let me know what encryption tool you used
and how you did it?
Thanks!
Jeremy Savage
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 31 Aug 1999 13:55:39 GMT
From: Ian Smith <iansmith@pepper.ncinter.net>
Subject: Why doesn't my undef an array?
Message-Id: <v9Ry3.8376$914.581178@typ11.nn.bcandid.com>
I ran into a situation in Perl that I don't understand. Take the
following code...
#!/usr/local/bin/perl5 -w
use strict;
sub test {
my $yn = shift;
my @array;
@array = ( 'A','B','C','D' ) if $yn;
print "$yn : $array[2]\n" if defined @array;
}
test(0); test(1); test(0);
This results in...
1 : C
Use of uninitialized value at ./p line 10.
0 :
...which to me, does not make sense. Doesn't the "my @array;"
statement create a new instance of @array each time around?
Why does @array stay defined forever once it is set? The
same thing happens if I use a hash instead.
--
$p=3;do{print substr(' t"se
cueho"eaaJrkrtrn ,lP h',$p-1,1);$p=15*$p%29;}until $p==3;
------------------------------
Date: Tue, 31 Aug 1999 13:51:22 +0200
From: Joachim Nock <Joachim.Nock@sirona.de>
Subject: Re: Win32::ODBC
Message-Id: <37CBC1BA.6B287906@sirona.de>
"Vinh T. Bui" schrieb:
> use Win32::ODBC;
> $db = new Win32::ODBC("DSN=***; UID=***; PWD=***");
Should be:
$db = new Win32::ODBC("DSN=***; UID=***; PWD=***") or die "Error: $!";
> $db->Sql("SELECT * FROM ***");
Insert here:
die qq(\n\nSQL failed "$query": ), $ch->Error(), qq(\n) if $rc;
> while($db->FetchRow()){
> $Data = $db->DataHash();
As the name indicates, DataHash returns the entire row as an associative
array(!) if you don't specify any field names as an argument.
-- Joachim
------------------------------
Date: Tue, 31 Aug 1999 12:05:36 GMT
From: Eduardo Pimenta <epimenta@my-deja.com>
Subject: Re: write to a file in a loop
Message-Id: <7qggeb$fh5$1@nnrp1.deja.com>
In article <7qgbvn$qv5$1@lublin.zrz.tu-berlin.de>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> Lakmal Jinadasa <lakmal@ml.com> wrote in comp.lang.perl.misc:
> >Hi,
> >
> >I have the following problem.
> >
> >I open a file within a foreach loop
> >then try to write some data to the file.
> >
> >everything goes fine except the data is not in the file.
> >
> >Part of the program is as follows
> >
> >foreach $key1(@list1)
> > foreach $key2 (@list2) {
> > open DAT ">File_Name";
>
> You are not checking the result of open(). *Always* do that.
Not only that, but if you open a file inside a loop:
1) you should close the file inside the same loop;
2) you should open it for append, as in ">>File_Name" .
Eduardo Pimenta.
>
> > @arr = output_of _a function;
> > print DAT @arr;
> > }
> >close (DAT);
> >}
> >
> >Seperate file is created for each key1.key2
> >
> >The files are there with 0 byte length.
>
> It looks like @arr contains nothing, or undefined values. There's no
> way of telling.
>
> Just as a general rule, you should switch on warnings with -w and
> use strict in your programs, especially when they give you trouble.
>
> Anno
>
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 686
*************************************