[12724] in Perl-Users-Digest
Perl-Users Digest, Issue: 134 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 13 20:17:21 1999
Date: Tue, 13 Jul 1999 17:12:51 -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, 13 Jul 1999 Volume: 9 Number: 134
Today's topics:
translating carrage returns in CGI Forms <cjscarff@knology.net>
Re: translating carrage returns in CGI Forms (Tad McClellan)
Re: translating carrage returns in CGI Forms (David Cantrell)
Re: translating carrage returns in CGI Forms (Bart Lateur)
Re: translating carrage returns in CGI Forms (Larry Rosler)
Re: undef of $ENV{VAR} used by a called script (Andrew Allen)
Uninitialized Value in Hash?? <tlynch@cisco.com>
Re: unzip (Tony Kennick)
Re: Using perlcc to compile a perl prog richardwchin@my-deja.com
Re: Using perlcc to compile a perl prog <gellyfish@gellyfish.com>
Variable interpolation and "my" mikec201@my-deja.com
Re: Variable interpolation and "my" (Chris Nandor)
Re: Variable interpolation and "my" (Tad McClellan)
VBScript to PerlScript <lambax@polbox.com>
Re: VBScript to PerlScript <matt@sergeant.org>
Re: VBScript to PerlScript <lambax@polbox.com>
Ways of making this subroutine faster <gavin@optus.net.au>
weird mysql occurance lxtruong@uiuc.edu
Re: weird mysql occurance (brian d foy)
Re: weird mysql occurance lxtruong@uiuc.edu
Re: weird mysql occurance dzuy@my-deja.com
Re: weird mysql occurance (brian d foy)
Re: weird mysql occurance lxtruong@uiuc.edu
What does ctrl-d do? <prlawrence@lehigh.edu>
Re: What does ctrl-d do? <coh@email.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 12 Jul 1999 21:05:07 -0400
From: Chris Scarff <cjscarff@knology.net>
Subject: translating carrage returns in CGI Forms
Message-Id: <378A90C2.2AF58BDE@knology.net>
I'm trying to translate carrage returns from a CGI Form into spaces
without much luck. I'm ok if I don't use the "pack" command below. But
then I don't get other COMMON characters put into my flat-bed database
file (plain text file) like periods and commas. I've tried to use the
translate command and the substitution command to change it, but no luck
there either.
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",
hex($1))/eg;
$FORM{$name} = $value;
Carrage returns keep blowing up my text database. Crude I know, but
it's where I am in knowledge right now.
Does anyone have any ideas for me.
Thanks,
Chris
------------------------------
Date: Mon, 12 Jul 1999 19:48:39 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: translating carrage returns in CGI Forms
Message-Id: <nsudm7.2of.ln@magna.metronet.com>
Chris Scarff (cjscarff@knology.net) wrote:
: I'm trying to translate carrage returns from a CGI Form into spaces
: without much luck.
: Does anyone have any ideas for me.
use CGI;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 13 Jul 1999 12:22:07 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: translating carrage returns in CGI Forms
Message-Id: <378b2eab.328106251@news.insnet.net>
On Mon, 12 Jul 1999 21:05:07 -0400, Chris Scarff
<cjscarff@knology.net> said:
>I'm trying to translate carrage returns from a CGI Form into spaces
>without much luck.
Before solving your problem for you :-) I'll tell you that you should
either use the CGI module or the cgi-lib.pl library instead of doing
all the hard work of parsing the form results yourself.
To \ns into spaces do ...
$myVariable=~s/\n/ /g;
assuming that the user's text is in $myVariable, of course.
[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, 13 Jul 1999 13:30:20 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: translating carrage returns in CGI Forms
Message-Id: <37913f52.24688457@news.skynet.be>
Tad McClellan wrote:
>: I'm trying to translate carrage returns from a CGI Form into spaces
>: without much luck.
>
>: Does anyone have any ideas for me.
>
> use CGI;
I don't get it. CGI.pm converts CR's to spaces?
Bart.
------------------------------
Date: Tue, 13 Jul 1999 07:25:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: translating carrage returns in CGI Forms
Message-Id: <MPG.11f4ec158c8662ec989cb3@nntp.hpl.hp.com>
In article <378b2eab.328106251@news.insnet.net> on Tue, 13 Jul 1999
12:22:07 GMT, David Cantrell <NukeEmUp@ThePentagon.com> says...
...
> To \ns into spaces do ...
>
> $myVariable=~s/\n/ /g;
>
> assuming that the user's text is in $myVariable, of course.
If doing it about an order of magnitude faster matters, then use:
$myVariable =~ tr/\n/ /;
The 'tr' operator and the 'translating characters' in the Subject seem
to have some sort of correlation. :-)
Someday people will simply stop posting 's/X/Y/g'. We should all live
so long.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 12 Jul 1999 23:29:52 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: undef of $ENV{VAR} used by a called script
Message-Id: <7mdtpg$sb3$1@fcnews.fc.hp.com>
John Coers (coers@evsx.com) wrote:
: I have a wrapper script that undef's an environment variable via the
: $ENV{VAR} hash that is previously set in my .cshrc. The wrapper then
: calls another script that prints $ENV{VAR} and tests to see if it is
: defined via the Perl 'defined' function.
: While the called script prints no visable characters, the $ENV{VAR}
: passes the 'defined' test. A 'defined' test in the wrapper fails
: correctly and if I change the test in the called script to a simple
: true/false eval, $ENV{VAR} does indeed evaluate to false -- so in the
: called script it is a null but somehow defined string.
^^^^^^^^^^^^^^^
The null string "" is defined. There's no magic to it.
The environment consists of strings in "name=value" pairs. It has no
concept of the perl value "undef". Perl will conveniently maintain
undef-ness for %ENV values within your script, but there is no way to
pass an "undefined" value for an environment variable to another
process, except by removing that variable's definition completely.
: Can anyone tell me what is happening here? I couldnt
: find any specifics in the Camel or perlfaq or other manpages -- is it in
: there somewhere?
It's not really a perl thing. The UNIX manpages environ(5) and exec(2)
probably have what you need to know.
: I have since changed the wrapper to use 'delete' -- this is probably the
: better way to do business in this case.
Correct. That removes the variable from the environment, which is what
it sounded like you were trying to do in the first place.
Andrew
------------------------------
Date: Tue, 13 Jul 1999 14:04:51 -0400
From: Tom Lynch <tlynch@cisco.com>
Subject: Uninitialized Value in Hash??
Message-Id: <378B7FC3.F5858010@cisco.com>
Greetings:
I have the following code:
while (<FILE>) {
chop;
@line = $_;
@line = split;
if (/^\s+\d+/) {
$pinname = $line[1];
}
if (/---->/) {
$pin = basename $line[1];
if ($line[2] eq "R") {
print "$line[1]\n";
if (exists $grp0rise{$line[1]}) {
push (@rise_grp0, "$pinname $pin $line[4] $grp0rise{$line[0]}");
}
if (exists $grp1rise{$line[1]}) {
push (@rise_grp1, "$pinname $pin $line[4] $grp1rise{$line[0]}");
}
if (exists $grp2rise{$line[1]}) {
push (@rise_grp2, "$pinname $pin $line[4] $grp2rise{$line[0]}");
}
}
if ($line[2] eq "F") {
print "$line[1]\n";
if (exists $grp0fall{$line[1]}) {
push (@fall_grp0, "$pinname $pin $line[4] $grp0fall{$line[0]}");
}
if (exists $grp1fall{$line[1]}) {
push (@fall_grp1, "$pinname $pin $line[4] $grp1fall{$line[0]}");
}
if (exists $grp2fall{$line[1]}) {
push (@fall_grp2, "$pinname $pin $line[4] $grp2fall{$line[0]}");
}
}
}
}
close(FILE);
and I keep getting:
Use of uninitialized value at rtime line 163, <FILE> chunk 9086 (#1)
which always points to one of the exists lines.
I have check and double checked $line[1] and it's
a valid value. Is it the Hash itself? I created the
has in another while loop. Could it be this while loop
does see the hash?
Thanks for any help in advance
Tom
--
#-----------------------+--------------------------+
# Tom Lynch | Email: tlynch@cisco.com |
# Cisco Systems | Phone: 978-244-8765 |
# 250 Apollo Drive | FAX: 978-244-8039 |
# Chelmsford MA 01824 | MS: CH1-2LF |
#-----------------------+--------------------------+
------------------------------
Date: Tue, 13 Jul 1999 17:45:48 GMT
From: tony@showroom.org.uk (Tony Kennick)
Subject: Re: unzip
Message-Id: <378b7aa3.8677805@missy.shef.ac.uk>
Tanya <tanya@i-cable.com> imparted the following:
:->no
:->since using a broswer to upload file to server can be only by the method
:->"one by one"
:->so i would like to upload a zipped file with many files inside, then
:->unzip it after upload it
:->to the server, so that i can put many files to the server but just upload
:->only one zip file
:->
:->that is my situation, so can you help me because i can only run this
:->script under shell....
:->THX
No I don't believe that this post is THX certified after all if the
won't accept the smell of popcorn leaking in they won't accept those
broken lines. And the lowercase i is also likely to annoy the TAP
mystery customers.
--
From Tony Kennick aka Gonzo The Great
http://missy.shef.ac.uk/users/old-firm/
Gonzo: Slang for "the last man standing
at a drinking marathon"
------------------------------
Date: Tue, 13 Jul 1999 09:19:31 GMT
From: richardwchin@my-deja.com
Subject: Re: Using perlcc to compile a perl prog
Message-Id: <7mf0at$e33$1@nnrp1.deja.com>
In article <7m5vd8$1v5$1@gellyfish.btinternet.com>,
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> On Fri, 09 Jul 1999 13:57:10 GMT richardwchin@my-deja.com wrote:
> > In article <3785e39b@cs.colorado.edu>,
> > tchrist@mox.perl.com (Tom Christiansen) wrote:
> >> [courtesy cc of this posting mailed to cited author]
> >>
> >> In comp.lang.perl.misc,
> >> richardwchin@my-deja.com writes:
> >> :I want to create a single executable rather
> >> :than a script that some users might be tempted to edit.
> >>
> >> "tempted"? And what's your problem with that?
> >>
> > His main concern is security and if the compiler makes it less
secure
> > the whole exercise is pointless.
> >
>
> If the security of your system has been violated already then its
already
> too late. Use proper security on your system.
>
> /J\
I meant the security of the script not of the system. I'm sorry if this
wasn't clear.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 13 Jul 1999 12:53:32 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Using perlcc to compile a perl prog
Message-Id: <378b28bc@newsread3.dircon.co.uk>
richardwchin@my-deja.com wrote:
> In article <7m5vd8$1v5$1@gellyfish.btinternet.com>,
> Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>> On Fri, 09 Jul 1999 13:57:10 GMT richardwchin@my-deja.com wrote:
>> > In article <3785e39b@cs.colorado.edu>,
>> > tchrist@mox.perl.com (Tom Christiansen) wrote:
>> >> [courtesy cc of this posting mailed to cited author]
>> >>
>> >> In comp.lang.perl.misc,
>> >> richardwchin@my-deja.com writes:
>> >> :I want to create a single executable rather
>> >> :than a script that some users might be tempted to edit.
>> >>
>> >> "tempted"? And what's your problem with that?
>> >>
>> > His main concern is security and if the compiler makes it less
> secure
>> > the whole exercise is pointless.
>> >
>>
>> If the security of your system has been violated already then its
> already
>> too late. Use proper security on your system.
>>
>> /J\
>
> I meant the security of the script not of the system. I'm sorry if this
> wasn't clear.
>
So did I - if the security on your system has been compromised in such a way
as to allow an unauthorised person to alter the behaviour of *any* program
then it is too late. If the system you are on does not allow you to
control peoples permissions to do things to files then there is little
point worrying about security anyhow.
/J\
--
"Tony Blair is reported to be detained indefinitely under plans unveiled
by the Home Secretary" - Corrupt Teletext Page
------------------------------
Date: Tue, 13 Jul 1999 16:43:02 GMT
From: mikec201@my-deja.com
Subject: Variable interpolation and "my"
Message-Id: <7mfqai$noh$1@nnrp1.deja.com>
The following code:
#!/usr/local/bin/perl -w
my @A_List = ('a', 'b');
$name = 'A_List';
print "Not defined $name\n" if
(!defined(@{$name}));
print "$name = @{$name} \n";
print "$name = @A_List\n";
generates this:
Not defined A_List
A_List =
A_List = a b
The references I looked up seem to indicate that
my is purely lexically scoped; the reference that
is giving the "Not defined" is within scope,
lexically speaking. If you remove the "my", this
works--that is, it is defined. So it appears that
a "my" scope cannot use this indirect variable
technique. I can't find anything to confirm this
in the references I've tried, though. Can anyone
tell me if I'm right, or if I've screwed something
up?
Mike Christie
mikec@jump.net
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 13 Jul 1999 17:50:45 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Variable interpolation and "my"
Message-Id: <pudge-1307991350490001@192.168.0.17>
In article <7mfqai$noh$1@nnrp1.deja.com>, mikec201@my-deja.com wrote:
# The following code:
#
# #!/usr/local/bin/perl -w
# my @A_List = ('a', 'b');
# $name = 'A_List';
# print "Not defined $name\n" if
# (!defined(@{$name}));
# print "$name = @{$name} \n";
# print "$name = @A_List\n";
#
# generates this:
#
# Not defined A_List
# A_List =
# A_List = a b
Yep.
# The references I looked up seem to indicate that
# my is purely lexically scoped;
Variables declared with my() are lexically scoped.
# the reference that
# is giving the "Not defined" is within scope,
# lexically speaking. If you remove the "my", this
# works--that is, it is defined. So it appears that
# a "my" scope cannot use this indirect variable
# technique.
This is why it is suggested you put this at the top of your programs:
use strict;
This is something that you Shouldn't Do. The bottom line is that you
cannot symbolically reference a lexical variable like that, you can only
do it with global variables. Again: Don't Do That. Don't use symbolic
variable references at all unless you need to specifically muck with the
symbol table. use strict and adjust your thinking to fit into it, you'll
be happier.
#!/usr/local/bin/perl -w
use strict;
my(@A_List, $name, %hash);
@A_List = ('a', 'b');
$name = 'A_List';
%hash = ($name => \@A_List);
print "Not defined $name\n" unless exists $hash{$name};
print "$name = @{$hash{$name}}\n";
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Tue, 13 Jul 1999 12:47:50 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Variable interpolation and "my"
Message-Id: <mjqfm7.ikh.ln@magna.metronet.com>
mikec201@my-deja.com wrote:
: The following code:
: #!/usr/local/bin/perl -w
: my @A_List = ('a', 'b');
: $name = 'A_List';
: print "Not defined $name\n" if
: (!defined(@{$name}));
^^^^^^^^
Since $name is a _string_ and not a reference, you are making
use of "Symbolic references" there.
Making use of Symbolic references is a Very Bad Idea in
nearly all cases.
In modern Perl, it is better to use an explicit hash.
In Perl 4, you had to play around with a Special Hash
(the symbol table), but we have been liberated from
such machinations for several years now.
See:
http://www.plover.com/~mjd/perl/varvarname.html
: generates this:
: Not defined A_List
: A_List =
: A_List = a b
: The references I looked up seem to indicate that
: my is purely lexically scoped;
That's right.
lexically scoped variables to not get Symbol Table entries.
: the reference that
: is giving the "Not defined" is within scope,
: lexically speaking.
You cannot play Symbol Table tricks (symbolic references)
on variables that do not appear in the Symbol Table :-)
: If you remove the "my", this
: works--that is, it is defined.
Because then it _would_ be entered into the Symbol Table.
: So it appears that
: a "my" scope cannot use this indirect variable
: technique.
Right.
Thank God^H^H^HLarry.
: I can't find anything to confirm this
: in the references I've tried, though. Can anyone
: tell me if I'm right, or if I've screwed something
: up?
The "Symbolic references" section in perlref.pod says:
----------------
Only package variables (globals, even if localized) are visible to
symbolic references. Lexical variables (declared with my()) aren't in
a symbol table, and thus are invisible to this mechanism.
----------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 13 Jul 1999 12:36:20 +0200
From: "Tomas R." <lambax@polbox.com>
Subject: VBScript to PerlScript
Message-Id: <7mfcpv$mmh$2@news.ikp.pl>
HI
How to translate this VBScript to PerlScript??
(my communication with MS Index Server not working :((
Please help :)
VBScript
---------------------- cut here --------------------------
<HTML>
<HEAD>
<TITLE>Communication with MS Index Server - VBScript</TITLE>
</HEAD>
<BODY>
<% Set rs = Server.CreateObject("ADODB.Recordset")
sCommand = "SELECT DocTitle, Path, DocAppName, HitCount FROM SCOPE('
""/directory"" ') WHERE CONTAINS(' ""words"" ')>0 ORDER BY
HitCount DESC"
rs.Open sCommand, "Provider=MSIDXS"
While Not rs.EOF
%>
<BR>
<B><% = rs("DocTitle") & " " %></B>
(<% = rs("HitCount") %>)
<I><% = rs("DocAppName") & " " %></I>
<% = rs("Path") & " " %>
<BR>
<% rs.MoveNext
Wend
%>
</BODY>
</HTML>
-------------------------- cut here ----------------------------
Not working PerlScript
---------------------- cut here --------------------------
<% @LANGUAGE=PerlScript %>
<HTML>
<HEAD>
<TITLE>Communication with MS Index Server - PerlScript</TITLE>
</HEAD>
<BODY>
<%
my $Record=$Server->CreateObject("ADODB.RecordSet");
$sql = "SELECT DocTitle, Path, DocAppName, HitCount FROM SCOPE('
\"\"/directory\"\" ') WHERE CONTAINS(' \"\"worlds\"\" ')>0
ORDER BY HitCount DESC";
$Record->Open($sql, "Provider=MSIDXS");
while(!$Record->eof) {
$Response->Write($Record->Fields("DocTitle")->{'Value'});
$Response->Write($Record->Fields("Path")->{'Value'});
$Record->movenext;
}
$Record->Close;
%>
</BODY>
</HTML>
-------------------- cut here -----------------------
------------------------------
Date: Tue, 13 Jul 1999 13:07:11 +0100
From: Matt Sergeant <matt@sergeant.org>
Subject: Re: VBScript to PerlScript
Message-Id: <378B2BEF.CFAA788@sergeant.org>
"Tomas R." wrote:
>
> Not working PerlScript
> ---------------------- cut here --------------------------
> <% @LANGUAGE=PerlScript %>
> <HTML>
> <HEAD>
> <TITLE>Communication with MS Index Server - PerlScript</TITLE>
> </HEAD>
> <BODY>
> <%
# Add this...
use Win32::OLE;
Win32::OLE->Warn(3);
> my $Record=$Server->CreateObject("ADODB.RecordSet");
> $sql = "SELECT DocTitle, Path, DocAppName, HitCount FROM SCOPE('
> \"\"/directory\"\" ') WHERE CONTAINS(' \"\"worlds\"\" ')>0
> ORDER BY HitCount DESC";
> $Record->Open($sql, "Provider=MSIDXS");
>
> while(!$Record->eof) {
>
> $Response->Write($Record->Fields("DocTitle")->{'Value'});
> $Response->Write($Record->Fields("Path")->{'Value'});
> $Record->movenext;
>
> }
> $Record->Close;
> %>
> </BODY>
> </HTML>
Now tell us the error message.
Matt.
------------------------------
Date: Tue, 13 Jul 1999 19:06:20 +0200
From: "Tomas R." <lambax@polbox.com>
Subject: Re: VBScript to PerlScript
Message-Id: <7mg3nd$b0n$1@news.ikp.pl>
HI
>use Win32::OLE;
>Win32::OLE->Warn(3);
>Now tell us the error message.
use Win32::OLE; Win32::OLE->Warn(3); error '80004005'
Cannot autoload class method "Warn"
:)
This is verry important. Please - Help :(((
Tom
------------------------------
Date: Tue, 13 Jul 1999 22:29:14 GMT
From: Gavin Cato <gavin@optus.net.au>
Subject: Ways of making this subroutine faster
Message-Id: <378BBE61.62879C21@optus.net.au>
Hi,
This is a subroutine of part of a program I've written that needs to be
referred to generally 2-3 times during the actual running of the program
.
This subroutines basically collects entries from textfiles, sorts them
and adds and "uniq's" then into a master global list ($global).
When used with lists of 3500+ entries, it can cause quite a noticeable
pause to the user. I can see that I'm repeating my code several times in
the subroutine but every time I try to shorten it I break it ; and find
myself going back to my old routine which works - albeit inefficiently.
Do any perl guru's have any suggestiobs to trim this code & make it
faster? It's not a "rocket science" subroutine it performs quite simple
functions.
thanks
Gavin;
---------------------------------------------
sub write_config {
%ucnt = ();
$customerdir = "/optus/customers";
opendir(CUSTDIR, $customerdir) or die "can't open customer directory :
$!";
while (defined($config_file = readdir(CUSTDIR))) {
next unless ($config_file =~ /\.cfg/);
next if ($config_file eq "");
next if ($config_file eq ".");
next if ($config_file eq "..");
# Now that we have a (theoretically) valid
config to work on
# open the file & grab information out of it
open(CUSTCFG, "<$customerdir/$config_file") or
die "Error opening $customerdir/$config_file : $! \n";
while (<CUSTCFG>) {
if (/AL-Location:/) {
my $al = (split/:\s+/)
[1];
push(@FILES,
$al); # collect a list of files we need to open
}
}
}
open(GLOBAL, ">>$global") or die "$global : $! \n";
foreach $accesslist (@FILES) {
open(ACCESSLIST, "<$accesslist") or die "$accesslist : $! \n";
while (<ACCESSLIST>) {
s/#.*//;
s/!.*//;
next if /^$/;
chomp;
print GLOBAL "$_\n";
}
}
close ACCESSLIST;
open(DIFFLIST, "<$new_list") or die "$new_list : $! \n";
while (<DIFFLIST>) {
s/#.*//;
s/!.*//;
next if /^$/;
chomp;
print GLOBAL "$_\n";
}
close DIFFLIST;
close GLOBAL;
open(GLOBAL, "<$global") or die " $! \n";
while (<GLOBAL>) {
chomp;
s/#.*//;
s/!.*//;
next if /^$/;
$ucnt{$_}++;
}
close GLOBAL;
@routes = sort keys %ucnt;
open(GLOBAL, ">$global") or die " $! \n";
foreach (@routes) {
($sortbase, $sortcidr) = (split/\//) [0,1];
next if ($sortcidr =~
/^25$|^26$|^27$|^28$|^29$|^30$|^31$|^32$/);
print GLOBAL "$_\n"; }
close GLOBAL;
} # end sub write_config
------------------------------
Date: 13 Jul 1999 15:51:28 GMT
From: lxtruong@uiuc.edu
Subject: weird mysql occurance
Message-Id: <7mfna0$sf$1@vixen.cso.uiuc.edu>
Hi guys. I'm using MySQL with DBI/DBD and I'm getting this strange error. I
looked around the MySQL homepage, and I couldn't find the answer. What I'm
trying to do is input some arbitrary text into a text box. Easy enough,
right? Well, the problem occurs when there is a question mark in the text.
When the data is entered into the database, it is entered in as a "NULL".
Am I required to escape the "?" ? I tried doing that, and it didn't really
work. Any ideas guys?
Long
--
---------------------------------------------------
Long Truong lxtruong@uiuc.edu
I speak only for myself
------------------------------
Date: Tue, 13 Jul 1999 11:03:05 -0500
From: brian@pm.org (brian d foy)
Subject: Re: weird mysql occurance
Message-Id: <brian-1307991103070001@62.bloominton-01rs13-14rt.il.dial-access.att.net>
In article <7mfna0$sf$1@vixen.cso.uiuc.edu>, lxtruong@uiuc.edu wrote:
>Hi guys. I'm using MySQL with DBI/DBD and I'm getting this strange error. I
>looked around the MySQL homepage, and I couldn't find the answer. What I'm
>trying to do is input some arbitrary text into a text box. Easy enough,
>right? Well, the problem occurs when there is a question mark in the text.
>When the data is entered into the database, it is entered in as a "NULL".
>Am I required to escape the "?" ? I tried doing that, and it didn't really
>work. Any ideas guys?
it would help to see code. it sounds like you might be incorrectly using
placeholders.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: 13 Jul 1999 16:23:37 GMT
From: lxtruong@uiuc.edu
Subject: Re: weird mysql occurance
Message-Id: <7mfp69$2co$1@vixen.cso.uiuc.edu>
here is the code. it's really simple, though...
[
$statement = "insert into documentation values ($entryid,
$categoryid,$id, $timestamp, $siteid,
$sltid, \"$description\", 0)";
$sth= $db->prepare($statement);
$rv= $sth->execute();
if ($sth->errstr() ne ""){
print $sth->errstr();
$rc= $sth->finish();
return -1;
}
$rc= $sth->finish();
]
the variable $description is the text in question. it's the input
from a textarea field in a cgi.
Hope that helps.
brian d foy <brian@pm.org> wrote:
: In article <7mfna0$sf$1@vixen.cso.uiuc.edu>, lxtruong@uiuc.edu wrote:
:>Hi guys. I'm using MySQL with DBI/DBD and I'm getting this strange error. I
:>looked around the MySQL homepage, and I couldn't find the answer. What I'm
:>trying to do is input some arbitrary text into a text box. Easy enough,
:>right? Well, the problem occurs when there is a question mark in the text.
:>When the data is entered into the database, it is entered in as a "NULL".
:>Am I required to escape the "?" ? I tried doing that, and it didn't really
:>work. Any ideas guys?
: it would help to see code. it sounds like you might be incorrectly using
: placeholders.
: --
: brian d foy
: CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
: Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
--
---------------------------------------------------
Long Truong lxtruong@uiuc.edu
I speak only for myself
------------------------------
Date: Tue, 13 Jul 1999 16:53:41 GMT
From: dzuy@my-deja.com
Subject: Re: weird mysql occurance
Message-Id: <7mfque$o1i$1@nnrp1.deja.com>
In article <7mfna0$sf$1@vixen.cso.uiuc.edu>,
lxtruong@uiuc.edu wrote:
>
> Hi guys. I'm using MySQL with DBI/DBD and I'm getting this strange
error. I
> looked around the MySQL homepage, and I couldn't find the answer.
What I'm
> trying to do is input some arbitrary text into a text box. Easy
enough,
> right? Well, the problem occurs when there is a question mark in the
text.
> When the data is entered into the database, it is entered in as a
"NULL".
> Am I required to escape the "?" ? I tried doing that, and it didn't
really
> work. Any ideas guys?
>
> Long
>
Try quoting the entire data string.
> --
> ---------------------------------------------------
> Long Truong lxtruong@uiuc.edu
> I speak only for myself
>
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 13 Jul 1999 13:27:06 -0500
From: brian@pm.org (brian d foy)
Subject: Re: weird mysql occurance
Message-Id: <brian-1307991327070001@82.bloominton-01rs13-14rt.il.dial-access.att.net>
In article <7mfp69$2co$1@vixen.cso.uiuc.edu>, lxtruong@uiuc.edu wrote:
> $statement = "insert into documentation values ($entryid,
> $categoryid,$id, $timestamp, $siteid,
> $sltid, \"$description\", 0)";
>
> $sth= $db->prepare($statement);
> the variable $description is the text in question. it's the input
>from a textarea field in a cgi.
you need to quote text fields. what if $description has a "
character in it? use the $db->quote() method for this:
$desc = $db->quote($description);
$statement = qq| INSERT INTO docs (description) VALUES ($desc) |;
all of the quoting and escaping of special characters is handled by
the DBD, so any database specific features will be accounted for.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: 13 Jul 1999 21:03:22 GMT
From: lxtruong@uiuc.edu
Subject: Re: weird mysql occurance
Message-Id: <7mg9iq$gi2$1@vixen.cso.uiuc.edu>
Thanks for all the help guys!
Long
--
---------------------------------------------------
Long Truong lxtruong@uiuc.edu
I speak only for myself
------------------------------
Date: Tue, 13 Jul 1999 15:06:28 -0400
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: What does ctrl-d do?
Message-Id: <7mg2nn$1sag@fidoii.cc.Lehigh.EDU>
I am familiar with ctrl-c, but not any other ctrl chars. I have a script under
UNIX which requests info:
209 # Get one filename interactively if none were passed in.
210 until (@filenames) {
211 print "Please enter file to print: ";
212 my $f; chomp ($f = <STDIN>);
213 if (-e $f) {
214 push @filenames, $f;
215 } else {
216 print "File $f does not exist. Try again.\n";
217 }
218 }
If I hit ctrl-d at the prompt, it complains:
--------------------------------------------------------------
Use of uninitialized value at ... line 212, <STDIN> chunk 1.
Use of uninitialized value at ... line 213, <STDIN> chunk 1.
Use of uninitialized value at ... line 213, <STDIN> chunk 1.
Use of uninitialized value at ... line 213, <STDIN> chunk 1.
Use of uninitialized value at ... line 213, <STDIN> chunk 1.
File does not exist. Try again.
Please enter file to print:
--------------------------------------------------------------
Why is ctrl-d considered unitialized? How can I catch it?
--
Phil R Lawrence
Lehigh University
Enterprise Systems Implementation
Programmer / Analyst
prlawrence@lehigh.edu - work
prlawrence@planetall.com - personal
--
until (!$self->{'plaid pants'}) { bless $self, $class }
------------------------------
Date: Tue, 13 Jul 1999 16:14:09 -0400
From: Chad O Hulbert <coh@email.com>
Subject: Re: What does ctrl-d do?
Message-Id: <378B9E11.D482D727@email.com>
Phil R Lawrence wrote:
>
> I am familiar with ctrl-c, but not any other ctrl chars. I have a script under
> UNIX which requests info:
>
> 209 # Get one filename interactively if none were passed in.
> 210 until (@filenames) {
> 211 print "Please enter file to print: ";
> 212 my $f; chomp ($f = <STDIN>);
> 213 if (-e $f) {
> 214 push @filenames, $f;
> 215 } else {
> 216 print "File $f does not exist. Try again.\n";
> 217 }
> 218 }
>
> If I hit ctrl-d at the prompt, it complains:
> --------------------------------------------------------------
> Use of uninitialized value at ... line 212, <STDIN> chunk 1.
> Use of uninitialized value at ... line 213, <STDIN> chunk 1.
> Use of uninitialized value at ... line 213, <STDIN> chunk 1.
> Use of uninitialized value at ... line 213, <STDIN> chunk 1.
> Use of uninitialized value at ... line 213, <STDIN> chunk 1.
> File does not exist. Try again.
> Please enter file to print:
> --------------------------------------------------------------
>
> Why is ctrl-d considered unitialized? How can I catch it?
^d is not considered uninitialized, your $f is. ^d is a control
character that means "End Of File/Input" in most Unix lands, so if you
haven't typed anything, $f isn't assigned anything. When you try to use
the value of $f, which you haven't set, perl complains.
--
Chad O Hulbert - coh@email.com
"Speed is subsittute fo accurancy."
------------------------------
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.
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 134
*************************************