[25801] in Perl-Users-Digest
Perl-Users Digest, Issue: 8040 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 2 11:05:26 2005
Date: Mon, 2 May 2005 08:05:07 -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 Mon, 2 May 2005 Volume: 10 Number: 8040
Today's topics:
Can't install Oracle::Loader module <egoduk@NOSPAM_hotmail.com>
Re: CGI & Formatting or a Perl Problem?! <hackeras@gmail.com>
Re: Help with perl array (Vorxion)
Re: Help with perl array <tadmc@augustmail.com>
How do you check the utf8 flag on a given string? <g_m@remove-comcast.net>
Re: missing the boat <joe@inwap.com>
Re: REMOTE_HOST aint working <joe@inwap.com>
Re: REMOTE_HOST aint working <hackeras@gmail.com>
Re: REMOTE_HOST aint working <hackeras@gmail.com>
request uri in CGI module <moritz.karbach@desy.de>
Re: request uri in CGI module <1usa@llenroc.ude.invalid>
Re: request uri in CGI module <moritz.karbach@desy.de>
Re: request uri in CGI module <noreply@gunnar.cc>
Somethign about hashes <hackeras@gmail.com>
Re: Somethign about hashes <wyzelli@yahoo.com>
Re: Somethign about hashes (Greg Bacon)
Re: Somethign about hashes <hackeras@gmail.com>
Re: Somethign about hashes <hackeras@gmail.com>
Re: Somethign about hashes <noreply@gunnar.cc>
Re: Somethign about hashes <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 2 May 2005 13:31:19 +0100
From: "Edward" <egoduk@NOSPAM_hotmail.com>
Subject: Can't install Oracle::Loader module
Message-Id: <42761d87$0$83063$ed2619ec@ptn-nntp-reader01.plus.net>
Running 'perl Makefile.pl' reports a file (Loader.t) is missing from the
distribution. This file is where it's supposed to be.
Any ideas how I would fix this?
Thanks,
Edward.
Server # tar -xvf Oracle-Loader-1.03.tar
x ./Oracle-Loader-1.03, 0 bytes, 0 tape blocks
x ./Oracle-Loader-1.03/t, 0 bytes, 0 tape blocks
x ./Oracle-Loader-1.03/t/Loader.t, 3628 bytes, 8 tape blocks
x ./Oracle-Loader-1.03/Loader.pm, 71664 bytes, 140 tape blocks
x ./Oracle-Loader-1.03/test.pl, 223 bytes, 1 tape blocks
x ./Oracle-Loader-1.03/Makefile.PL, 1403 bytes, 3 tape blocks
x ./Oracle-Loader-1.03/Oracle-Loader-1.03.readme, 29294 bytes, 58 tape
blocks
x ./Oracle-Loader-1.03/README, 29294 bytes, 58 tape blocks
x ./Oracle-Loader-1.03/MANIFEST, 76 bytes, 1 tape blocks
Server # cd Oracle-Loader-1.03
Server # perl Makefile.PL
*** ExtUtils::AutoInstall version 0.61
*** Checking for dependencies...
*** ExtUtils::AutoInstall configuration finished.
Checking if your kit is complete...
Warning: the following files are missing in your kit:
./t/Loader.t
Please inform the author.
Writing Makefile for Oracle::Loader
--
I am using the free version of SPAMfighter for private users.
It has removed 4456 spam emails to date.
Paying users do not have this message in their emails.
Try www.SPAMfighter.com for free now!
------------------------------
Date: Mon, 02 May 2005 13:20:51 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: CGI & Formatting or a Perl Problem?!
Message-Id: <d54utv$442$1@nic.grnet.gr>
Fabian Pilkowski wrote:
> Err, your CSS class 'tip' is only defined for <td>-tags, and not for
> <span>. Please fix that and it should work.
Yes you were right, i chanegs td.tip to span.tin and now it is showing
as it should. That also corrected other print errors as well.
Thank you.
--
"Of course I cant stop you. And that would really bum me out
if that were my job. But my job isnt to stop you, its to
make it as difficult as possible, for as many as possible,
for as long as possible ."
------------------------------
Date: 2 May 2005 06:56:10 -0400
From: vorxion@knockingshopofthemind.com (Vorxion)
Subject: Re: Help with perl array
Message-Id: <4276074a$1_1@news.iglou.com>
In article <VVmde.14922$qK3.6049@fe1.news.blueyonder.co.uk>, Nick wrote:
>I have a partial perl script that i want to understand and then be able
>to change. It simply searches a text file for text and print that text
Oh, it -needs- changes.
>use CGI;
>use CGI::Carp qw(fatalsToBrowser); # Hook errors to browser
>
>#search_file.pl
>read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});
>$buffer =~ tr/+/ /;
>$buffer =~ s/\r/ /g;
>$buffer =~ s/\n/ /g;
>@pairs = split(/&/,$buffer);
>foreach $pair(@pairs){
>($key,$value)=split(/=/,$pair);
>$formdata{$key}.="$value";
>}
You bother to include CGI, but then write your own broken version? Why?
Your methodology -can- break--quite easily. If the input is large enough
and chunked or split by packet sizes, you won't get CONTENT_LENGTH all at
once, and you're not bothering to retry and append until you do. You're
also only handling POST with your methodology, where the module you include
but don't use is already fully capable of handling both. I happened to
nuke the rest, but I don't see you doing any urldecoding, either--at least
not in the quoted section where I'd expect at least a reference to a
function designed to do so. Pardon, you decoded spaces but none of the
other characters you're likely to need decoded. Very broken.
If you're going to work in this area, I suggest you fully embrace CGI.pm
and use it correctly. Everything else is superfluous because your engine
is more or less destined to break.
`perldoc CGI`
Actually, I suggest that you hire someone to actually work on your CGI for
you. If you're making mistakes this crucial, you're bound to overlook
even some of the most basic CGI security rules. This leads to compromised
systems, which are generally Not A Good Thing[tm].
No offense...I've just seen systems that are the result of people trying to
roll their own when they don't understand the basics. CGI is not an area
for beginners, from a security standpoint.
------------------------------
Date: Mon, 2 May 2005 08:03:24 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Help with perl array
Message-Id: <slrnd7c98s.4at.tadmc@magna.augustmail.com>
Nick <please@touchmywilly.com> wrote:
> I have a partial perl script
It is a profoundly amateurish program.
You would be well-served to throw it away and start with code
that was writted by a *good* programmer instead.
> that i want to understand and then be able
> to change. It simply searches a text file for text and print that text
> to a web page. I want to understand the array
The array does nothing more than hold all of the lines in memory,
only to process them line-by-line anyway.
A Real Programmer would not have written it that way.
> and be able to add
> multiple more lines.
The array has nothing to do with the number of fields.
> At the moment, it has two fields (surname and forename), i need to
> expand that to around 6 or 7 fields.
You need to change the split() line if you want to accomodate more fields.
> Ultimately, i want to be able to search a text file for specific text
> and have it output all matches (the complete line) to a web page.
>
> Below is what i have so far:
>
> #!/usr/bin/perl -w
>
> use CGI;
> use CGI::Carp qw(fatalsToBrowser); # Hook errors to browser
>
> #search_file.pl
> read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});
> $buffer =~ tr/+/ /;
> $buffer =~ s/\r/ /g;
> $buffer =~ s/\n/ /g;
> @pairs = split(/&/,$buffer);
> foreach $pair(@pairs){
> ($key,$value)=split(/=/,$pair);
> $formdata{$key}.="$value";
> }
> $search=$formdata{'search'};
This is buggy and has security holes.
You will be hacked if you attempt to use this code.
You are already pulling in the CGI module, so you should use
that for parsing the form values instead.
> open(INFO, "names_file.txt"); # Open db for reading
You should always, yes *always*, check the return value from open():
open(INFO, 'names_file.txt') or die "could not open 'names_file.txt' $!";
> @array=<INFO>;
> foreach $line (@array){
It is script-kiddie form to read into an array only to process
line-by-line anyway.
Why not read a line a process a line, having only a single line
in memory instead?
> print <<End_of_line;
> Your search returned: $first $last<br>
> End_of_line
More hokey code.
print "Your search returned: $first $last<br>";
does the same thing only it is easier to read.
> Any help much appreciated.
Scrap that piece of crap and write a new program from scratch.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 2 May 2005 09:46:24 -0400
From: "~greg" <g_m@remove-comcast.net>
Subject: How do you check the utf8 flag on a given string?
Message-Id: <1KudnehU3ZW-suvfRVn-tQ@comcast.com>
One case of the problem I'm having is that I'm reading from a file strings
containing Ns with tildes on them
Ñ
(- or they're something, anyway, that I know should look like
a ascii 209 --in 8859-1 (I guess) )
And I'm trying to sort strings so that these get sorted like 'n's.
At the moment I'm trying to do this by checking for ordinals 209
and then converting them to 'n's for the comparisons.
I'm also checking, eg, for ordinals 195 ( 'A's with a tildes on them, - Ã )
Problem is that the 'n's are getting sorted as if they were 'a's.
And the Ñ (--N with tilde) get printed to an HTML file as Ã'
( ---A with tilde followed by a back-tick)
-- which does appear in the rendered HTM as an Ñ (N with tilde).
OBVIOUSLY - I don't don't know what I'm doing!
It seems to me that the sorting is being done on bytes,
whereas it should be being done on utf8-wide characters.
So I think the first step for me would be to check the utf8-flags
of the program's strings at each point in the processing,
to see how the program is regarding them.
But I don't know how to check that.
~greg
------------------------------
Date: Mon, 02 May 2005 03:14:40 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: missing the boat
Message-Id: <lP2dne9rUMEPYOjfRVn-ig@comcast.com>
Michael De Tomaso wrote:
> (.) (.) (.) (.)
> -- You say tomato and I say tomatoe, Let's call the whole thing off
You have your signature written in an invalid format. You need to
fix that. The first line must be two hyphens, a space, and nothing
else, like this:
|--
| (.) (.) (.) (.)
| You say tomato and I say tomatoe, Let's call the whole thing off
------------------------------
Date: Mon, 02 May 2005 03:06:36 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: REMOTE_HOST aint working
Message-Id: <nf6dnfh7-qkzZujfRVn-vA@comcast.com>
Nikos wrote:
>> Probably because your web server is not configured to resolve the IP
>> address.
>
> a asked in #apache on UnderNet and they told me that Apache isnt
> responsible for this.
Whoever answered you is ignorant or misinformed.
Apache has a config file setting to turn it on and off.
It is one of the "core" directives.
-Joe
------------------------------
Date: Mon, 02 May 2005 13:08:51 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: REMOTE_HOST aint working
Message-Id: <d54u7f$3jk$1@nic.grnet.gr>
Joe Smith wrote:
> Nikos wrote:
>
>>> Yes. Read the dcoumentation for your web server.
>>
>>
>> I searched the docs. nothing relevant.
>
>
> You didn't do a very good job looking for it. It's right there,
> listed as being part of the core configuration directives.
> http://httpd.apache.org/docs/mod/core.html
>
> -Joe
Yes its, HostnameLookups on
but how di you searched this? i serached it too but didnt find it.
--
"Of course I cant stop you. And that would really bum me out
if that were my job. But my job isnt to stop you, its to
make it as difficult as possible, for as many as possible,
for as long as possible ."
------------------------------
Date: Mon, 02 May 2005 13:10:48 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: REMOTE_HOST aint working
Message-Id: <d54ub4$3jk$2@nic.grnet.gr>
Joe Smith wrote:
> Nikos wrote:
>
>> This can be done also liek you said but that would require the use of an
>> extra module that would have to be downloaded from CPAN.
>
>
> Wrong!
>
> 'use Socket;' does *not* require downloading any modules from CPAN.
>
> I suggest that you familiarize yourself with the list of modules
> that come bundled in with the perl sources.
> -Joe
Yes other guys told me thats is embedded in the core as well yesterday.
I though it was an extra module.
--
"Of course I cant stop you. And that would really bum me out
if that were my job. But my job isnt to stop you, its to
make it as difficult as possible, for as many as possible,
for as long as possible ."
------------------------------
Date: Mon, 02 May 2005 14:06:54 +0200
From: Moritz Karbach <moritz.karbach@desy.de>
Subject: request uri in CGI module
Message-Id: <d5554u$2u0fu$1@claire.desy.de>
Hi everyone,
I need something similar to the PHP variable $SERVER[REQUEST_URI], that is
the full string someone entered in his browser, the url and the query.
Is there some easy way to get this? Or do I have to compose it again using
CGI::params and lots of ? and & parsing?
Cheers,
- Moritz
------------------------------
Date: Mon, 02 May 2005 12:20:06 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: request uri in CGI module
Message-Id: <Xns964A54B05692Basu1cornelledu@127.0.0.1>
Moritz Karbach <moritz.karbach@desy.de> wrote in
news:d5554u$2u0fu$1@claire.desy.de:
> I need something similar to the PHP variable $SERVER[REQUEST_URI],
> that is the full string someone entered in his browser, the url and
> the query.
I am not fmailiar with PHP to know exactly what that variable contains.
> Is there some easy way to get this? Or do I have to compose it again
> using CGI::params and lots of ? and & parsing?
Why not read the documentation?
http://search.cpan.org/~lds/CGI.pm-3.08/CGI.pm#CREATING_A_SELF-
REFERENCING_URL_THAT_PRESERVES_STATE_INFORMATION:
or
http://search.cpan.org/~lds/CGI.pm-
3.08/CGI.pm#OBTAINING_THE_SCRIPT'S_URL
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Mon, 02 May 2005 14:38:37 +0200
From: Moritz Karbach <moritz.karbach@desy.de>
Subject: Re: request uri in CGI module
Message-Id: <d5570d$2ue11$1@claire.desy.de>
A. Sinan Unur wrote:
> Why not read the documentation?
Actually I had a quick look at the docu and I searched it for "request uri"
and something similar, but I didn't find anything. Obviosly I should have
had a closer look, what you found was exactly what I needed.
Thanks!
- Moritz
------------------------------
Date: Mon, 02 May 2005 15:26:12 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: request uri in CGI module
Message-Id: <3dmo18F6qrignU1@individual.net>
Moritz Karbach wrote:
> I need something similar to the PHP variable $SERVER[REQUEST_URI], that is
> the full string someone entered in his browser, the url and the query.
>
> Is there some easy way to get this?
Yes. In Perl, the environment variables are available in the %ENV hash,
so $ENV{REQUEST_URI} is probably what you want.
To print the whole %ENV hash you can do:
print "$_ = $ENV{$_}\n" for keys %ENV;
HTH
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 02 May 2005 15:25:29 +0300
From: Nikos <hackeras@gmail.com>
Subject: Somethign about hashes
Message-Id: <d5567p$9r6$1@nic.grnet.gr>
while( $row = $sth->fetchrow_hashref )
{
print table( {class=>'user_form'},
Tr(
td( {-width=>'25%'}, {class=>'name'}, $row->{name} ),
td( {-width=>'50%'}, {class=>'email'}, $row->{email} ),
td( {-width=>'25%'}, {class=>'date'}, $row->{date} )
),
{snip more code]
I use the above code when i retrives rows of information from my mysql
database but in the print output a see soemthing like hash(0x0A8B)and
after that the data when what i only want is the actual data itself.
The code is correct but why does those hashed appear?
--
"Of course I cant stop you. And that would really bum me out
if that were my job. But my job isnt to stop you, its to
make it as difficult as possible, for as many as possible,
for as long as possible ."
------------------------------
Date: Mon, 02 May 2005 12:40:32 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: Somethign about hashes
Message-Id: <4dpde.705$31.672@news-server.bigpond.net.au>
"Nikos" <hackeras@gmail.com> wrote in message
news:d5567p$9r6$1@nic.grnet.gr...
: while( $row = $sth->fetchrow_hashref )
: {
: print table( {class=>'user_form'},
:
: Tr(
: td( {-width=>'25%'}, {class=>'name'}, $row->{name} ),
: td( {-width=>'50%'}, {class=>'email'}, $row->{email} ),
: td( {-width=>'25%'}, {class=>'date'}, $row->{date} )
: ),
:
: {snip more code]
:
:
: I use the above code when i retrives rows of information from my mysql
: database but in the print output a see soemthing like hash(0x0A8B)and
: after that the data when what i only want is the actual data itself.
:
: The code is correct but why does those hashed appear?
The output code is wrong. Therefore posting the input code is not much
help.
P
------------------------------
Date: Mon, 02 May 2005 12:46:17 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Somethign about hashes
Message-Id: <117c88pctpslgea@corp.supernews.com>
In article <d5567p$9r6$1@nic.grnet.gr>,
Nikos <hackeras@gmail.com> wrote:
: while( $row = $sth->fetchrow_hashref )
: {
: print table( {class=>'user_form'},
:
: Tr(
: td( {-width=>'25%'}, {class=>'name'}, $row->{name} ),
: td( {-width=>'50%'}, {class=>'email'}, $row->{email} ),
: td( {-width=>'25%'}, {class=>'date'}, $row->{date} )
: ),
:
: {snip more code]
:
: I use the above code when i retrives rows of information from my mysql
: database but in the print output a see soemthing like hash(0x0A8B)and
: after that the data when what i only want is the actual data itself.
:
: The code is correct but why does those hashed appear?
If the code were correct, the hashes wouldn't appear.
The problem with your code is that it has the class attribute values in
separate hashes, but they're supposed to be in a single hash per element
as in the following code:
#! /usr/local/bin/perl
use warnings;
use strict;
package FakeSth;
sub new { bless {} => shift }
{
my $counter;
sub fetchrow_hashref {
return unless $counter++ < 3;
return {
name => "name" . $counter,
email => "email" . $counter,
date => "date" . $counter,
};
}
}
package main;
use CGI qw/ :html /;
my $sth = new FakeSth;
my $row;
while( $row = $sth->fetchrow_hashref )
{
print table( {class=>'user_form'},
Tr(
td( {-width=>'25%', class=>'name'}, $row->{name} ),
td( {-width=>'50%', class=>'email'}, $row->{email} ),
td( {-width=>'25%', class=>'date'}, $row->{date} ),
),
);
}
Hope this helps,
Greg
--
Life, faculties, production -- in other words, individuality, liberty,
property -- this is man. And in spite of the cunning of artful political
leaders, these three gifts from God precede all human legislation, and are
superior to it. -- Frederic Bastiat, *The Law*
------------------------------
Date: Mon, 02 May 2005 16:41:37 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: Somethign about hashes
Message-Id: <d55ame$dsm$1@nic.grnet.gr>
Greg Bacon wrote:
> The problem with your code is that it has the class attribute values in
> separate hashes, but they're supposed to be in a single hash per element
> as in the following code:
Yes that was the mistake. thank you for pinting this out. :-)
--
"Of course I cant stop you. And that would really bum me out
if that were my job. But my job isnt to stop you, its to
make it as difficult as possible, for as many as possible,
for as long as possible ."
------------------------------
Date: Mon, 02 May 2005 16:50:38 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: Somethign about hashes
Message-Id: <d55b7b$ebt$1@nic.grnet.gr>
Maybe you can help me with this too:
print span( {class=>'tip'}, "Some Greek Text!" );
========================
span.tip {
text-align: center;
font: 20px comic;
color: lime;
}
========================
Although i have specified a style and iam using it the print the text
aint being centered.
What am i doing wrong?
--
"Of course I cant stop you. And that would really bum me out
if that were my job. But my job isnt to stop you, its to
make it as difficult as possible, for as many as possible,
for as long as possible ."
------------------------------
Date: Mon, 02 May 2005 15:55:06 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Somethign about hashes
Message-Id: <3dmpndF6spr1vU1@individual.net>
Nikos wrote:
>
> print span( {class=>'tip'}, "Some Greek Text!" );
>
> ========================
> span.tip {
> text-align: center;
> font: 20px comic;
> color: lime;
> }
> ========================
>
> Although i have specified a style and iam using it the print the text
> aint being centered.
>
> What am i doing wrong?
You are using CSS while refusing to study the docs for it.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 02 May 2005 14:11:40 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Somethign about hashes
Message-Id: <Xns964A67975E605asu1cornelledu@127.0.0.1>
Nikos <hackeras@gmail.com> wrote in news:d55b7b$ebt$1@nic.grnet.gr:
> text aint being centered.
It takes exactly as many characters to write "isn't" as it does to type
"ain't".
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
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 8040
***************************************