[26151] in Perl-Users-Digest
Perl-Users Digest, Issue: 8342 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 20 18:05:26 2005
Date: Sat, 20 Aug 2005 15:05:04 -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 Sat, 20 Aug 2005 Volume: 10 Number: 8342
Today's topics:
Can DBI Insert call return record #? <nospam@nospam.com>
Re: Can DBI Insert call return record #? <no@email.com>
DBI and symbol table <perl@my-header.org>
Re: DBI and symbol table <perl@my-header.org>
escaping special characters in a form input jnam@sunnybrook.com
Re: escaping special characters in a form input xhoster@gmail.com
Re: escaping special characters in a form input <noreply@gunnar.cc>
Re: how to read file from sub-directories and do an ave <tadmc@augustmail.com>
Re: how to read file from sub-directories and do an ave <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 Aug 2005 11:40:59 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Can DBI Insert call return record #?
Message-Id: <1124552609.795729@nntp.acecape.com>
Hi All,
Am using Perl to access my MySQL database. I was curious, can somehow call
the INSERT command with Perl, and get some sort of handle returned that is
the record # of the newly created record?
Make a long story short:
Every time I insert a new user, in the record is a User Id that gets
automatically created with the auto_increment setting.
So I was hoping if I call an Insert for "Paul Johnson", somewhere in the
return handle I could see the value of his UserId, without having to
immedietly do a search on Paul Johnson.
Thanks ahead,
Daniel
------------------------------
Date: Sat, 20 Aug 2005 16:49:39 +0100
From: Brian Wakem <no@email.com>
Subject: Re: Can DBI Insert call return record #?
Message-Id: <3mp1ojF1843djU1@individual.net>
daniel kaplan wrote:
> Hi All,
>
> Am using Perl to access my MySQL database. I was curious, can somehow
> call the INSERT command with Perl, and get some sort of handle returned
> that is the record # of the newly created record?
>
> Make a long story short:
>
> Every time I insert a new user, in the record is a User Id that gets
> automatically created with the auto_increment setting.
>
> So I was hoping if I call an Insert for "Paul Johnson", somewhere in the
> return handle I could see the value of his UserId, without having to
> immedietly do a search on Paul Johnson.
>
> Thanks ahead,
>
> Daniel
SELECT LAST_INSERT_ID();
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: Sat, 20 Aug 2005 15:12:03 +0200
From: Matija Papec <perl@my-header.org>
Subject: DBI and symbol table
Message-Id: <pcaeg1pdlq0rbi5t6jg7mt6plebiemg2pp@4ax.com>
I would like to temper calls to DBI so that caller gets DBIfoo object if
real DBI method failed for some reason. The code below should imho do just
that but no luck so far. What is wrong with it?
=======
use Data::Dumper;
use DBI;
$dbh = DBI->connect;
package DBIfoo;
use Data::Dumper;
my $DBI_connect;
BEGIN {
# $DBI_connect = $DBI::{connect};
# $DBI::{connect} = \&connect;
$DBI_connect = *DBI::connect;
*DBI::connect = \&connect;
}
sub connect {
# $DBI_connect = sub { print "@_ ", __PACKAGE__ };
return &$DBI_connect || (bless {}, __PACKAGE__);
}
1;
--
Matija
------------------------------
Date: Sat, 20 Aug 2005 15:19:38 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: DBI and symbol table
Message-Id: <ecbeg193n1g3elgccud4ljoarf0lhndvr0@4ax.com>
>BEGIN {
># $DBI_connect = $DBI::{connect};
># $DBI::{connect} = \&connect;
> $DBI_connect = *DBI::connect;
^
$DBI_connect = &DBI::connect;
^
to answer my own question. :)
--
Matija
------------------------------
Date: Sat, 20 Aug 2005 11:09:43 -0400
From: jnam@sunnybrook.com
Subject: escaping special characters in a form input
Message-Id: <hkheg1l4b4it9h8gohjli8v2dvvdugrvl0@4ax.com>
I have run into a bit of problem with special characters like " ' and > < that are often used used for inches and feet.
I have a form textarea that may contain text such as " four (4) 2x4 @ 2'-0" O.C. "
When a user enters this imformation it is re-displayed in text areas for editing but when they try to submit it any
special characters cause an error.
Any ideas?
Thanks in advance
------------------------------
Date: 20 Aug 2005 19:35:30 GMT
From: xhoster@gmail.com
Subject: Re: escaping special characters in a form input
Message-Id: <20050820153530.424$Kr@newsreader.com>
jnam@sunnybrook.com wrote:
> I have run into a bit of problem with special characters like " ' and > <
> that are often used used for inches and feet.
>
> I have a form textarea that may contain text such as " four (4) 2x4 @
> 2'-0" O.C. "
>
> When a user enters this imformation it is re-displayed in text areas for
> editing but when they try to submit it any special characters cause an
> error.
>
> Any ideas?
Yes. Fix the code.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Sat, 20 Aug 2005 21:52:14 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: escaping special characters in a form input
Message-Id: <3mpfvfF10f370U1@individual.net>
jnam@sunnybrook.com wrote:
> I have run into a bit of problem with special characters like " ' and
> > < that are often used used for inches and feet.
>
> I have a form textarea that may contain text such as " four (4) 2x4 @
> 2'-0" O.C. "
>
> When a user enters this imformation it is re-displayed in text areas
> for editing but when they try to submit it any special characters
> cause an error.
>
> Any ideas?
Check out this thread:
http://groups-beta.google.com/group/comp.lang.perl.misc/browse_frm/thread/b781dc7985054e59
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 20 Aug 2005 08:15:33 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: how to read file from sub-directories and do an average?
Message-Id: <slrndgeb7l.39j.tadmc@magna.augustmail.com>
Ross <a@cuhk.edu.hk> wrote:
> $curdir = `pwd`;
> chop $curdir;
You should not use chop() to remove newlines.
You should use chomp() to remove newlines.
> @inputdirname = readdir(WORKINGDIR);
> foreach $inputdirname (sort @inputdirname) {
There is no need for a temporary array:
foreach $inputdirname (sort readdir WORKINGDIR) {
Or, since you should have "use strict" turned on by now:
foreach my $inputdirname (sort readdir WORKINGDIR) {
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 20 Aug 2005 08:20:41 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: how to read file from sub-directories and do an average?
Message-Id: <slrndgebh9.39j.tadmc@magna.augustmail.com>
Ross <a@cuhk.edu.hk> wrote:
> $curdir = $curdir . "/$ARGV[0]";
> opendir(SUBDIR, $curdir.$inputdirname) || die ("unable to open dir
^^^ no slash character?
> named $inputdirname $!");
Don't you need a directory separator character between $curdir
and $inputdirname?
Your diagnostic message is misleading, you should have the same name
there as used in the opendir():
opendir(SUBDIR, "$curdir/$inputdirname") or
die "unable to open dir named '$curdir/$inputdirname' $!";
> chdir ($curdir);
You should check the return value to ensure that you actually
got what you asked for:
chdir $curdir or die "could not change to '$curdir' $!";
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 8342
***************************************