[17799] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5219 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 4 12:56:12 2001

Date: Thu, 4 Jan 2001 09:55:38 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <978630938-v9-i5219@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 4 Jan 2001     Volume: 9 Number: 5219

Today's topics:
        "Changed database context" / DBI:Sybase ->MSSQL7 <toughiq@i-one.at>
    Re: "Changed database context" / DBI:Sybase ->MSSQL7 (Abigail)
    Re: "Changed database context" / DBI:Sybase ->MSSQL7 <mpeppler@peppler.org>
        $ENV{'QUERY_STRING'} Question <josh@glassgallery.net>
    Re: $ENV{'QUERY_STRING'} Question (Garry Williams)
    Re: $ENV{'QUERY_STRING'} Question (Martien Verbruggen)
    Re: $ENV{'QUERY_STRING'} Question (Aleksandar V.)
    Re: $ENV{'QUERY_STRING'} Question (Martien Verbruggen)
    Re: $ENV{'QUERY_STRING'} Question <iltzu@sci.invalid>
    Re: $ENV{'QUERY_STRING'} Question <bart.lateur@skynet.be>
    Re: $ENV{'QUERY_STRING'} Question (Martien Verbruggen)
    Re: $ENV{'QUERY_STRING'} Question <iltzu@sci.invalid>
    Re: $ENV{'QUERY_STRING'} Question <bart.lateur@skynet.be>
    Re: $ENV{'QUERY_STRING'} Question (Abigail)
    Re: $ENV{'QUERY_STRING'} Question <iltzu@sci.invalid>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 03 Jan 2001 16:51:01 +0100
From: Christian Tawfik <toughiq@i-one.at>
Subject: "Changed database context" / DBI:Sybase ->MSSQL7
Message-Id: <l9i65t0ancdvkc6v00maaevbdt9sdq2b0b@4ax.com>

hi again,

i managed to get a connection between my solaris box and my MSSQL
server, using freeTDS and DBD::Sybase

but at every statement i get the following error message:

Changed database context to 'perldb'.

what does this mean? how to deactivate it?

my sql statements are not affected by this error, but it is annoying.

thanx for info.

bye chris


------------------------------

Date: 3 Jan 2001 16:48:17 GMT
From: abigail@foad.org (Abigail)
Subject: Re: "Changed database context" / DBI:Sybase ->MSSQL7
Message-Id: <slrn956luh.nmu.abigail@tsathoggua.rlyeh.net>

Christian Tawfik (toughiq@i-one.at) wrote on MMDCLXXXII September
MCMXCIII in <URL:news:l9i65t0ancdvkc6v00maaevbdt9sdq2b0b@4ax.com>:
() hi again,
() 
() i managed to get a connection between my solaris box and my MSSQL
() server, using freeTDS and DBD::Sybase
() 
() but at every statement i get the following error message:
() 
() Changed database context to 'perldb'.
() 
() what does this mean? how to deactivate it?

It's a Sybase message. See http://sybooks.sybase.com/, or one of the
two paper volumes describing the errors and messages of Sybase.

() my sql statements are not affected by this error, but it is annoying.

It's not an error, and I would be utterly surprised if they are not
affected. After all, you do want to run your queries in a database,
preferable the one with the structures and data, don't you? 



Abigail
-- 
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
          q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'


------------------------------

Date: Thu, 04 Jan 2001 07:45:04 -0800
From: "Michael Peppler" <mpeppler@peppler.org>
Subject: Re: "Changed database context" / DBI:Sybase ->MSSQL7
Message-Id: <t596k1tfsfced@corp.supernews.com>

In article <l9i65t0ancdvkc6v00maaevbdt9sdq2b0b@4ax.com>, "Christian
Tawfik" <toughiq@i-one.at> wrote:

> hi again,
> 
> i managed to get a connection between my solaris box and my MSSQL
> server, using freeTDS and DBD::Sybase
> 
> but at every statement i get the following error message:
> 
> Changed database context to 'perldb'.
> 
> what does this mean? how to deactivate it?

This is an informational message that tells the client which database is
the "default" database (or current database) for the connection.
DBD::Sybase "hides" this message when connecting to Sybase servers, but
it appears that MS-SQL has changed the error number for this message.

You can hide it in various ways - see the syb_err_handler database handle
attribute for one way of doing that.

Michael
-- 
Michael Peppler - Data Migrations Inc. - mpeppler@peppler.org
http://www.mbay.net/~mpeppler - mpeppler@mbay.net
International Sybase User Group - http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com


------------------------------

