[15745] in Perl-Users-Digest
Perl-Users Digest, Issue: 3158 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 25 06:10:43 2000
Date: Thu, 25 May 2000 03:10:22 -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: <959249421-v9-i3158@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 25 May 2000 Volume: 9 Number: 3158
Today's topics:
Perl and OLE postmaster@bill.co.uk
Re: Perl Editor for Linux <elaine@chaos.wustl.edu>
Re: Perl, system and Cron <elaine@chaos.wustl.edu>
Re: please "grade" my coding skills (Neil Kandalgaonkar)
Re: please "grade" my coding skills <trw@uakron.edu>
Reading XML documents <martin@nospam-.highwaytohell.net>
Re: Reading XML documents <uackermann@orga.com>
Re: Reading XML documents <svenk@tzi.de>
seeking method to encode email addresses in web page fo <btreap@counsel.net>
Re: seeking method to encode email addresses in web pag <godzilla@stomp.stomp.tokyo>
select() function does not work <A.Birkholz@alcatel.de>
Visual Studio Integration <justin@lolofie.com>
Re: Where is the Perl 5.6 bug list? <elaine@chaos.wustl.edu>
Windows NT4.0 / IIS / ActivePerl 5.22 <peter.krauzer@aon.at>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 25 May 2000 09:38:34 GMT
From: postmaster@bill.co.uk
Subject: Perl and OLE
Message-Id: <8gisaq$tm4$1@nnrp1.deja.com>
Hi, I'm using perl under linux and I use sybperl to access
an MS SQL server database. The Tables in the SQL database
are linked into MS Access. A new table has just been created
which has image data. It is an OLE object when viewed in Access
and the users can drop a gif or jpg in the field. When I get the image
out, it has a bunch of OLE stuff (I presume) in front of the image.
I'm not familiar with OLE structures and after looking at them
this morning, I don't think I'm going to be an expert anytime
soon. I also found an OLE perl mod, but it more or less just
seems to deal with the document itself and I've only got a bit
of it out of the database that I really just want to strip the
garbage off of... spose I can try and find some way of searching
for the start of the image, but if there's any better methods
out there, I'd like to know....
Thanks
Bill Dossett
Emtex
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 25 May 2000 05:34:05 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Perl Editor for Linux
Message-Id: <B552338C.4B7A%elaine@chaos.wustl.edu>
in article 8ghahj$qbt$1@nnrp1.deja.com, houseofpain@my-deja.com at
houseofpain@my-deja.com quoth:
> Can anyone recomend a good Perl Editor for Linux. Someting i can use
> to trace through my code.
Try ed.
e.
------------------------------
Date: Thu, 25 May 2000 05:08:20 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Perl, system and Cron
Message-Id: <B5522D83.4B71%elaine@chaos.wustl.edu>
in article 8ggldf$316$1@news.tuwien.ac.at, e8825393 at
e8825393@stud2.tuwien.ac.at quoth:
> everything works fine (from commandline), since I try to run the script from
> Cron, then no changes were made and on trying to debug the script, I found
> out, that the Temp-File is not opened.
Have you tried reading the logs? cron generally logs errors and/or sends
output to the user via mail. Are you running it as the same user as your
cron? What are the permissions on the directory where the tmpfile should be
opened? Have you tried running with -w and possibly Carp?
e.
------------------------------
Date: 25 May 2000 04:58:30 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: please "grade" my coding skills
Message-Id: <8gibtm$usj$1@newsflash.concordia.ca>
In article <8gi4li$1m8$1@kira.cc.uakron.edu>, Todd W <trw@uakron.edu> wrote:
>I had to make sure a date was a valid date without DateCalc. My free web
>host wont install modules by request.
Perl allows you to use modules in any directory.
perldoc lib
Even then... you *have* the source to Date::Calc, you can always rip
out the parts that are useful to you.
>After I finished I thought this might
>be a good snippet of code to see what the more seasoned programmers think.
I'm changing the order of the lines because you tend to interweave
the lines of the code that deal with totally different things.
> #!/usr/local/bin/perl
> use Time::Local;
> use CGI qw/:standard/;
good, although -w and use strict are recommended.
#!/usr/local/bin/perl -w
use strict;
> @date_data = localtime();
> $epoch = timelocal(@date_data);
time() returns the current time in epoch seconds.
> $input{$_} = param("$_") foreach (param);
> @ARGV = ($input{month}, $input{day}, $input{year});
[...]
> ($month, $day, $year) = @ARGV;
You're wasting your time shuffling input out of three different data
structures.
my ($month, $day, $year) =
(param('month'), param('day'), param('year');
Assuming you need the local variables at all.
> eval{$input_epoch = timelocal(0, 0, 0, $day, $month - 1, $year - 1900)};
Okay, this is really just a way of getting Time::Local to do its range
check on your data. Although you will find that Time::Local is rather
lax in what it accepts, it is not really a date checking module.
> # debug date parsing #
> # Printed date should match the one on command line #
>
> @date_check = localtime($input_epoch);
> print "Content-type: text/html\n\nDate is: " . ($date_check[4] + 1) . "." . ($date_check[3]) . "." . ($date_check[5] + 1900) . "<br>\n";
>
> # Check for invalid dates #
You seem to misunderstand the concept of die here. Die is for printing to
STDERR, and usually you want error and output in different file descriptors.
In the case of a CGI script, the usual answer is to use CGI::Carp, which
will print the errors in the returned output as well.
I'm finding the statement-modifier syntax a bit hard to follow, too.
You're allowed to have informative error messages, too. Like "Error: month
$month shouldn't have 31 days."
> die print STDOUT "Expired/Invalid Date error 1\n" if ($@);
> die print STDOUT "Expired/Invalid Date error 2\n" if ($input_epoch < ($epoch -86400));
> die print STDOUT "Expired/Invalid Date error 3\n" if ($month =~ /^[4|6|9|11]/) and ($day == 31);
> die print STDOUT "Expired/Invalid Date error 4\n" if ($year % 4) and ($day > 28);
> die print STDOUT "Expired/Invalid Date error 5\n" if (!($year % 4)) and ($day > 29);
I find some of these checks bewildering. It's not allowed to have a day of
30 when the year is evenly divisible by 4? I think you forgot to add the
condition that the month has to be February. Even then it is still wrong,
it would have failed for the year 2000.
Date checking is better left to specialized modules, it is very easy to
slip up in home-grown code.
The easy way:
make a directory called "/home/myname/mymodules/Date/", or whatever is
convenient.
put Date::Calc into that directory (i.e. Calc.pm)
(or if you have shell access, use the CPAN module, setting PREFIX to be
/home/myname/mymodules).
#!/usr/local/bin/perl -w
use strict;
use lib qw(/home/myname/mymodules/);
use CGI qw(:standard);
use Date::Calc;
print header;
print start_html ("Testing dates");
if ( Date::Calc::check_date(param('year'),param('month'),param('day')) ) {
print "It checks out";
} else {
print "It doesn't";
warn ("Date did not check out!"); # will appear in log file.
}
print end_html;
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: Thu, 25 May 2000 02:05:04 -0400
From: "Todd W" <trw@uakron.edu>
Subject: Re: please "grade" my coding skills
Message-Id: <8gifn3$iaq$1@kira.cc.uakron.edu>
Neil Kandalgaonkar wrote in message <8gibtm$usj$1@newsflash.concordia.ca>...
>In article <8gi4li$1m8$1@kira.cc.uakron.edu>, Todd W <trw@uakron.edu>
wrote:
>
>>I had to make sure a date was a valid date without DateCalc. My free web
>>host wont install modules by request.
>
>Perl allows you to use modules in any directory.
>
>perldoc lib
I was under the assumption that DateCalc needs compiled(im pretty sure i
read that)....no shell access...just ftp
>Even then... you *have* the source to Date::Calc, you can always rip
>out the parts that are useful to you.
I never thought of that, because I thought I wouldnt be able to figure it
out, but now that I think about it, it shouldnt be too hard.
>time() returns the current time in epoch seconds.
That i didnt know
>> $input{$_} = param("$_") foreach (param);
>> @ARGV = ($input{month}, $input{day}, $input{year});
>[...]
>> ($month, $day, $year) = @ARGV;
>
>You're wasting your time shuffling input out of three different data
>structures.
>
> my ($month, $day, $year) =
> (param('month'), param('day'), param('year');
>
>Assuming you need the local variables at all.
I started writing the script to run locally from the command line, but I
understand what you mean.
>> eval{$input_epoch = timelocal(0, 0, 0, $day, $month - 1, $year - 1900)};
>
>Okay, this is really just a way of getting Time::Local to do its range
>check on your data. Although you will find that Time::Local is rather
>lax in what it accepts, it is not really a date checking module.
I did this because the intrepreter gives me "month out of range at line ..."
if $month = 'foo' without the eval. This way the error is trapped in $@. Is
it still not a good idea?
>> die print STDOUT "Expired/Invalid Date error 1\n" if ($@);
>> die print STDOUT "Expired/Invalid Date error 2\n" if ($input_epoch <
($epoch -86400));
>> die print STDOUT "Expired/Invalid Date error 3\n" if ($month =~
/^[4|6|9|11]/) and ($day == 31);
>> die print STDOUT "Expired/Invalid Date error 4\n" if ($year % 4) and
($day > 28);
>> die print STDOUT "Expired/Invalid Date error 5\n" if (!($year % 4)) and
($day > 29);
>
>I find some of these checks bewildering. It's not allowed to have a day of
>30 when the year is evenly divisible by 4? I think you forgot to add the
>condition that the month has to be February. Even then it is still wrong,
>it would have failed for the year 2000.
Your right thats horrible. I got ya though. Its a little more complicated
than the little more complicated that I thought it was =0)
>Date checking is better left to specialized modules, it is very easy to
>slip up in home-grown code.
I will start spending my time figurung out how to reuse stuff thats already
been done instead of reinventing the wheel.
thanks
Todd
------------------------------
Date: Thu, 25 May 2000 10:45:22 +0200
From: Martin Askestad <martin@nospam-.highwaytohell.net>
Subject: Reading XML documents
Message-Id: <392CE822.E6A8C8D4@nospam-.highwaytohell.net>
Hi
I'm trying to parse a XML document with Perl on a WindowsNT machine. Do
I have to download some kind of module to do that. I'm having trouble
with splitting the tags and getting the contents of them.
Martin.
------------------------------
Date: Thu, 25 May 2000 11:01:13 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: Reading XML documents
Message-Id: <392CEBD9.665C2A5E@orga.com>
Martin Askestad wrote:
>
> Hi
>
> I'm trying to parse a XML document with Perl on a WindowsNT machine. Do
> I have to download some kind of module to do that. I'm having trouble
> with splitting the tags and getting the contents of them.
>
> Martin.
There is an article about that at www.perl.com. There is the module
XML::Parser mentioned.
HTH
Ulrich
--
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925
mailto:uackermann@orga.com
------------------------------
Date: Thu, 25 May 2000 11:09:57 +0200
From: "Sven Kuenzler" <svenk@tzi.de>
Subject: Re: Reading XML documents
Message-Id: <8giqlr$c3$1@kohl.informatik.uni-bremen.de>
> I'm trying to parse a XML document with Perl on a WindowsNT machine. Do
> I have to download some kind of module to do that. I'm having trouble
> with splitting the tags and getting the contents of them.
There is a XML::Parser module available from CPAN.
Sven....
------------------------------
Date: Thu, 25 May 2000 07:27:38 GMT
From: Bob Reap <btreap@counsel.net>
Subject: seeking method to encode email addresses in web page forms
Message-Id: <392CD5B9.66187366@counsel.net>
Hi all,
I have a simple Perl chatboard I've created and I noticed that the email
addresses are getting farmed by spammers. I've put up wPoison, but to
really protect the users' privacy I want to switch to a system where all
email is sent to the original poster via a form resident on my site.
My question: is there an easy way to encode the email addresses in the
chatboard script so that my mail-to-poster form can just as easily
decode the address, yet keep most spider's and curious (and clever)
folks from figuring out what the email address is?
I understand that PGP will encrypt stuff but I don't think I need that
level of protection, and I don't really have the skills to get that
running. Could I just craft some type of translation/substitution code
in Perl to stash the address in the form and then have the mail form
decode it back?
Thanks for your help -- please cc: any responses to me at
btreap@counsel.net!
:o)
Bob Reap
San Diego, CA
==
------------------------------
Date: Thu, 25 May 2000 02:19:24 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: seeking method to encode email addresses in web page forms
Message-Id: <392CF01C.BE324457@stomp.stomp.tokyo>
Bob Reap wrote:
(some snippage)
> My question: is there an easy way to encode the email addresses in the
> chatboard script so that my mail-to-poster form can just as easily
> decode the address, yet keep most spider's and curious (and clever)
> folks from figuring out what the email address is?
> I understand that PGP will encrypt stuff but I don't think I need that
> level of protection, and I don't really have the skills to get that
> running. Could I just craft some type of translation/substitution code
> in Perl to stash the address in the form and then have the mail form
> decode it back?
Good Day Bob,
Looking at this realistically, chances are pretty
good human eyes will never see your email address.
Robotic eyes, certainly.
Why I say this is most spider bots harvest thousands
of email addresses, both from USENET and Internet Sites.
It is unrealistic to expect some jerk spammer to sit
and graze through thousands of email addresses trying
to spot bad addresses. It is realistic to assume some
run programs to try and decode 'munged' addresses such
as mine for this article. Good luck. Nonetheless, there
is some success at removing common anti-spam words,
such as 'invalid', 'nospam', 'remove' and similar.
So, in a practical sense, you really don't need to
use PGP or even Perl's encrypt module. You just need
to defeat robots and common decoding methods. Security
is not truly your issue, defeating robots is.
Here are four methods I tossed together for you. First
one is very standard ROT-13 encoding, which simply shifts
your alphabet over 13 letters. Most likely, there are
bots / programs out there which decode this. Probably
not your best choice but shows how it is done.
Second method is a mimic of ROT-13 but with a bit of
a twist. I doubt robots would have much luck decoding
this, not without some human help. Chances are good
an email with this encoding would kicked as a bad.
Look over the code, you will see how I shifted some
letters much like ROT-13 does.
Method four is HEX encoding. I kinda think there might
be some robots out there which decode hex. Maybe not
a lot but I wouldn't be surprised to learn they exist.
Security, I dunno, mostly personal opinion on this one.
Last method, number five, would kick butt on most robots.
It is a combination of method two and hex encoding. I think
this one would be frustrating to figure out, least for
stupid spammers with little patience.
All of these can be cracked of course. Still, you are
dealing with robots for the most part, dealing with
spammers who are not rocket scientists and, dealing
with people interested in harvesting gross amounts of
email addresses rather than spending an hour, a day,
trying to crack just one. Odds are in your favor not
so much by security but rather by 'frustration'.
You can include a 'robot.txt' to keep many bots out,
but not all certainly. Here is an example:
<META NAME="robots" CONTENT="noindex,nofollow">
This fits between </TITLE> and </HEAD> for your
html header information.
There is one last method which I wish I could
discuss in detail. You can kill robots, I mean
literally kill them. This would be a fun topic.
However, methods used to kill robots can also
be used to kill cyber people, that is, crash
a person's system / browser. Some of these
methods are very harsh. Probably wouldn't be
a good idea to talk about such stuff publically.
My printed results are first, my test script is
last. I hope this gives you some ideas and help.
I would give you my email address but I hate spam.
Heh!
Godzilla!
PRINTED RESULTS
_______________
Method One, ROT-13:
Method One, encode: pnyytvey@yn.marg.pbz
Method One, decode: callgirl@la.znet.com
Method Two, Custom:
Method Two, encode: usddyajd@ds.rfwl.uge
Method Two, decode: callgirl@la.znet.com
Method Three, HEX:
Method Three, encode: 63616c6c6769726c406c612e7a6e65742e636f6d
Method Three, decode: callgirl@la.znet.com
Method Four, Custom HEX:
Method Four, encode: 7573646479616a644064732e7266776c2e756765
Method Four, decode: callgirl@la.znet.com
Godzilla Rocks!
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type:text/plain\n\n";
$email = "callgirl\@la.znet.com";
print "Method One, ROT-13: \n\n";
# encode:
$email =~ tr/a-zA-Z/n-za-mN-ZA-M/;
print "Method One, encode: $email \n";
# decode:
$email =~ tr/a-zA-Z/n-za-mN-ZA-M/;
print "Method One, decode: $email \n\n";
print "Method Two, Custom:\n\n";
# encode:
$email =~ tr/a-zA-Z/s-za-rS-ZA-R/;
print "Method Two, encode: $email \n";
# decode:
$email =~ tr/s-za-rS-ZA-R/a-zA-Z/;
print "Method Two, decode: $email \n\n";
print "Method Three, HEX: \n\n";
# encode:
$email =~ s/(.)/ sprintf('%02x',ord($1)) /ge ;
print "Method Three, encode: $email \n";
# decode:
$email =~ s/([0-9A-Fa-f]{2})/ sprintf("%c",hex($1)) /ge ;
print "Method Three, decode: $email \n\n";
print "Method Four, Custom HEX: \n\n";
# encode:
$email =~ tr/a-zA-Z/s-za-rS-ZA-R/;
$email =~ s/(.)/ sprintf('%02x',ord($1)) /ge ;
print "Method Four, encode: $email \n";
# decode:
$email =~ s/([0-9A-Fa-f]{2})/ sprintf("%c",hex($1)) /ge ;
$email =~ tr/s-za-rS-ZA-R/a-zA-Z/;
print "Method Four, decode: $email \n\n";
print "
Godzilla Rocks!";
------------------------------
Date: Thu, 25 May 2000 11:38:04 +0200
From: Andreas Birkholz <A.Birkholz@alcatel.de>
Subject: select() function does not work
Message-Id: <392CF47C.2E187CC3@alcatel.de>
Hello,
I tried the select function and it worked not in that way as described
in the perldoc.
My scenario:
$logfile="hilti.log";
open (HILTI,"<$logfile") || die "Could not open $logfile\n";
while (TRUE) {
#prepare for select command
$rin='';
vec($rin,fileno(HILTI),1)=1;
#wait for selected
$nfound=select($rin,undef,undef,undef);
while (<HILTI>) {
#read something from the file
}
}
The HILTI file grows from time to time.
Referring to perldoc the select function should set the process to
status "sleeping" but if I look it up with "top" then this script
occupies nearly all cpu time (about 97%). That's wrong, isn't it?
I tried it on Solaris 2.6 and Linux SuSE 6.3 with Perl 5.005_02.
Regards,
Andreas Birkholz
------------------------------
Date: Thu, 25 May 2000 01:04:46 -0700
From: "Justin" <justin@lolofie.com>
Subject: Visual Studio Integration
Message-Id: <sipnhp26o1185@corp.supernews.com>
I realize all I can get is speculation at best, but does anyone know the
details on what Visual Perl will be exactly? Will it be a full component of
visual studio 7 like visual c++ and visual basic are in vs6? I am just
wondering if it will be some kind of web-monkey interface that has a tab on
the bottom that displays your perl as if it were in a web browser. :)
Also, on a completely unrelated thought(and irrelevant for that matter)-
does anyone know what is up with activestate's new communist-web-theme? :)
------------------------------
Date: Thu, 25 May 2000 04:56:49 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Where is the Perl 5.6 bug list?
Message-Id: <B5522ACE.4B70%elaine@chaos.wustl.edu>
in article 392C8B78.EB740842@rcisd.com, chuck at cgoehring@rcisd.com quoth:
> I found this one. Don't know if there are others.
>
> bugs.activestate.com
http://bugs.perl.org/
and the p5p archive is a good place to check as well
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/
e.
------------------------------
Date: Thu, 25 May 2000 10:54:36 +0200
From: "Peter Krauzer" <peter.krauzer@aon.at>
Subject: Windows NT4.0 / IIS / ActivePerl 5.22
Message-Id: <959245061.861891@newsmaster-04.atnet.at>
Maybe anyone can help.
I am runnning ActiveState Perl 5.22 under Windows NT with IIS4. My problem
is, that all my scripts are working fine most of the time. But sometimes I
recieve instead of the script output the source code of my scripts.
Any idea whats wrong with my configuration?
Thanks
:-) Peter
------------------------------
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 3158
**************************************