[16942] in Perl-Users-Digest
Perl-Users Digest, Issue: 4354 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 18 03:05:59 2000
Date: Mon, 18 Sep 2000 00:05:11 -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: <969260710-v9-i4354@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 18 Sep 2000 Volume: 9 Number: 4354
Today's topics:
Re: - Free ebooks and resources - (alex\)
2 Questions <frankie@centurytel.net>
Re: 2 Questions (Logan Shaw)
Re: 2 Questions <dag@orion.no>
Re: find the number of characters in a string (Abigail)
Net::LDAP <quest@powersurfr.com>
Perl and Databases FAQ pohanl@my-deja.com
perl and web daud11@hotmail.com
Re: perl and web <godzilla@stomp.stomp.tokyo>
Piping problems <ksmith@firesnacks.com>
Recursive subroutines not recursing dion@gl.hardnet.com.au
Re: Recursive subroutines not recursing (Abigail)
Re: Recursive subroutines not recursing <anmcguire@ce.mediaone.net>
Re: Regular Expression for matching with email addresse <bart.lateur@skynet.be>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 18 Sep 2000 08:33:33 +0200
From: "javafaq.nu \(alex\)" <nospam@nospam.com>
Subject: Re: - Free ebooks and resources -
Message-Id: <8q4ci9$kju$1@newstoo.ericsson.se>
you can find four free book about Java here:
Thinking in Java
Guide to JINI Technologies
Swing
Introduction to Programming Using Java
http://javafaq.nu/java/index.shtml
--
alex from http://javafaq.nu
daily tips, free books, code, etc.
"John English" <je@bton.ac.uk> wrote in message
news:39BF5EC8.8AC7555C@bton.ac.uk...
> COM Service (webmaster@swap-resources.com) wrote:
> > I would like to know where I can find free ebooks and good resources
> about
> > Java, Perl, Unix, ASP and Visual Basic.
>
> Try http://burks.bton.ac.uk/burks/language/.
>
> -----------------------------------------------------------------
> John English | mailto:je@brighton.ac.uk
> Senior Lecturer | http://www.it.bton.ac.uk/staff/je
> Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS **
> University of Brighton | -- see http://burks.bton.ac.uk
> -----------------------------------------------------------------
------------------------------
Date: Sun, 17 Sep 2000 23:17:18 -0500
From: Frankie <frankie@centurytel.net>
Subject: 2 Questions
Message-Id: <39C5974E.AC51F612@centurytel.net>
My apologies for the cross-post and the broad nature of this question.
I just can't seem to find the info I want via traditional search
engines, including Deja News. And please, no flames. I'm not a newbie
and am aware I'm on thin ice with the cross and the questions. Thanks.
My question is what programming language would you recommend to a
complete beginner in programming? I've extensive background in various
environments, so I'm not going to be terribly uneasy with the comp, I'm
just looking for a good start.
The second, and virtually hand in hand with the first, is where to go
from there and in what sequence. IOW, I'm thinking (just an example)
qbasic to Visual Basic to C to C++ etc? And yes, I'm going to throw in
HTML, but I want to go beyond that.
Again, my apologies if this is an inappropriate post. Or, for that
matter, too broad. Any help will be greatly appreciated. E-mails are
welcome (take the ** out per below) but since I'm posing the question, I
can check all the Groups also. TIA
--
"I do this really moronic thing that the government doesn't want me to
do. It is called thinking" - George Carlin
Remove * * to reply.
-----------------------------------------------------------------------
Pursuant to US Code, Title 47, Chapter 5, Subchapter II, ¢227,
Any and all nonsolicited commercial E-mail sent to this address
is subject to a download and archival fee in the amount of $500.00 US.
E-Mailing denotes the acceptance of these terms
-----------------------------------------------------------------------
------------------------------
Date: 18 Sep 2000 00:36:15 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: 2 Questions
Message-Id: <8q49kf$qc4$1@provolone.cs.utexas.edu>
In article <39C5974E.AC51F612@centurytel.net>,
Frankie <*frankie*@centurytel.net> wrote:
>My question is what programming language would you recommend to a
>complete beginner in programming?
Scheme, or any other language which isn't cluttered up with
convenience features which will only get in the way when you're
trying to learn what programming is about. If you choose to go the
Scheme route, the standard book is "Structure and Interpetation of
Computer Programs" by Abelson and Sussman. Note: the route I am
suggesting is the complete opposite of the cookbook approach.
Instead, it's the grok-the-underlying-concepts approach.
- Logan
------------------------------
Date: Mon, 18 Sep 2000 06:58:27 GMT
From: "Dag Sunde" <dag@orion.no>
Subject: Re: 2 Questions
Message-Id: <n2jx5.1751$X46.277700@juliett.dax.net>
Agree completely with your intentions and arguments,
but my prefered language for teaching programming
and OO principles is Python.
Dag.
"Logan Shaw" <logan@cs.utexas.edu> wrote in message
news:8q49kf$qc4$1@provolone.cs.utexas.edu...
> In article <39C5974E.AC51F612@centurytel.net>,
> Frankie <*frankie*@centurytel.net> wrote:
> >My question is what programming language would you recommend to a
> >complete beginner in programming?
>
> Scheme, or any other language which isn't cluttered up with
> convenience features which will only get in the way when you're
> trying to learn what programming is about. If you choose to go the
> Scheme route, the standard book is "Structure and Interpetation of
> Computer Programs" by Abelson and Sussman. Note: the route I am
> suggesting is the complete opposite of the cookbook approach.
> Instead, it's the grok-the-underlying-concepts approach.
>
> - Logan
------------------------------
Date: 18 Sep 2000 04:57:01 GMT
From: abigail@foad.org (Abigail)
Subject: Re: find the number of characters in a string
Message-Id: <slrn8sb82p.h8o.abigail@alexandra.foad.org>
Bob Walton (bwalton@rochester.rr.com) wrote on MMDLXXV September MCMXCIII
in <URL:news:39C577C6.D8E8DC85@rochester.rr.com>:
$$
$$ Well, actually, if it is the number of *letters* the poster wants:
$$
$$ $number_of_letters=$_=~y/a-zA-Z/a-zA-Z/;
And accented letters aren't letters?
Abigail
--
perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'
------------------------------
Date: Sun, 17 Sep 2000 23:25:45 -0600
From: "Stephane Zanoni" <quest@powersurfr.com>
Subject: Net::LDAP
Message-Id: <8q48v4$ssg$1@dagger.ab.videon.ca>
Has anyone been able to get LDAP working with Windows 2000 Active Directory?
If so lemme know, i'd like to know if it's just my code or not.
Thanks
------------------------------
Date: Mon, 18 Sep 2000 04:33:21 GMT
From: pohanl@my-deja.com
Subject: Perl and Databases FAQ
Message-Id: <8q45uh$9cm$1@nnrp1.deja.com>
The following is a Mini-FAQ on...
Perl and Databases
It is released into the public domain.
=====================================================
1) How Does Perl store information?
=====================================================
1) Perl stores information like any other language,
though file system calls or custom modules that
talk to databases.
As we all know the most common database API is (was?) ODBC,
which provided a level of abstraction for you to talk to many
different types of databases. Basically, how this works is,
you install the ODBC driver on the same machine where your
program is stored (the program that is going to connect to
the database). The database can be located anywhere like
a remote server half way around the world. In order for your
program to talk to the ODBC interface, you must link against
an ODBC header file, or if in Java, use the JDBC api built-in
class files. The ODBC bascially takes your commands and
converts them into calls the database understands.
In Perl, you can either open a file and write to it like any
old programming technique, or you can use some of the built-in
database support, or lastly go for the DBI (an ODBC type of
technology). Perl has built-in support for tied hashes, which
means whenever you change a hash variabled, it is persistently
stored automatically in a database. This is a type of
automatic serialization of variables that can be implemented
in Java or C++.
Tied database uses a special type of database: a hash (key, value)
database. There are built-in support for these in Perl, mainly
DB_File, SDBM_File, etc. There are the two that you should be
aware of. SDBM_File is built into all Perl binaries, so you can
use it if you have Perl. DB_File is sometimes not included, but
it is the only version that supports unlimited Key/Value length.
If you use SDBM_File, if your value exceeds 1024 characters for
any Key, it becomes empty (horrible I know, with no errors).
This is known as the Bucket_size. DB_File support unlimited
characters/value per Key. So if you start playing with tied
hashes, start with SDBM_File, then convert to DB_File when
you need larger storage needs. But before long, you will
find that DB_File is not suitable either, because it has
its own paging cache, and there is no way it can support
concurrent users. It is so unpredictable that you can
corrupt your database just by having multiple perl scripts
write things into the DB_File. Even if you have extensive
locking mechanism, eventually, you database will get corrupted.
What you need is concurrent support with built-in locking.
Most databases these days are separated into two parts, the
Daemon, which is the sole gateway into the data. So two people
wanting to writing things to the data must go through the daemon
(a background process on its own). DB_File and SDBM_File
are basically just files. If you have two perl programs writing
to a file, there is no gateway daemon to schedule the writes,
which will end up clobbering each other as they write to the
database. It is extremely dangerous to write web-cgi applications
using solely a tied hash, as your data will get corrupted in no time
at all. This is an inherent technology problem with SDBM_File and
DB_File.
DB_File is the perl module to access the Berkeley DB version 1.x.
There are newer versions of BerkeleyDB namely 2.x and 3.x.
3.x support concurrent access (writes), but requires setting up
a third virtual memory pool, which you can't do in perl. So
what does this mean? To write any web stuff with multiple
perl scripts sharing a database, you CANT use DB_File, DBM databases,
BerkeleyDB, and the rest. If you know for sure only one script
is going to use the database, and it happens serially, then go ahead,
but otherwise, stay AWAY from tied hashes. Eventually your
database will get corrupted, and there is no current fix.
The third option is to go with a regular database. For these,
Perl comes with DBI, which is like the header file you link
in your C++ programs to call the ODBC driver. It is also like
the Built-in API on java (JDBC api classes). The actual
ODBC library you install on your client is synonymous with a
DBD driver for you database. So if you are using a perl script
or module that needs to store and retrieve data from a database,
then it needs to have a DBI module and the appropriate DBD for
the database installed. There are DBD drivers for Oracle,
mySQL, SqlServer, and many many others. You just need to find
the drivers and install them after installing the DBI module.
You still talk to the database using the database's native
SQL syntax. The DBI/DBD is only an interface to the database's
SQL engine.
mySQL happens to be the fastest database in the world. So I
will concentrate on this database. You can write cross platform
perl code for mySQL (running on linux, windows, etc). but you
must note the differences between mySQL on both of these popular
plateforms.
For linux and unix variants, if you type a show tables,
you will find that the tables are case sensitive when they
are displayed.
If you do this on the windows mysql, they are all in lowercase.
There is a call: show tables like "name".
Which is a way to see if a table exists. Well, in order
for this line of code to work on multiple platforms,
you need to convert all table creation to use lowercase.
I wont go into too much detail, but certain SQL syntax calls in mySQL
are case sensitive and certain calls are not, and in order to
make your code work on both platforms, you need to make ALL
your table names lowercase. Juse do a lc($theTableName) on
all table names in SQL and you should be fine.
As for fields and values in the tables, you can continue using
variable cases, as they should be portable anyways.
One final note: On windows a carriage return is "\r\n", while
in Unix its "\n". If you vi a DOS file in unix you will see
^M that ^M is \r, which Unix doesn't understand.
mySQL runs as a daemon, so it is safe for concurrent users.
you can lock and unlock databases using SQL calls. Most
calls are atomic, and autocommit, so no need to worry about
corruptions.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 18 Sep 2000 05:44:36 GMT
From: daud11@hotmail.com
Subject: perl and web
Message-Id: <8q4a41$dnp$1@nnrp1.deja.com>
Hi
I installed Perl in my windows NT server. I wanted to use it from the
web as a CGI program. At first I got it working ie I was able to
execute it from the web server using http://www..../cgi-bin/script.pl.
Now it is no longer working. When the above url is tested it seems to
download the file. Why? and how do i fix it?
thanks
Daud11
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 17 Sep 2000 23:06:14 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: perl and web
Message-Id: <39C5B0D6.FC3A3E4@stomp.stomp.tokyo>
daud11@hotmail.com wrote:
> I installed Perl in my windows NT server. I wanted
> to use it from the web as a CGI program. At first I
> got it working ie I was able to execute it from the
> web server using http://www..../cgi-bin/script.pl.
> Now it is no longer working. When the above url is
> tested it seems to download the file.
It "seems" to download a file? Strikes me you either
download a file or you don't. This is like saying,
"I seem to be alive but I could be dead."
> Why?
Because you changed something.
> and how do i fix it?
Undo what you changed.
Might be a good idea to check your headers
for a valid content type.
Godzilla!
--
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class
------------------------------
Date: Mon, 18 Sep 2000 05:52:14 GMT
From: "Keith Smith" <ksmith@firesnacks.com>
Subject: Piping problems
Message-Id: <i4ix5.65735$eR5.1675376@news1.rdc1.on.wave.home.com>
Hi folks:
I am trying to pipe some text to my openssl encription util, and then to
sendmail.
Currently, my approach is:
open FD, "|openssl ... |mailer ..." # ... are the arguments to these
commands.
print FD @text;
close FD;
However, when this operation completes, @text seems to never have reached
openssl... its almost like openssl executed immediately without waiting for
a close on FD. Note that performing the same on the command line works fine
(eg. echo 'some text' | openssl ... | mailer ...)
What is the best approach to doing this sort of pipping?
Thanks in advance,
Keith
------------------------------
Date: Mon, 18 Sep 2000 14:17:12 +1000
From: dion@gl.hardnet.com.au
Subject: Recursive subroutines not recursing
Message-Id: <39C59748.F00022FC@hotmail.com>
I have been attempting to write a perl script that takes a directory
name and recursively lists all
files under that path (and directories under that path, and directories
under those directories etc). However, for some reason the recursion
seems not to be working. I have flicked through "Programming Perl" but
not been able to find anything that cautions that you should write
recursive subroutines in any special way as compared to normal
subroutines. Here is the script below:
#this script should take a directory name and return all non-directory
files
#under that directory and all of its subdirectories etc..
#however, for some reason, the recursion is broken so it only returns
files in the
#specified directory, files in the first subdirectory it comes across,
and, incorrectly
#those same files as being in the specified directory (one level up).
if ($ARGV[0] eq "") {
print "Recursive File Lister v1.0 (c) 2000 Dionysus Scripts\n";
print "Usage: perl rlist [path to list files from]\n";
}
print "Listing under $ARGV[0]\n";
@result = rlist("$ARGV[0]");
print "\nResult is: @result\n";
#takes a path, lists all files in that path, runs itself for all
directories in that path
#and adds the files in them to the list.
#
sub rlist
{
my ($path) = @_;
# print "rlisting $path\n";
opendir(CURRENT, "$path") or die "Cannot open dir $path\n";
@possfiles = readdir CURRENT;
print "These files are the potential real files under $path:
@possfiles\n";
foreach $possfile (@possfiles) {
# print "Checking $path\\$possfile\n";
next if (($possfile eq ".") || ($possfile eq ".."));
if (-d "$path\\$possfile") {
print "$path\\$possfile marked as a directory\n";
#if it is a directory
# print "Adding $path\\$possfile\n";
foreach $retfile (rlist("$path\\$possfile")) {
$realfiles[++$#realfiles] = "$path\\$possfile";
}
# @realfiles = arrayAdd(@realfiles, rlist("$path\\$possfile"));
print "realfiles is now @realfiles\n";
}
else {
$realfiles[++$#realfiles] = "$path\\$possfile";
}
}
return @realfiles;
}
I wrote and tested it on a win95 machine, and then when that didn't
work, tried it on my red hat 6.2 machine, and it didn't work there
either....am I missing something stupidly obvious or more subtle? If
anyone can give me any help with this one I would be very much
appreciative.
dal
------------------------------
Date: 18 Sep 2000 05:34:45 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Recursive subroutines not recursing
Message-Id: <slrn8sba9g.h8o.abigail@alexandra.foad.org>
dion@gl.hardnet.com.au (dion@gl.hardnet.com.au) wrote on MMDLXXV
September MCMXCIII in <URL:news:39C59748.F00022FC@hotmail.com>:
// I have been attempting to write a perl script that takes a directory
// name and recursively lists all
// files under that path (and directories under that path, and directories
// under those directories etc).
And the reason you didn't use File::Find is.... ?
// However, for some reason the recursion
// seems not to be working. I have flicked through "Programming Perl" but
// not been able to find anything that cautions that you should write
// recursive subroutines in any special way as compared to normal
// subroutines. Here is the script below:
//
// #this script should take a directory name and return all non-directory
// files
// #under that directory and all of its subdirectories etc..
//
// #however, for some reason, the recursion is broken so it only returns
// files in the
// #specified directory, files in the first subdirectory it comes across,
// and, incorrectly
// #those same files as being in the specified directory (one level up).
//
// if ($ARGV[0] eq "") {
// print "Recursive File Lister v1.0 (c) 2000 Dionysus Scripts\n";
// print "Usage: perl rlist [path to list files from]\n";
// }
"" is a very odd parameter. Perhaps you meant !@ARGV? And perhaps you
should exit after printing a usage message?
// print "Listing under $ARGV[0]\n";
// @result = rlist("$ARGV[0]");
Why the quotes?
// print "\nResult is: @result\n";
//
//
// #takes a path, lists all files in that path, runs itself for all
// directories in that path
// #and adds the files in them to the list.
// #
// sub rlist
// {
// my ($path) = @_;
// # print "rlisting $path\n";
// opendir(CURRENT, "$path") or die "Cannot open dir $path\n";
Why the quotes? And since you are doing recursion, you should localize
your handle, although in this particular case, it should just work out.
// @possfiles = readdir CURRENT;
// print "These files are the potential real files under $path:
// @possfiles\n";
// foreach $possfile (@possfiles) {
// # print "Checking $path\\$possfile\n";
// next if (($possfile eq ".") || ($possfile eq ".."));
// if (-d "$path\\$possfile") {
Use a forward slash, instead of double backwacks.
// print "$path\\$possfile marked as a directory\n";
// #if it is a directory
// # print "Adding $path\\$possfile\n";
// foreach $retfile (rlist("$path\\$possfile")) {
// $realfiles[++$#realfiles] = "$path\\$possfile";
// }
Eh, is this really what you want? If the recursive call returns
10 elements, @realfiles will have the _directory name_ 10 times.
// # @realfiles = arrayAdd(@realfiles, rlist("$path\\$possfile"));
// print "realfiles is now @realfiles\n";
// }
// else {
// $realfiles[++$#realfiles] = "$path\\$possfile";
// }
// }
// return @realfiles;
Well, this is very odd. @realfiles isn't a lexical variable, and you
keep adding to it. Then you return it, and what you return, you add
as well. No wonder it's becoming a mess. Note however that if the tree
doesn't contain any file, @realfiles never, ever, gets populated.
// }
//
//
// I wrote and tested it on a win95 machine, and then when that didn't
// work, tried it on my red hat 6.2 machine, and it didn't work there
// either....am I missing something stupidly obvious or more subtle? If
// anyone can give me any help with this one I would be very much
// appreciative.
Well, "didn't work" is very very vague. What did it do, and what did you
expect it to do? Don't assume this group has the same notion of "doesn't
work" as you do.
Also note that symlinks can make your program loop till it runs out of
memory.
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: Mon, 18 Sep 2000 02:00:10 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Recursive subroutines not recursing
Message-Id: <Pine.LNX.4.21.0009180154070.32211-100000@hawk.ce.mediaone.net>
On Mon, 18 Sep 2000, dion@gl.hardnet.com.au quoth:
> I have been attempting to write a perl script that takes a directory
> name and recursively lists all
> files under that path (and directories under that path, and directories
> under those directories etc). However, for some reason the recursion
> seems not to be working. I have flicked through "Programming Perl" but
> not been able to find anything that cautions that you should write
> recursive subroutines in any special way as compared to normal
> subroutines. Here is the script below:
Judging from your spec, and the comments in your script, I would
instead look into using the File::Find module. You are reinventing
the wheel here.
Regards,
anm
--
# Only works with 'use strict'
foreach (qw~Just another Perl Hacker~) {!$|=~m~\d+~&&
++$.&&eval&&(@$=split?\s{1}?,$@);$@=~s[.*?"(.*?)".*$]
{$.<=3?$1." ":$1."\n"}gmse;$\=$@;local$_="";print if+
!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!1}
------------------------------
Date: Mon, 18 Sep 2000 06:49:55 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Regular Expression for matching with email addresses
Message-Id: <4jebssgtngnc1gmf5178vpq18f1o8q25ac@4ax.com>
Abigail wrote:
>There are no anchors.
Yes of course. That was so obvious that I had forgotten about it after
the first 10 seconds. And, I forgot to mention that. I'll try to make up
for it now.
- to validate an email address, you need anchors. In that case, the
proposed solution would fail.
- to extract the email address, you don't anchor. But the proposed
solution would extract user@domain.co' from 'joe.user@domain.co.uk'.
--
Bart.
------------------------------
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 4354
**************************************