Date: Tue, 2 Jan 2001 16:37:06 -0600
From: "Josh Harlan" <josh@glassgallery.net>
Subject: $ENV{'QUERY_STRING'} Question
Message-Id: <BLs46.10$tE2.2782@news1.primary.net>


Hello,

I have developed a script that accesses data by linking to
states.cgi?Colorado, as an example.  The $ENV{'QUERY_STRING'} works fine for
one word states.  But if I want to have it be two word states, such as North
Dakota I link it to states.cgi?North%20Dakota or states.cgi?North+Dakota and
they display the %20 or + literally instead of converting it to a space.
How might I convert the %20 or + to a space?

Link to source: http://www.glassgallery.net/states.txt

Thanks for any help!


Josh




------------------------------

Date: Tue, 02 Jan 2001 22:59:24 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <g3t46.1044$Dm5.29839@eagle.america.net>

On Tue, 2 Jan 2001 16:37:06 -0600, Josh Harlan <josh@glassgallery.net> wrote:
>
>Hello,
>
>I have developed a script that accesses data by linking to
>states.cgi?Colorado, as an example.  The $ENV{'QUERY_STRING'} works fine for
>one word states.  But if I want to have it be two word states, such as North
>Dakota I link it to states.cgi?North%20Dakota or states.cgi?North+Dakota and
>they display the %20 or + literally instead of converting it to a space.
>How might I convert the %20 or + to a space?

It sounds like you should be using the CGI module instead of rolling
your own.  

But who can really tell?  No code.  

-- 
Garry Williams


------------------------------

Date: Wed, 3 Jan 2001 10:07:13 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <slrn954np1.edk.mgjv@martien.heliotrope.home>

On Tue, 2 Jan 2001 16:37:06 -0600,
	Josh Harlan <josh@glassgallery.net> wrote:
> 
> Hello,
> 
> I have developed a script that accesses data by linking to
> states.cgi?Colorado, as an example.  The $ENV{'QUERY_STRING'} works fine for
> one word states.  But if I want to have it be two word states, such as North
> Dakota I link it to states.cgi?North%20Dakota or states.cgi?North+Dakota and
> they display the %20 or + literally instead of converting it to a space.
> How might I convert the %20 or + to a space?

Your terminology is terribly confused, but I suspect you are trying to
write a program using the CGI that needs to accept a query string with
spaces in it, and you want to know how to decode those spaces in your
program, right?

You use the CGI.pm module that comes with Perl, and that does all CGI
work for you. Hardly any sane Perl programmer even considers doing this
stuff themselves, nowadays.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
NSW, Australia                  | 


------------------------------

Date: 3 Jan 2001 00:05:21 GMT
From: acabox@yahoo.com (Aleksandar V.)
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <slrn954r41.qd.acabox@localhost.localdomain>

>
>
>I have developed a script that accesses data by linking to
>states.cgi?Colorado, as an example.  The $ENV{'QUERY_STRING'} works fine for
>one word states.  But if I want to have it be two word states, such as North
>Dakota I link it to states.cgi?North%20Dakota or states.cgi?North+Dakota and
>they display the %20 or + literally instead of converting it to a space.
>How might I convert the %20 or + to a space?
>
>Link to source: http://www.glassgallery.net/states.txt
>
>Thanks for any help!
>
>
>Josh
>
>


It's quite simple. Just replace the "%20" with space " ". Example:


$viewstate = "These%20words%20should%be%20separated%with%20spaces.";

print "This is ugly text:\n";
print "$viewstate\n\n";

$viewstate =~ s/%20/ /g;

print "And this is corrected text:\n";
print "$viewstate\n";



If you're familiar with VI editor, in Perl you can replace text in the
same manner.

Hope this helps...




-- 
~ Sascha.
My opinions may have changed, but not the fact that I am right.
(Ashleigh Brilliant)


------------------------------

Date: Wed, 3 Jan 2001 12:20:14 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <slrn954vie.edk.mgjv@martien.heliotrope.home>

On 3 Jan 2001 00:05:21 GMT,
	Aleksandar V. <acabox@yahoo.com> wrote:
>>
>>
>>I have developed a script that accesses data by linking to
>>states.cgi?Colorado, as an example.  The $ENV{'QUERY_STRING'} works fine for
>>one word states.  But if I want to have it be two word states, such as North
>>Dakota I link it to states.cgi?North%20Dakota or states.cgi?North+Dakota and
>>they display the %20 or + literally instead of converting it to a space.
>>How might I convert the %20 or + to a space?
> 
> It's quite simple. Just replace the "%20" with space " ". Example:

