[15981] in Perl-Users-Digest
Perl-Users Digest, Issue: 3393 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 16 14:15:52 2000
Date: Fri, 16 Jun 2000 11:15:31 -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: <961179331-v9-i3393@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 16 Jun 2000 Volume: 9 Number: 3393
Today's topics:
Single quotes in SQL queries <ozzydaz@WriteMe.com>
Re: Single quotes in SQL queries newsposter@cthulhu.demon.nl
Re: Single quotes in SQL queries <gedichte@lycosmail.com>
Re: Single quotes in SQL queries <abe@ztreet.demon.nl>
Re: Single quotes in SQL queries (Abigail)
Re: Sorting a ':' delimeted file by a field value/surna (Abigail)
string::approx for windows nnyglb@my-deja.com
subdomain name forwarding scripts ?? <omygod@my-deja.com>
Re: subdomain name forwarding scripts ?? <gedichte@lycosmail.com>
Re: Syntax checker (Malcolm Dew-Jones)
system() in WinNT4-service <W.Hielscher@mssys.com>
Text substitution problem <viciousdogs@zdnetmail.com>
Re: Text substitution problem <gedichte@lycosmail.com>
Re: Text substitution problem <uri@sysarch.com>
Re: Text substitution problem <viciousdogs@zdnetmail.com>
Re: Text substitution problem <abe@ztreet.demon.nl>
Re: Text substitution problem <sariq@texas.net>
Re: Text substitution problem <viciousdogs@zdnetmail.com>
Re: Text substitution problem <thomas@newtonlabs.org>
Re: Text substitution problem <abe@ztreet.demon.nl>
Re: Text substitution problem (Michel Dalle)
Re: Text substitution problem (Abigail)
Translating from a code reference back to a function na <andrew.mclaren@swx.ch>
Re: Unix database for Perl (Abigail)
very simple cgi problem <mhughes@hgmp.mrc.ac.uk>
Re: very simple cgi problem <care227@attglobal.net>
Re: Very strange DBI:mysql-problem! <iltzu@sci.invalid>
Re: Very strange DBI:mysql-problem! <iltzu@sci.invalid>
Re: Where are the error logs? <iltzu@sci.invalid>
Re: Where are the error logs? <flavell@mail.cern.ch>
Re: why does this code print two spaces? <rowlands_mark@hotmail.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 17 Jun 2000 02:30:30 +1000
From: Darren Cooper <ozzydaz@WriteMe.com>
Subject: Single quotes in SQL queries
Message-Id: <sdkkkscpuiqvso41grlca779soeqmobdqp@4ax.com>
My perl CGI scripts fall over when I put in code to do an SQL query
involving variables or fields containing the single quote (') character.
eg. $get_data = $dbh->prepare("SELECT * FROM country WHERE country =
'$country'");
when the value of $country is "Cote d'Ivore"
or $update_data = $dbh->prepare("UPDATE user SET lastname = '$lastname'
WHERE userid = '$userid'")
when the value of $lastname is "O'Reilly"
I understand how the problem is caused. But I don't know how to fix it.
Could anyone help?
Ta
------------------------------
Date: 16 Jun 2000 16:45:20 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: Single quotes in SQL queries
Message-Id: <8idlj0$j9g$1@internal-news.uu.net>
Darren Cooper <ozzydaz@writeme.com> wrote:
> My perl CGI scripts fall over when I put in code to do an SQL query
> involving variables or fields containing the single quote (') character.
> I understand how the problem is caused. But I don't know how to fix it.
> Could anyone help?
Escape the quotes (and other special characters) properly. If you
use DBI, you can use its quote function, or you can use placeholders.
Check DBI documentation for more information.
If you need/want to do it manually, check the documentation of the
database you are using to find out what needs to be escaped and how
to do that.
Erik
------------------------------
Date: Fri, 16 Jun 2000 18:52:30 +0200
From: Johannes <gedichte@lycosmail.com>
Subject: Re: Single quotes in SQL queries
Message-Id: <394A5B4E.235AF0FB@lycosmail.com>
Darren Cooper wrote:
> My perl CGI scripts fall over when I put in code to do an SQL query
> involving variables or fields containing the single quote (') character.
>
> eg. $get_data = $dbh->prepare("SELECT * FROM country WHERE country =
> '$country'");
> when the value of $country is "Cote d'Ivore"
>
> or $update_data = $dbh->prepare("UPDATE user SET lastname = '$lastname'
> WHERE userid = '$userid'")
> when the value of $lastname is "O'Reilly"
>
> I understand how the problem is caused. But I don't know how to fix it.
You have to make sure that your value is correctly quoted:
$country = $dbh->quote($value);
$sth = $dbh->prepare("SELECT * FROM country WHERE country = ?");
$sth->execute($country);
You can also insert the correctly quoted string into the SQL statement:
$country = $dbh->quote($value);
$sth = $dbh->prepare("SELECT * FROM country WHERE country = '$country'");
$sth->execute();
------------------------------
Date: Fri, 16 Jun 2000 18:56:22 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Single quotes in SQL queries
Message-Id: <0cmkksk6erc7an83nohvu6rs3hcrhik72b@4ax.com>
On Sat, 17 Jun 2000 02:30:30 +1000, Darren Cooper <ozzydaz@WriteMe.com>
wrote:
> My perl CGI scripts fall over when I put in code to do an SQL query
> involving variables or fields containing the single quote (') character.
>
> eg. $get_data = $dbh->prepare("SELECT * FROM country WHERE country =
> '$country'");
> when the value of $country is "Cote d'Ivore"
>
> or $update_data = $dbh->prepare("UPDATE user SET lastname = '$lastname'
> WHERE userid = '$userid'")
> when the value of $lastname is "O'Reilly"
>
> I understand how the problem is caused. But I don't know how to fix it.
> Could anyone help?
Looks like DBI :-)
The best way is to use placeholders (?) in your query
$get_data = $dbh->prepare(
"SELECT * FROM country WHERE country = ?");
or
$update_data = $dbh->prepare(
"UPDATE user SET lastname = ? WHERE userid = ?");
and call the execute method with the actual values:
$get_data->execute($country);
and
$update_data->execute($lastname, $userid);
But some DBD-drivers do not support placeholders in all places. You
might have to resort to the $dbh->quote() method.
perldoc DBI
perldoc DBD::your_driver
--
Good luck,
Abe
------------------------------
Date: 16 Jun 2000 12:57:00 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Single quotes in SQL queries
Message-Id: <slrn8kko53.me0.abigail@alexandra.delanet.com>
Darren Cooper (ozzydaz@WriteMe.com) wrote on MMCDLXXXI September MCMXCIII
in <URL:news:sdkkkscpuiqvso41grlca779soeqmobdqp@4ax.com>:
\\ My perl CGI scripts fall over when I put in code to do an SQL query
\\ involving variables or fields containing the single quote (') character.
\\
\\ eg. $get_data = $dbh->prepare("SELECT * FROM country WHERE country =
\\ '$country'");
\\ when the value of $country is "Cote d'Ivore"
\\
\\ or $update_data = $dbh->prepare("UPDATE user SET lastname = '$lastname'
\\ WHERE userid = '$userid'")
\\ when the value of $lastname is "O'Reilly"
\\
\\ I understand how the problem is caused. But I don't know how to fix it.
\\ Could anyone help?
Well, since you know what's causing the problem, you have to fix it
in whatever way is appropriate for you particular SQL server.
Or you might be able to use placeholders, depending on what you use
to connect to your SQL server.
Abigail
--
perl -wlpe '}{*_=*.}{' file # Count the number of lines.
------------------------------
Date: 16 Jun 2000 11:14:24 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Sorting a ':' delimeted file by a field value/surname.
Message-Id: <slrn8kki4o.kp1.abigail@alexandra.delanet.com>
Jimmy Lantz (jimmy.lantz@ostas.lu.se) wrote on MMCDLXXXI September
MCMXCIII in <URL:news:394A1194.85041B01@ostas.lu.se>:
@@
@@ &read_file("$fil"); #reads the file into an array called @lines
Why the quotes around $fil? And why the bad style of assigning to a
global variable in read_file? And why the Perl 4 style of using a &?
@@
@@ $amountoflines = @lines;
@@
@@ print $amountoflines . "\n"; # printing the real amount of lines by
@@ printing the number of lines.
@@
@@ foreach $line (@lines) { $sorted{(split /:/)[3]} = $line; }
@@
@@ print "Testing sorted output below!\n\n";
@@ sort keys %sorted;
And what is the purpose of this? You take the keys of %sorted, sort
them, and throw away the result. Except for consuming memory and making
your program slower, this line doesn't do anything.
@@ foreach $key ( @keys{keys %sorted} ) #
Now you are looping over some of the values of %keys, of which you assume
to have the same keys as %sorted. Yet, you never populate %keys. It's
likely you meant %sorted, and you don't even have a hash called %keys.
Had you used -w and "use strict;", Perl would have told you.
@@ { print $sorted{$key};}
@@
@@ exit;
I bet your question could have easily answered by consulting the FAQ.
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Fri, 16 Jun 2000 17:18:11 GMT
From: nnyglb@my-deja.com
Subject: string::approx for windows
Message-Id: <8idnfu$bf$1@nnrp1.deja.com>
Does anyone know where I can get the compiled version of the
string::approx module?
I have already been to activestate and they don't have it listed. I
have left a message with them to find out if and when they will have it,
but I need it sooner than they will get to the email.
Any help would be appreciated.
Barry
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 16 Jun 2000 15:58:12 GMT
From: Ramya <omygod@my-deja.com>
Subject: subdomain name forwarding scripts ??
Message-Id: <8idiq9$scq$1@nnrp1.deja.com>
Hi,
I am not sure a javascript can do this or you need a cgi/perl script
but here is what I am looking for. I have a domain name www.myname.com
and I want to create subdomain names like music.myname.com ,
geek.myname.com etc. which in turn will be pointing to
www.myname.com/music and www.myname.com/geek for there respective index
pages. Could anybody suggest any sites with such scripts even for a
nominal fee.
Thanks for the info in advance,
Ramya.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 16 Jun 2000 18:39:58 +0200
From: Johannes <gedichte@lycosmail.com>
Subject: Re: subdomain name forwarding scripts ??
Message-Id: <394A585E.1CB83AD6@lycosmail.com>
Ramya wrote:
> Hi,
> I am not sure a javascript can do this or you need a cgi/perl script
> but here is what I am looking for. I have a domain name www.myname.com
> and I want to create subdomain names like music.myname.com ,
> geek.myname.com etc. which in turn will be pointing to
> www.myname.com/music and www.myname.com/geek for there respective index
> pages.
This isn't done with a script, you have to change your DNS configuration,
to send *.myname.com to your webserver.
Then you can change your webserver to point anything different from www to
the subdirectory you want.
------------------------------
Date: 16 Jun 2000 09:43:56 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Syntax checker
Message-Id: <394a594c@news.victoria.tc.ca>
Jonathan Stowe (gellyfish@gellyfish.com) wrote:
: On Tue, 13 Jun 2000 17:52:39 -0500 Barry Grupe wrote:
: >>
: >> It is called "perl" :-)
: >>
: >> perl -cw my_script
: >
: > Try that with a 50K program that you left out a '}' in. EOF errors are no
: > help. :-)
: Thats why people use editors that can show matched brackets.
Why depend on technology when a simple style change wil solve your
problems?
Align brackets vertically and you don't need a fancy editor or syntax
checker.
while (something)
{
# If they don't vertically align, you've got a problem.
}
Note that this code can be checked without any tools - like when you're
reading a printout while riding home on the bus!
------------------------------
Date: Fri, 16 Jun 2000 17:20:48 +0200
From: Wolfgang Hielscher <W.Hielscher@mssys.com>
Subject: system() in WinNT4-service
Message-Id: <394A45D0.D780D12C@mssys.com>
Hi!
I developed sort of a daemon running both on HP-UX and WinNT4.0 using
Perl (Version 5.004_02 on WinNT).
In order to behave daemon-like, I created a WinNT-Service (using Delphi
btw) starting my Perl-Script. To fulfill its task the Perl-script needs
to call the system()-function.
I tested this daemon on different WinNT-workstations in a network, all
using the same Perl-interpreter located on a server. The result of the
test is somewhat suprising to me: On most of the WinNT-workstations the
daemon works fine, just as expected.
But: On some workstations, the system()-call failed, returning the
result 0xff00 and setting $! to "No such file or directory". Furthermore
on most of these WinNT-machines, this misbehavior disappears after
rebooting them 2 or 3 times while some steadily deny executing the
system()-function.
Having performed serveral tests I found out that the system()-function
fails the way described above with any parameters given, even
system("dir") or system("").
Obviously, this system()-problem disappears after logging in and
starting the Perl-Script from a commandline.
So, does anyone know under which circumstances the system()-function
fails?
Cheers
Wolfgang
------------------------------
Date: Fri, 16 Jun 2000 12:49:15 -0400
From: "verio" <viciousdogs@zdnetmail.com>
Subject: Text substitution problem
Message-Id: <hUs25.5670$HD6.167757@iad-read.news.verio.net>
Can anyone tell me how I can delete equal signs (=) from a text file?
I have tried:
$postinput =~ s/=//g;
$postinput =~ s/\=//g;
$postinput =~ s/\W//g;
$postinput =~ s/\061//g;
$postinput =~ s/[=]//g;
and a lot of other variations that make even less sense.
viciousdogs@zdnetmail.com
------------------------------
Date: Fri, 16 Jun 2000 18:55:15 +0200
From: Johannes <gedichte@lycosmail.com>
Subject: Re: Text substitution problem
Message-Id: <394A5BF3.5C9EE85B@lycosmail.com>
If $postinput is a multiline string you should use: $postinput =~
s/=//mg;
verio wrote:
> Can anyone tell me how I can delete equal signs (=) from a text file?
>
> I have tried:
> $postinput =~ s/=//g;
> $postinput =~ s/\=//g;
> $postinput =~ s/\W//g;
> $postinput =~ s/\061//g;
> $postinput =~ s/[=]//g;
> and a lot of other variations that make even less sense.
>
> viciousdogs@zdnetmail.com
------------------------------
Date: Fri, 16 Jun 2000 17:04:00 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Text substitution problem
Message-Id: <x7snud5zi8.fsf@home.sysarch.com>
>>>>> "J" == Johannes <gedichte@lycosmail.com> writes:
J> If $postinput is a multiline string you should use: $postinput =~
J> s/=//mg;
that /m has no effect. /m only modifies ^ and $ to match internal
newlines.
J> verio wrote:
>> Can anyone tell me how I can delete equal signs (=) from a text file?
>>
>> I have tried:
>> $postinput =~ s/=//g;
are you sure this didn't work?
>> $postinput =~ s/\=//g;
not needed. = is not a metachar in regexes
>> $postinput =~ s/\W//g;
huh? delete all non-word chars? overkill for just removing =
>> $postinput =~ s/[=]//g;
no different than the first one.
>> and a lot of other variations that make even less sense.
and did you really look at your output?
the best and fastest way is:
tr/=//d ;
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Fri, 16 Jun 2000 13:07:47 -0400
From: "verio" <viciousdogs@zdnetmail.com>
Subject: Re: Text substitution problem
Message-Id: <E9t25.5679$HD6.167914@iad-read.news.verio.net>
No good. The equal sign is still there.
$postinfo is defined as
read(STDIN, $buffer, $ENV{"CONTENT_LENGTH"});
$postinput = $buffer;
I haven't been able to strip out the equal sign in the incoming text string
that is sent as part of the variable name.
viciousdogs@zdnetmail.com
"Johannes" <gedichte@lycosmail.com> wrote in message
news:394A5BF3.5C9EE85B@lycosmail.com...
> If $postinput is a multiline string you should use: $postinput =~
> s/=//mg;
>
> verio wrote:
>
> > Can anyone tell me how I can delete equal signs (=) from a text file?
> >
> > I have tried:
> > $postinput =~ s/=//g;
> > $postinput =~ s/\=//g;
> > $postinput =~ s/\W//g;
> > $postinput =~ s/\061//g;
> > $postinput =~ s/[=]//g;
> > and a lot of other variations that make even less sense.
> >
> > viciousdogs@zdnetmail.com
>
>
------------------------------
Date: Fri, 16 Jun 2000 19:09:06 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Text substitution problem
Message-Id: <rknkksclgd21i570u97khob0edkjtegdp9@4ax.com>
On Fri, 16 Jun 2000 12:49:15 -0400, "verio" <viciousdogs@zdnetmail.com>
wrote:
> Can anyone tell me how I can delete equal signs (=) from a text file?
>
> I have tried:
> $postinput =~ s/=//g;
> $postinput =~ s/\=//g;
> $postinput =~ s/\W//g;
> $postinput =~ s/\061//g;
> $postinput =~ s/[=]//g;
> and a lot of other variations that make even less sense.
$postinput =~ tr/=//d;
--
Good luck,
Abe
------------------------------
Date: Fri, 16 Jun 2000 12:12:52 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Text substitution problem
Message-Id: <394A6014.1766121C@texas.net>
verio wrote:
>
> Can anyone tell me how I can delete equal signs (=) from a text file?
>
> I have tried:
> $postinput =~ s/=//g;
That should work, assuming you've successfully gotten the contents of
the text file into $postinput; however, the 'tr' operator is much more
efficient.
perldoc perlop
perldoc perlrun
perl -pi.bak -e 'tr/=//d' <filename>
- Tom
------------------------------
Date: Fri, 16 Jun 2000 13:11:41 -0400
From: "verio" <viciousdogs@zdnetmail.com>
Subject: Re: Text substitution problem
Message-Id: <hdt25.5682$HD6.167928@iad-read.news.verio.net>
Got it. tr/=//d ; worked.
viciousdogs@zdnetmail.com
"Uri Guttman" <uri@sysarch.com> wrote in message
news:x7snud5zi8.fsf@home.sysarch.com...
> >>>>> "J" == Johannes <gedichte@lycosmail.com> writes:
>
> J> If $postinput is a multiline string you should use: $postinput =~
> J> s/=//mg;
>
> that /m has no effect. /m only modifies ^ and $ to match internal
> newlines.
>
> J> verio wrote:
>
> >> Can anyone tell me how I can delete equal signs (=) from a text file?
> >>
> >> I have tried:
> >> $postinput =~ s/=//g;
>
> are you sure this didn't work?
>
> >> $postinput =~ s/\=//g;
>
> not needed. = is not a metachar in regexes
>
> >> $postinput =~ s/\W//g;
>
> huh? delete all non-word chars? overkill for just removing =
>
> >> $postinput =~ s/[=]//g;
>
> no different than the first one.
>
> >> and a lot of other variations that make even less sense.
>
> and did you really look at your output?
>
> the best and fastest way is:
>
> tr/=//d ;
>
> uri
>
> --
> Uri Guttman --------- uri@sysarch.com ----------
http://www.sysarch.com
> SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX
Consulting
> The Perl Books Page -----------
http://www.sysarch.com/cgi-bin/perl_books
> The Best Search Engine on the Net ----------
http://www.northernlight.com
------------------------------
Date: Fri, 16 Jun 2000 13:04:58 -0400
From: "Thomas L. Newton" <thomas@newtonlabs.org>
Subject: Re: Text substitution problem
Message-Id: <394A5E3A.194C0ACD@newtonlabs.org>
When I can't figure out what is going on, I through it into an array
and look at the output.
@testArray = split (/\=/,$postinput);
print "@testArray\n";
-Thomas Newton
Johannes wrote:
>
> If $postinput is a multiline string you should use: $postinput =~
> s/=//mg;
>
> verio wrote:
>
> > Can anyone tell me how I can delete equal signs (=) from a text file?
> >
> > I have tried:
> > $postinput =~ s/=//g;
> > $postinput =~ s/\=//g;
> > $postinput =~ s/\W//g;
> > $postinput =~ s/\061//g;
> > $postinput =~ s/[=]//g;
> > and a lot of other variations that make even less sense.
> >
> > viciousdogs@zdnetmail.com
------------------------------
Date: Fri, 16 Jun 2000 19:19:47 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Text substitution problem
Message-Id: <05okksg6ipe1vfqaqiqderr8ha34gu1vlh@4ax.com>
On Fri, 16 Jun 2000 13:07:47 -0400, "verio" <viciousdogs@zdnetmail.com>
wrote:
> No good. The equal sign is still there.
>
> $postinfo is defined as
> read(STDIN, $buffer, $ENV{"CONTENT_LENGTH"});
> $postinput = $buffer;
That looks like a CGI thingy.
Now why would you want to remove the '='-signs from that? It makes your
user-supplied data worthless.
If you want the data suplied by the user, use CGI.pm, as it knows how to
deal with it.
perldoc CGI
--
Good luck,
Abe
------------------------------
Date: Fri, 16 Jun 2000 17:17:41 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Text substitution problem
Message-Id: <8idnk0$ps7$1@news.mch.sbs.de>
In article <E9t25.5679$HD6.167914@iad-read.news.verio.net>, "verio" <viciousdogs@zdnetmail.com> wrote:
>No good. The equal sign is still there.
>
>$postinfo is defined as
> read(STDIN, $buffer, $ENV{"CONTENT_LENGTH"});
> $postinput = $buffer;
>
>I haven't been able to strip out the equal sign in the incoming text string
>that is sent as part of the variable name.
Makes you wonder what data your browser is actually sending to
the server.
use CGI; would handle that for you, of course. :)
Michel.
------------------------------
Date: 16 Jun 2000 13:22:06 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Text substitution problem
Message-Id: <slrn8kkpk6.mho.abigail@alexandra.delanet.com>
verio (viciousdogs@zdnetmail.com) wrote on MMCDLXXXI September MCMXCIII
in <URL:news:hUs25.5670$HD6.167757@iad-read.news.verio.net>:
() Can anyone tell me how I can delete equal signs (=) from a text file?
()
() I have tried:
() $postinput =~ s/=//g;
That should work.
() $postinput =~ s/\=//g;
That should work.
() $postinput =~ s/\W//g;
That should delete anything that isn't a letter, digit or underscore.
() $postinput =~ s/\061//g;
That should delete the character `1'.
() $postinput =~ s/[=]//g;
That should work.
Of course, all of the above deletes characters from the string $postinput.
(In an inefficient way, y/=//d is more efficient).
However, the above doesn't have any file related code, so your problem
might be there.
Abigail
--
perl -wlpe '}{$_=$.}{' file # Count the number of lines.
------------------------------
Date: Fri, 16 Jun 2000 15:50:24 GMT
From: aml <andrew.mclaren@swx.ch>
Subject: Translating from a code reference back to a function name
Message-Id: <8idibo$rvn$1@nnrp1.deja.com>
Does anyone know how to translate from a code reference back to the
full function or method name? If you examine a code reference in the
debugger it does this for you, so it's obviously possible, but I
haven't a clue how.
Andrew
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Jun 2000 11:47:59 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Unix database for Perl
Message-Id: <slrn8kkk3k.kp1.abigail@alexandra.delanet.com>
Drew Simonis (care227@attglobal.net) wrote on MMCDLXXXI September
MCMXCIII in <URL:news:394A3F55.9F563927@attglobal.net>:
~~ Bob Tate wrote:
~~ >
~~ > Anyone know a good database for a Unix system that Perl will talk to.
~~
~~ I can't think of one that Perl _won't_ talk to.
~~ Read up on the DBD/DBI database modules.
But the DBD/DBI aren't the end all. There are also specific packages
for specific databases. Like sybperl for Sybase, which gives you
access to the Sybase provided API.
Abigail
--
perl -Mstrict -we '$_ = "goto V.print chop;\n=rekcaH lreP rehtona tsuJ";V1:eval'
------------------------------
Date: Fri, 16 Jun 2000 16:50:39 +0100
From: Dr M Hughes <mhughes@hgmp.mrc.ac.uk>
Subject: very simple cgi problem
Message-Id: <Pine.GSO.4.21.0006161641330.2938-100000@tin>
Please could someone give me an indicater as to why I am having problems
with the following very very simple script
use CGI qw(:standard);
print header(), start_html('hello world'), h1('blast results');
$cur=param("S1");
$type=param("form");
$database=param("T1");
open(SEQ, ">> s:/common data/blasts/cgi") || die "can't open";
print SEQ $cur;
print p("$type, $database, $cur");
print end_html();
For some reason the print to the file s:/common data/blasts/cgi will not
work. All the permissions on the file appear to be ok.
Thanks very much in advance.
Please reply to r.dobson@microscience.com otherwise I will have to wait
for a long time before receiving the answer and it's driving me up the
wall!
Rich
r.dobson@microscience.com
------------------------------
Date: Fri, 16 Jun 2000 12:11:39 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: very simple cgi problem
Message-Id: <394A51BB.55FBCC@attglobal.net>
[Posted and CC per request]
Dr M Hughes wrote:
>
> For some reason the print to the file s:/common data/blasts/cgi will not
> work. All the permissions on the file appear to be ok.
"For some reason" isn't very helpfull. Change your die statment
to also print the value of $!, and you may see exactly what that
reason is.
------------------------------
Date: 16 Jun 2000 16:44:39 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Very strange DBI:mysql-problem!
Message-Id: <961172932.5297@itz.pp.sci.fi>
In article <8ibgtc$fmo$1@nnrp1.deja.com>, jsunden@my-deja.com wrote:
>> you step through it in the debugger. If you still have troubles, you
>> should cut your code down to a small, self-contained example showing
>> the line of code which is not doing what you think it should. That way,
>> others will be able to see what's going on without having to set up a
>> database full of cheese. :-)
>
>If you read my mail it should be obvious that I think the problem is
>not to be found in the code, at least not with the debugger. It is,
Maybe so, but trying to reduce the code to a self-contained example of
less than half a dozen lines is good advice even in that case.
* If the bug is in your code, you'll probably find it in the process.
* If the bug is somewhere else, it'll be easier for others to debug.
* If the bug is a combination of both, we'll know what triggers it.
The code you posted was a good start, but it was still too long for
most of the regulars here to bother scrutinizing - we're not paid for
it, after all. Please try to simplify it further and post again.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: 16 Jun 2000 17:25:43 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Very strange DBI:mysql-problem!
Message-Id: <961174146.8907@itz.pp.sci.fi>
In article <8i8eij$5h6$1@nnrp1.deja.com>, joakim@varia.nu wrote:
>@ingredients = qw (onion cheese garlic goatcheese carrot);
>
>while (($ingredientid, $ingredientname) = $sth->fetchrow_array) {
> foreach $ingredient (@ingredients) {
> if ($ingredient =~ /$ingredientname/ig) {
> $ingredienthash{$ingredientid} = 1;
> }
> }
>}
After writing my previous post, I decided to take another, closer look
at your code. It did take some time, but I finally found your bug.
It's the /g regexp operator above. I have no idea what it's supposed
to be doing in such an unlikely place, but what it's actually doing is
carrying position information between iterations and thus causing the
problems you describe.
To confirm my hunch - based simply on the fact that the /g looked out
of place - I reduced your program to these two one-liners, only one of
which suffers from the same bug as your code:
$ perl -le '@a = qw(foo bar); @b = qw(ba oo o a); for $b (@b) {for $a (@a) {print "$a contains $b" if $a =~ /$b/}}'
bar contains ba
foo contains oo
foo contains o
bar contains a
$ perl -le '@a = qw(foo bar); @b = qw(ba oo o a); for $b (@b) {for $a (@a) {print "$a contains $b" if $a =~ /$b/g}}'
bar contains ba
foo contains oo
bar contains a
See. You're supposed to be able to do this yourself, you know.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: 16 Jun 2000 15:57:14 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Where are the error logs?
Message-Id: <961169990.1057@itz.pp.sci.fi>
In article <Pine.GHP.4.21.0006161211290.8722-100000@hpplus03.cern.ch>, Alan J. Flavell wrote:
>True. But injecting warning messages at random points into what's
>(presumably) supposed to be a syntactically valid HTML stream[1]
>that's being generated by the script, doesn't exactly make for legible
>results on screen.
I once wrote and used a modified version of CGI::Carp which had the
ability to print warnings as HTML comments. It also had a function to
delay the printing of warnings, to avoid messing up CDATA sections.
I can't find it now, and in any case it was rather klugy and based on
an old version of CGI::Carp. It shouldn't be too hard to rewrite,
though, and if someone bothered to do it well, maybe the patch could
be made into an official release. That'd also be a good time to do
the long-needed s/CODE/PRE/g on fatalsToBrowser()..
Unless somebody else volunteers, I'll see if I can find some extra
time to do this in the near future. I have a rather long queue of
things-to-do-yesterday, however, so don't count on anything.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Fri, 16 Jun 2000 18:59:54 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Where are the error logs?
Message-Id: <Pine.GHP.4.21.0006161857280.17418-100000@hpplus03.cern.ch>
On 16 Jun 2000, Ilmari Karonen wrote:
[good stuff omitted]
> That'd also be a good time to do
> the long-needed s/CODE/PRE/g on fatalsToBrowser()..
Oh gosh, I hadn't spotted that "bloomer". I hope the data also gets
HTML-escaped too, or weird things could still happen (maybe even some
of the things threatened in CA-2000-02...).
> Unless somebody else volunteers, I'll see if I can find some extra
> time to do this in the near future. I have a rather long queue of
> things-to-do-yesterday, however, so don't count on anything.
You're a public benefactor, clear enough ;-)
all the best
------------------------------
Date: Fri, 16 Jun 2000 16:33:24 GMT
From: mark rowlands <rowlands_mark@hotmail.com>
Subject: Re: why does this code print two spaces?
Message-Id: <8idksj$tuo$1@nnrp1.deja.com>
In article <Pine.GSO.4.10.10006151825260.5301-
100000@user2.teleport.com>,
Tom Phoenix <rootbeer@redcat.com> wrote:
> On Thu, 15 Jun 2000, mark rowlands wrote:
>
> > print "@gone has disappeared from $ch_here\n";
> > Print "@new has shown up at $oh_here\n";
>
> perl has no Print function. Please, if you want us to help you, show
us
> the code you're actually using. Thank you.
>
> --
> Tom Phoenix Perl Training and Hacking Esperanto
> Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
I edited in place to tidy it up a bit - sorry for the typo
#!/usr/bin/perl
open(OLD, "< samplea") || die("Can't open database samplea $!\n");
while (<OLD>){
(@db) = split(/\|/,$_);
dostuff();
}
close OLD;
sub dostuff {
$ch_here = $db[0];
$ch_portnum = $db[1];
$ch_ports = $db[2];
$ch_status = $db[3];
$ch_seqindex = $db[4];
$ch_os = $db[5];
(@ch_pports) = split(/,/,$ch_ports);
open(NEW, "< sampleb") || die("Can't open
database sampleb $!\n");
while (<NEW>){
(@ob) = split(/\|/,$_);
$oh_here = $ob[0];
$oh_portnum = $ob[1];
$oh_ports = $ob[2];
$oh_status = $ob[3];
$oh_seqindex = $ob[4];
$oh_os = $ob[5];
if ($oh_here eq $ch_here) {
if ($ch_ports ne $oh_ports) {
(@oh_pports) = split(/,/,$oh_ports);
my %ch_pports = map {$_ => 1}
@ch_pports;
my %oh_pports = map {$_ => 1}
@oh_pports;
my @new = grep {!$ch_pports {$_}}
@oh_pports; # new ports
my @gone = grep {!$oh_pports {$_}}
@ch_pports; # gone ports
print "@new has shown up at $oh_here\n";
print "@gone has disappeared from $ch_here\n";
#foreach $new (@new) {print "|$new|\n";}
#foreach $gone (@gone) {print "|$gone|\n";
} #end of ports
} #end of addresses
} #end of while NEW
} #end of doing stuff
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3393
**************************************