It may be, for this one instance. But, the OP also mentioned the '+'
encoding for space. You didn't provide for that. And then there are
many, many other possible encoded characters. Your code doesn't deal
with that.

Instead of coming up with these once off, incomplete 'solutions', maybe
it would be better to refer the OP to a module that does all this, and
is more likely to do it correctly than someone who has to ask this
question.

And if you really have such an aversion to using modules, at least you
could point the OP to the module with the advice to extract the relevant
code.

> $viewstate = "These%20words%20should%be%20separated%with%20spaces.";
> 
> print "This is ugly text:\n";

Ugly?

> If you're familiar with VI editor, in Perl you can replace text in the
> same manner.

I beg to differ. It's not the same. Perl's regexen are quite different
from the standard vi regexen. Besides that, the flags to the s///
operator are different as well.

> ~ Sascha.
> My opinions may have changed, but not the fact that I am right.
> (Ashleigh Brilliant)

sic.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.   | enough features yet.
NSW, Australia                  | 


------------------------------

Date: 3 Jan 2001 13:09:59 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <978526460.27021@itz.pp.sci.fi>

In article <slrn954vie.edk.mgjv@martien.heliotrope.home>, Martien Verbruggen wrote:
>
>It may be, for this one instance. But, the OP also mentioned the '+'
>encoding for space. You didn't provide for that. And then there are
>many, many other possible encoded characters. Your code doesn't deal
>with that.
>
>Instead of coming up with these once off, incomplete 'solutions', maybe
>it would be better to refer the OP to a module that does all this, and
>is more likely to do it correctly than someone who has to ask this
>question.

Well, I do agree that unless you know just how something is done, it's
better to use a module that to try guessing.  And once you know how
something is done, it often becomes apparent that using the module is
much more sensible that reinventing the wheel.

I'm just not sure if _this_ particular problem fits the second case
above, seeing as it can be solved in one or two lines anyway.  Here's
a little script I've found very useful:

  #!/usr/bin/perl -w
  use strict;

  my $q = join ' ' => @ARGV;
  $q =~ s/[^ \w]/sprintf '%%%02X', ord $&/eg;
  $q =~ tr/ /+/;

  exec 'lynx', '-cookies=off', "http://www.google.com/search?q=$q";

  __END__

Of course I could've used an existing function, like escape() from
CGI.pm, and I do just that whenever I'm already using that module.
But why bother in a script as simple as this?

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm



------------------------------

Date: Wed, 03 Jan 2001 16:22:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <hbk65tkeiub0bvoit87801bm32j9u83f90@4ax.com>

Josh Harlan wrote:

>I have developed a script that accesses data by linking to
>states.cgi?Colorado, as an example.  The $ENV{'QUERY_STRING'} works fine for
>one word states.  But if I want to have it be two word states, such as North
>Dakota I link it to states.cgi?North%20Dakota or states.cgi?North+Dakota and
>they display the %20 or + literally instead of converting it to a space.
>How might I convert the %20 or + to a space?

Gee.

	s/\+|%20/ /g;

But it sounds as if you're manually "decoding" the CGI form parameters.
Don't. Cargo Cult code alert! Use a proper module. If CGI.pm is too
heavy-weight for you, check out the alternatives, CGI::Request,
CGI::Lite, CGI::Minimal or even the old cgi-lib.pl. All are better than
rolling your own.

-- 
	Bart.


------------------------------

Date: Thu, 4 Jan 2001 09:13:10 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <slrn9578vm.edk.mgjv@martien.heliotrope.home>

On 3 Jan 2001 13:09:59 GMT,
	Ilmari Karonen <iltzu@sci.invalid> wrote:
> In article <slrn954vie.edk.mgjv@martien.heliotrope.home>, Martien Verbruggen wrote:
>>
>>It may be, for this one instance. But, the OP also mentioned the '+'
>>encoding for space. You didn't provide for that. And then there are
>>many, many other possible encoded characters. Your code doesn't deal
>>with that.
>>
>>Instead of coming up with these once off, incomplete 'solutions', maybe
>>it would be better to refer the OP to a module that does all this, and
>>is more likely to do it correctly than someone who has to ask this
>>question.
> 
> Well, I do agree that unless you know just how something is done, it's
> better to use a module that to try guessing.  And once you know how
> something is done, it often becomes apparent that using the module is
> much more sensible that reinventing the wheel.
> 
> I'm just not sure if _this_ particular problem fits the second case
> above, seeing as it can be solved in one or two lines anyway.  Here's
> a little script I've found very useful:
> 
>   #!/usr/bin/perl -w
>   use strict;
> 
>   my $q = join ' ' => @ARGV;
>   $q =~ s/[^ \w]/sprintf '%%%02X', ord $&/eg;
>   $q =~ tr/ /+/;
> 
>   exec 'lynx', '-cookies=off', "http://www.google.com/search?q=$q";
> 
>   __END__
> 
> Of course I could've used an existing function, like escape() from
> CGI.pm, and I do just that whenever I'm already using that module.
> But why bother in a script as simple as this?

Because the way you use it isn't the way the OP wanted to use it. If you
follow the link provided by the OP you'll find that where he wanted to
use the code he's talking about (and he needs unescape, not escape) is
in a CGI program. Even if the CGI program only expects escaped spaces
(which would be a failry dangerous assumption), right now, who says that
that won't change in the future. Even in the example of your script,
invalid characters may be left in the query string, even though maybe
lynx doesn't care or even escapes them for you. 

I tend to be very, very weary of making assumptions that the
requirements for a program that I write today are going to be the same
tomorrow. Life has taught me not to put trust in that. Unless there is a
very good performance reason, or another really good reason, will I
consider implementing an incomplete solution. Since the solution to this
partiocular problem has been implemented several times in several
modules, I wouldn't even dream of not using them.

Everyone is free to do whatever they want. However, if someone working
for me would code this sort of stuff up themselves, I'd ask them to
justify it.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | I used to have a Heisenbergmobile.
Commercial Dynamics Pty. Ltd.   | Every time I looked at the
NSW, Australia                  | speedometer, I got lost.


------------------------------

Date: 4 Jan 2001 10:42:15 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <978604165.24148@itz.pp.sci.fi>

In article <slrn9578vm.edk.mgjv@martien.heliotrope.home>, Martien Verbruggen wrote:
>On 3 Jan 2001 13:09:59 GMT,
>	Ilmari Karonen <iltzu@sci.invalid> wrote:
>> 
>>   $q =~ s/[^ \w]/sprintf '%%%02X', ord $&/eg;
>>   $q =~ tr/ /+/;
>
>Because the way you use it isn't the way the OP wanted to use it. If you
>follow the link provided by the OP you'll find that where he wanted to
>use the code he's talking about (and he needs unescape, not escape) is

Okay, then reverse it.

  $query =~ tr/+/ /;
  $query =~ s/%([\dA-F][\dA-F])/chr hex $1/ieg;


>that won't change in the future. Even in the example of your script,
>invalid characters may be left in the query string, even though maybe
>lynx doesn't care or even escapes them for you. 

Ehm?  Which character in \w is invalid in an URL?

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm



------------------------------

Date: Thu, 04 Jan 2001 12:37:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <ulr85tg336965b5741o6thr5trbe430a2r@4ax.com>

Ilmari Karonen wrote:

>Ehm?  Which character in \w is invalid in an URL?

Maybe "_"?

-- 
	Bart.


------------------------------

Date: 4 Jan 2001 15:03:51 GMT
From: abigail@foad.org (Abigail)
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <slrn95946n.qdu.abigail@tsathoggua.rlyeh.net>

Ilmari Karonen (iltzu@sci.invalid) wrote on MMDCLXXXIII September
MCMXCIII in <URL:news:978604165.24148@itz.pp.sci.fi>:
;; 
;;       Which character in \w is invalid in an URL?


That's a meaningless question. All characters are valid in some part of
some scheme, but all characters are also invalid for at least one part
of at least one scheme.



Abigail
-- 
perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
           ${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'


------------------------------

Date: 4 Jan 2001 17:29:25 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: $ENV{'QUERY_STRING'} Question
Message-Id: <978628976.10972@itz.pp.sci.fi>

In article <ulr85tg336965b5741o6thr5trbe430a2r@4ax.com>, Bart Lateur wrote:
>Ilmari Karonen wrote:
>
>>Ehm?  Which character in \w is invalid in an URL?
>
>Maybe "_"?

RFC 2396 disagrees with you:

  2.3. Unreserved Characters

     Data characters that are allowed in a URI but do not have a reserved
     purpose are called unreserved. These include upper and lower case
     letters, decimal digits, and a limited set of punctuation marks and
     symbols.

     unreserved alphanum | mark
        mark    - | _ | . | ! | ~ | * | ' | ( | )

     Unreserved characters can be escaped without changing the semantics
     of the URI, but this should not be done unless the URI is being used
     in a context that does not allow the unescaped character to appear.

So actually the regex should/could have been [^ \w.!~*'()-] instead of
just [^ \w], but as the last paragraph says, both are acceptable.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm



------------------------------

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 5219
**************************************


home help back first fref pref prev next nref lref last post