[11714] in Perl-Users-Digest
Perl-Users Digest, Issue: 5314 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 6 20:27:24 1999
Date: Tue, 6 Apr 99 17:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 6 Apr 1999 Volume: 8 Number: 5314
Today's topics:
Re: "chmod g+s" and $0 Problem (brian d foy)
Re: absolute path to the running script? <juex@my-dejanews.com>
Re: Accessing MS Access with perl <jwarner@tivoli.com>
Re: an IDE for perl program developing <cassell@mail.cor.epa.gov>
Re: chmod - setting permissions with perl? <cassell@mail.cor.epa.gov>
duplicate checker <SPAMBLOCKsurgie@bellsouth.net>
Re: duplicate checker (Andrew Allen)
Re: duplicate checker (Larry Rosler)
Re: duplicate checker <cassell@mail.cor.epa.gov>
Re: Hash help <cassell@mail.cor.epa.gov>
Re: How to handle a ctrl-C interupt ? <cassell@mail.cor.epa.gov>
Re: is there any ceiling function in perl? (Larry Rosler)
Re: leap year? (I R A Aggie)
Re: leap year? <cassell@mail.cor.epa.gov>
Re: leap year? (Larry Rosler)
Re: leap year? <cassell@mail.cor.epa.gov>
Re: leap year? (Larry Rosler)
Most elegant random string generator? <gregm@well.com>
Re: No clues to Win32::NetResource problem? <gehring@politik.uni-mainz.de>
Re: Perl as a first programming language - suitability, <jeff@co.mendocino.ca.us>
Re: Perl as a first programming language - suitability, (Larry Rosler)
Re: Perl as a first programming language - suitability, <cassell@mail.cor.epa.gov>
Perl for SunOS 4.1 wingo01@my-dejanews.com
Perlshop "missing file title" error <awajda@limbo.ne.mediaone.net>
Q - Mail::Header Module <tavi367@ibm.net>
regexp matching digits <frf@energyinteractive.com>
Re: Regular Expression <cassell@mail.cor.epa.gov>
Re: setting env variables, sourcing, etc. <cassell@mail.cor.epa.gov>
Thanx! (waas Re: Q: explain me "=") <eveelo@artcenter.edu>
typeglobs and strict....simple qn. bhaskaracharya@my-dejanews.com
Re: Unpack Question <cassell@mail.cor.epa.gov>
Re: Very large regular expressions <rick.delaney@home.com>
Re: Where can i find Net::SMTP module? <ebohlman@netcom.com>
Re: Which text editor should I use <cassell@mail.cor.epa.gov>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 06 Apr 1999 18:08:35 -0400
From: brian@pm.org (brian d foy)
Subject: Re: "chmod g+s" and $0 Problem
Message-Id: <brian-ya02408000R0604991808350001@news.panix.com>
In article <370A1DC1.C32F661F@ndh.net>, Nabil Edelbi <edelbi@ndh.net> posted:
> #!/usr/local/bin/perl
>
> print "$0\n";
> [world:/home/ne] (root) : ./x.pl
> ./x.pl
> [world:/home/ne] (root) : chmod g+s x.pl
> [world:/home/ne] (root) : ./x.pl
> /dev/fd/4
that's a security feature.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: Tue, 6 Apr 1999 15:42:21 -0700
From: "J|rgen Exner" <juex@my-dejanews.com>
Subject: Re: absolute path to the running script?
Message-Id: <7ee2io$qgv@news.dns.microsoft.com>
Dale Henderson <dhenders@cpsgroup.com> wrote in message
news:87bth1twxm.fsf@camel.cpsgroup.com...
>
>
> I'm trying (unsucessfully) to find the absolute pathname within a
> running script $0 contains the name the script was called as
> (e.g. ./foo perl/foo etc).
>
> Is there any way to easily retrieve the absolute pathname in a running
> process?
As pointed out in the UNIX FAQ this is not possible.
Just imagine that the script could have been deleted _after_ it's execution
started.
jue
--
J|rgen Exner
------------------------------
Date: Tue, 06 Apr 1999 15:18:31 -0500
From: John Warner <jwarner@tivoli.com>
Subject: Re: Accessing MS Access with perl
Message-Id: <370A6C17.F9D479BD@tivoli.com>
Actually, getting the DBI modules to work from a Unix box to an MS server is
just like working with any other DBD module. The important key is setting
up the equivalent of a System DSN on your Linux box that points to the MS
server. (Not that I know how to do that--it's always been done by someone
else ahead of me...anyone?) Once the DSN is defined, you should be off to
the races.
Greg Griffiths wrote:
> I suggest that you take a look at DBI as you are running on a Linux
> server, although if you can get a windows server running take a look at
> ODBC.pm from http://www.roth.net/odbc/ although I'm quite sceptical
> about getting an MS Access db to run under a unix like environment.
> either convert your DB or your server is probably the best bet, although
> give it a try first, as I know that Access & Unix don't mix, although I
> assume that includes Linux ?!
>
> Patrick wrote:
> >
> > Hi,
> >
> > Can someone tell me how to read a ms-access database with perl on a
> > Linux (redhat 5.1) server.
> >
> > Thank,
> > Patrick G.
--
John Warner Tivoli Systems Inc.
Sales Support Engineer 9442 Capital Of Texas Hwy North
Sales Infrastructure Group Austin, TX 78759
john_warner@tivoli.com
------------------------------
Date: Tue, 06 Apr 1999 15:43:48 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
To: David Delikat <ddelikat@protix.com>
Subject: Re: an IDE for perl program developing
Message-Id: <370A8E24.5702055E@mail.cor.epa.gov>
David Delikat wrote:
>
> David L. Cassell wrote:
> >
> > Perl doesn't have the
> > write-compile-link-curse-debug cycle of C, so some of the
> > features of an IDE aren't needed.
> >
>
> I occasionally have to convince people(bosses) that perl is
> a good resource, and I was wondering if I could quote you.
Feel free. I've always wanted to see my name up in lights.
> -dav
>
> --
> <((((><
> Consultant: Internet, Database, Business Systems
> Unix/Linux, Windows95/NT
> mailto:david-delikat@usa.net / http://obj.webjump.com/
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 06 Apr 1999 16:06:48 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: chmod - setting permissions with perl?
Message-Id: <370A9388.DEDE6D0E@mail.cor.epa.gov>
brian d foy wrote:
>
> In article <370A592F.1076C27F@mail.cor.epa.gov>, "David L. Cassell" <cassell@mail.cor.epa.gov> posted:
>
> > Tom Kralidis wrote:
> > >
> > > You can try
> > >
> > > system("chmod 755 ../test/jpg");
> >
> > Well, you can *try* it, but you might not like the results.
> > Perl will read 755 as decimal, not octal. Put the '0' back
> > in front of the '755' and Perl (and you) will be happier.
>
> chmod doesn't care - remember that *that* chmod isn't Perl ;)
DOH! There I was, off on chmod(), and the question was
on system(). Well, someday I'll hit the target. Of course,
as a statistician, I only have to produce a scatter which is
unbiased... :-)
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 06 Apr 1999 22:09:40 GMT
From: "Surgie" <SPAMBLOCKsurgie@bellsouth.net>
Subject: duplicate checker
Message-Id: <ECvO2.4381$gv2.867068@news2.mco>
I'm wondering if there was a built-in perl function to check if 2 arrays
have any of the same entries, and if not if anyone has a good function I
could use?
eg.
@array1 = ('cat','food','dog');
@array2 = ('cat','cow','ship');
and it would tell me there was a duplicate (return false, true, whatever)
------------------------------
Date: 6 Apr 1999 23:04:02 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: duplicate checker
Message-Id: <7ee3t2$hdu$1@fcnews.fc.hp.com>
Surgie (SPAMBLOCKsurgie@bellsouth.net) wrote:
: I'm wondering if there was a built-in perl function to check if 2 arrays
: have any of the same entries, and if not if anyone has a good function I
: could use?
: eg.
: @array1 = ('cat','food','dog');
: @array2 = ('cat','cow','ship');
How about:
my %t;
@t{@array1}=(1)x@array1;
print "duplicate" if grep(exists $t{$_},@array2);
or
print "duplicate" if grep {my $a=$_; grep($a eq $_,@array1)} @array2;
or even
my %t=(@array1,reverse @array1);
my %s=(@array2,reverse @array2);
my %r=(%t,%s);
print "duplicate" unless keys(%r)==keys(%t)+keys(%s);
Andrew
------------------------------
Date: Tue, 6 Apr 1999 16:26:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: duplicate checker
Message-Id: <MPG.117437f1539d8c92989853@nntp.hpl.hp.com>
In article <ECvO2.4381$gv2.867068@news2.mco> on Tue, 06 Apr 1999
22:09:40 GMT, Surgie <SPAMBLOCKsurgie@bellsouth.net> says...
> I'm wondering if there was a built-in perl function to check if 2 arrays
> have any of the same entries, and if not if anyone has a good function I
> could use?
>
> eg.
>
> @array1 = ('cat','food','dog');
> @array2 = ('cat','cow','ship');
>
> and it would tell me there was a duplicate (return false, true, whatever)
perlfaq4: "How do I compute the difference of two arrays? How do I
compute the intersection of two arrays?"
What you are asking is if the intersection of the two arrays is not
null.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 06 Apr 1999 17:00:01 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: duplicate checker
Message-Id: <370AA001.11747E2F@mail.cor.epa.gov>
Surgie wrote:
>
> I'm wondering if there was a built-in perl function to check if 2 arrays
> have any of the same entries, and if not if anyone has a good function I
> could use?
>
> eg.
>
> @array1 = ('cat','food','dog');
> @array2 = ('cat','cow','ship');
>
> and it would tell me there was a duplicate (return false, true, whatever)
You want the intersection of two arrays. At the command line,
type 'perldoc -q intersection' and get the FAQ for this question:
"How do I compute the difference of two arrays? How do I compute
the intersection of two arrays?"
perldoc is worth learning to use. You'll always be happier
finding your own answers in a second, rather than waiting hours
to have some jerk just say "At the command line, type 'perldoc -q
intersection'." :-)
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 06 Apr 1999 16:43:00 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
To: John Christena <john.christena@tivoli.com>
Subject: Re: Hash help
Message-Id: <370A9C04.80A19228@mail.cor.epa.gov>
John Christena wrote:
>
> Hello. I have a hash that contains several scalar variables. I want to
> reference members of this hash and have the value of the scalar
> interpreted. Is this possible?
If I understand your question, yes. Sort of. Maybe you'd better
read what I have to say below.
> Such as:
>
> $varname="list"
> $hashname{$varname}=?
Umm, this really isn't what you want to do. A hash is an
associative array. It is a set of key/value pairs. And using
it properly is a much better idea than trying to squeeze in
what looks like symbolic references.
> I would like the hash to point to the variable $varname and be
> recognized as that variable with the value of $varname.
Like this?
%property = (
fred => 'fat',
barney => 'short',
wilma => 'cute',
dino => 'irritating'
);
$name = 'Fred';
print "$name is $property{$name} \n";
The => operator is just a fancy comma, but it improves readability.
For me, anyway.
> Any hints are
> appreciated.. Thx.
>
> Please respond to john.christena@tivoli.com
Another hint: I think you need to re-read the perldata section
until you have a better grasp of how hashes work. This is
important stuff, and one of the central features of Perl.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 06 Apr 1999 15:46:56 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: How to handle a ctrl-C interupt ?
Message-Id: <370A8EE0.F98AFBAC@mail.cor.epa.gov>
Ala Qumsieh wrote:
>
> Wim Janssen <janssen@caos.kun.nl> writes:
>
> > Lectori Salutem,
>
> er .. yeah .. same to you.
At least he didn't write "morituri te salutamus". :-)
>
> > How do I handle an interupt like ctrl-C in a perl-script.
>
> I just answered that same question (asked by someone else). Basically,
> read the entry for %SIG in perlvar, read perlipc, read sigtrap.
And try 'perldoc -q signals' to learn that it is in the FAQ
(and how to do it).
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 6 Apr 1999 15:13:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: is there any ceiling function in perl?
Message-Id: <MPG.117426cef9ca00d998984f@nntp.hpl.hp.com>
In article <7edc1u$4hv$1@nnrp1.dejanews.com> on Tue, 06 Apr 1999
16:17:08 GMT, Don Roby <droby@copyright.com> says...
...
> I also did a benchmark. POSIX wins, which doesn't surprise me a bit, and
> Larry's corrected version beats mine, which is also unsurprising. I didn't
> make and benchmark a corrected version of Samuel's, but I assume it would work
> out similarly to Larry's. Multiplication by booleans is not efficient.
The POSIX module calls the functions in the C library.
Isn't the issue of perl performance here simply a matter of how many
perl-ops it takes to implement the algorithm? Fewer is better, which is
why using the numeric value of a Boolean returned by the compiler (1 or
0) should be best, rather than doing it explicitly by a '? 1 : 0'.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 6 Apr 1999 21:59:26 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: leap year?
Message-Id: <slrn7gl12s.kr.fl_aggie@stat.fsu.edu>
On Tue, 06 Apr 1999 13:35:29 -0400, Jay Glascoe <jglascoe@giss.nasa.gov> wrote:
+ # based upon Abigail's profound idea that a
+ # year is a is a leap year if, and only if,
+ # February is 29 days long
<sound of hand smacking forehead> D0H!
James - D0H!
------------------------------
Date: Tue, 06 Apr 1999 15:21:55 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: leap year?
Message-Id: <370A8903.F8EACF25@mail.cor.epa.gov>
Tramm Hudson wrote:
>
> In article <370A64D9.D74E83AB@mail.cor.epa.gov>,
> David L. Cassell <cassell@mail.cor.epa.gov> wrote:
> > Actually, this is a FAQ.. just not in Perl. But it's in the
> > comp.lang.c FAQ if that's any help.
> >
> > Just check:
> > year divisble by 4? then yes
> > year divisible by 100? then no
> > year divisible by 400? then yes
>
> I guess I'll have to cancel all of my appointments for 29 Feb 2000
> then since 2000 is divisible by 100. No, wait! 2000 is divisible by
> four, as is 2100. So I'll have to get ready for 29 Feb 2100.
> Dang it! Where is my calendar?
Well-written advice, huh? Worth every penny, too. :-)
> Just for reference, the comp.lang.c faq available at
>
> ftp://rtfm.mit.edu/pub/faqs/C-faq/faq
Thanx. I was too durn lazy to find the URL for my post.
> states in Q20.32 (Is 2000 a leap year?):
>
> year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
>
> So now someone has to ask how to write a version of this
> test in Perl...
Someone already has. I think it was Jay, just about two
or three weeks ago...
> > [Note first make sure to add 1900 to the $year variable if it
> > is coming from the C struct tm or from localtime() .]
>
> Now that is good advice. The FAQ for cl.c states that C does not
> have any year 2000 problems, but poorly written C programs might.
Ssshhhhh... Or else Russell Schulz will join the thread. :-)
> Tramm
> --
> o hudson@swcp.com tbhudso@cs.sandia.gov O___|
> /|\ http://www.swcp.com/~hudson/ H 505.266.59.96 /\ \_
> << KC5RNF @ N5YYF.NM.AMPR.ORG W 505.284.24.32 \ \/\_\
> 0 U \_ |
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 6 Apr 1999 15:18:02 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: leap year?
Message-Id: <MPG.117427f099033500989850@nntp.hpl.hp.com>
In article <7edu93$m7t$1@client2.news.psi.net> on 6 Apr 1999 21:28:03
GMT, Abigail <abigail@fnx.com> says...
...
> But that requires another module, and hence slows down your program
> due to extra compilation.
...
> Note that this subroutime might be wrong if called a few microseconds
> before the new year.
April 1 seems to have come late, this year.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 06 Apr 1999 15:25:06 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: leap year?
Message-Id: <370A89C2.7F5B8BDE@mail.cor.epa.gov>
Larry Rosler wrote:
>
> In article <370A64D9.D74E83AB@mail.cor.epa.gov> on Tue, 06 Apr 1999
> 12:47:37 -0700, David L. Cassell <cassell@mail.cor.epa.gov> says...
> > du_bing@my-dejanews.com wrote:
> > > How to judge if the current year is a leap year or not in Perl? There should
> > > be a formula. Unfortunately I forgot.
> ...
> > Actually, this is a FAQ.. just not in Perl. But it's in the
> > comp.lang.c FAQ if that's any help.
> >
> > Just check:
> > year divisble by 4? then yes
> > year divisible by 100? then no
> > year divisible by 400? then yes
>
> Those three checks are in the wrong order.
Yes. And really well-defined as a flowchart too.
> But reversing the order is
> less efficient than doing them in that order, but with more elaborate
> logic than 'yes' if the first test succeeds.
Definitely. That's what I had in mind. If you can call
something that writes pseudo-code like that a 'mind'.
> However, your submission won for me a private bet I made that at least
> one person would publish the three-mods approach.
Glad to help. Hope it was worth plenty of beer^H^H^H^H chocolate.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 6 Apr 1999 16:06:04 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: leap year?
Message-Id: <MPG.117433365f81c347989851@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <370A8903.F8EACF25@mail.cor.epa.gov> on Tue, 06 Apr 1999
15:21:55 -0700, David L. Cassell <cassell@mail.cor.epa.gov> says...
> Tramm Hudson wrote:
...
> > year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)
> >
> > So now someone has to ask how to write a version of this
> > test in Perl...
>
> Someone already has. I think it was Jay, just about two
> or three weeks ago...
This thread has reached the point that there's no way of telling who is
kidding whom, or why!
$_ = 'year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)';
s/year/\$year/g;
my $year = 2000;
my $is_a_leap_year = eval;
might do it. Maybe I should patent my C-to-Perl translator...
And, from another part of the thread:
In article <370A89C2.7F5B8BDE@mail.cor.epa.gov> on Tue, 06 Apr 1999
15:25:06 -0700, David L. Cassell <cassell@mail.cor.epa.gov> says...
...
> Glad to help. Hope it was worth plenty of beer^H^H^H^H chocolate.
How did you know? Thanks.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 06 Apr 1999 16:42:58 -0700
From: Greg McCann <gregm@well.com>
Subject: Most elegant random string generator?
Message-Id: <370A9C02.DD16F793@well.com>
The following simple program generates a random string of characters
(it's being used as a session ID in a web application). It works well,
but being new to Perl I'm wondering if there is a more efficient and/or
elegant way of doing this - without being TOO obfuscatory!
(BTW, a simple chr(rand $something + $something_else) does NOT work
because digits, l.c. alpha, and u.c. alpha are not consecutive in ASCII)
#!/usr/local/bin/perl -w
use strict;
my @charlist; # chars to use in random string
my $random_string; # string of random chars
my $number_of_chars = 20; # final length of string
my $i; # loop counter
@charlist = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
for ($i = 0; $i < $number_of_chars; $i++) {$random_string .=
$charlist[rand 62]}
print $random_string;
--
======================
Gregory McCann
http://www.calypteanna.com
"Be kind, for everyone you meet is fighting a great battle." Saint
Philo of Alexandria
------------------------------
Date: Tue, 06 Apr 1999 23:56:22 +0200
From: "Uwe W. Gehring" <gehring@politik.uni-mainz.de>
Subject: Re: No clues to Win32::NetResource problem?
Message-Id: <370A8306.E45011B1@politik.uni-mainz.de>
Dave Roth schrieb:
>
> Try specifing the machine name (even if the share is local):
> Win32::NetResource::NetShareGetInfo( $myshare, \%share_info, $machine )
>
> Whenever I run this function on my NT server with less than three
> parameters I get a runtime exception and Perl pukes (ActiveState build
> 509).
> Your function is correct, it looks like there may be a bug in
> Win32::NetResource.
>
Does not help. The following modification:
$server = Win32::AdminMisc::GetPDC($domain);
Win32::NetResource::NetShareGetInfo($myshare,\%share_info,$server)
|| die "Unable to get share information\n";
brings neither the desired output nor an error message (not even with
diag. and -w).
--
Sincerely
Uwe W. Gehring
Research Assistant
****************************************************
University of Mainz - Institute of Political Science
Saarstr. 21 55099 Mainz Germany
Tel.: +49 6131 39-5485 Fax: +49 6131 39-2996
E-Mail: gehring@politik.uni-mainz.de
WWW: http://www.uni-mainz.de/~gehring
****************************************************
------------------------------
Date: Tue, 6 Apr 1999 15:30:03 -0700
From: "Jeff Kirk" <jeff@co.mendocino.ca.us>
Subject: Re: Perl as a first programming language - suitability, good books ?
Message-Id: <7ee23c$e6p$1@ultra.sonic.net>
Jonathan,
O'Reilly is the place to go. The Camel book and the Ram book are
indespensible.
http://perl.oreilly.com/
Jeff
Jonathan <jonathan@meanwhile.freeserve.co.uk> wrote in message
news:7edtvp$v10$1@news4.svr.pol.co.uk...
> A friend of mine from an arts background is interested in learning to
> program, partly from intellectual curiousity and partly for career
reasons.
> She's extremely smart and a great problem solver, but she's never written
a
> program in any language. Until recently I didn't know what language to
> suggest to her - Basic's too ugly, Pascal is a dead end. And definitely
not
> C++ (although it's what I do half my work in myself - my other languguage
is
> Masm, which I felt was *almost* as inappropriate.) I was thinking maybe
> you-know-what, but last week I started to learn Perl.
>
> I finished writing my first production program the other day, a tool that
> assembles local chunks of data into a meshed description of 3D data. Now
I'm
> in love with the language and recommending it to all my C++ programmer
> friends. The normal response is "I thought it was just a text manipulation
> language." I've found that the most effective response is to tell them
that
> Perl supports dynamic inheritance - C++ programmers have a lot respect for
a
> language that has a feature that C++ lacks (with good reason.)
>
> I know that Perl is usually a second or third language, and is mostly used
> by hardcore programmers, but I'm sure that Larry Wall didn't mean it that
> way and that it doesn't have to be that way. Perl has a lot of great
> features for first-timers - notably a long, gentle learning curve. (I
think
> dynamc inheritance is probably the thing I'll leave until last.) I was
> wondering if anyone has any experience of learning Perl as a first
language
> ?
>
> But most important of all, I was wondering if anyone could recommend a
Perl
> book aimed at people like my friend ? Something that explains what an
array
> is, what a sort is, even what an interpreter is ? (I'm too far away from
her
> to make giving lessons easy and she's the sort of person who takes this
> stuff better from books.) I know that there's a Perl For Dummies book, but
> the reviews at Amazon were lukewarm - in particular it seemed to lack
> examples. Once she gets a start she can switch to one of the Learning Perl
> books.
>
> I'd be grateful for any suggestions.
>
> Jonathan Coupe
>
>
------------------------------
Date: Tue, 6 Apr 1999 16:19:36 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl as a first programming language - suitability, good books ?
Message-Id: <MPG.11743667a17dd632989852@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7ee23c$e6p$1@ultra.sonic.net> on Tue, 6 Apr 1999 15:30:03 -
0700, Jeff Kirk <jeff@co.mendocino.ca.us> says...
> Jonathan <jonathan@meanwhile.freeserve.co.uk> wrote in message
> news:7edtvp$v10$1@news4.svr.pol.co.uk...
...
> > But most important of all, I was wondering if anyone could recommend a
> > Perl book aimed at people like my friend ? Something that explains what an
> > array is, what a sort is, even what an interpreter is ?
>
> O'Reilly is the place to go. The Camel book and the Ram book are
> indespensible.
> http://perl.oreilly.com/
Gosh, no! Those are fine books for intermediate to advanced
programmers, but novices would have trouble, to say nothing of
beginners. (Skiers will grok those categories.)
This person is not far enough along even for the Llama book. There was
a thread about this recently, and I don't recall anyone proposing a Perl
book for beginners in programming. Search DejaNews for more.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 06 Apr 1999 16:54:42 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Perl as a first programming language - suitability, good books ?
Message-Id: <370A9EC2.4326C484@mail.cor.epa.gov>
Jonathan wrote:
>
> A friend of mine from an arts background is interested in learning to
> program, partly from intellectual curiousity and partly for career reasons.
> She's extremely smart and a great problem solver, but she's never written a
> program in any language. Until recently I didn't know what language to
> suggest to her - Basic's too ugly, Pascal is a dead end. And definitely not
> C++ (although it's what I do half my work in myself - my other languguage is
> Masm, which I felt was *almost* as inappropriate.) I was thinking maybe
> you-know-what, but last week I started to learn Perl.
>
> I finished writing my first production program the other day, a tool that
> assembles local chunks of data into a meshed description of 3D data. Now I'm
> in love with the language and recommending it to all my C++ programmer
> friends. The normal response is "I thought it was just a text manipulation
> language." I've found that the most effective response is to tell them that
> Perl supports dynamic inheritance - C++ programmers have a lot respect for a
> language that has a feature that C++ lacks (with good reason.)
>
> I know that Perl is usually a second or third language, and is mostly used
> by hardcore programmers, but I'm sure that Larry Wall didn't mean it that
> way and that it doesn't have to be that way. Perl has a lot of great
> features for first-timers - notably a long, gentle learning curve. (I think
> dynamc inheritance is probably the thing I'll leave until last.) I was
> wondering if anyone has any experience of learning Perl as a first language
> ?
>
> But most important of all, I was wondering if anyone could recommend a Perl
> book aimed at people like my friend ? Something that explains what an array
> is, what a sort is, even what an interpreter is ? (I'm too far away from her
> to make giving lessons easy and she's the sort of person who takes this
> stuff better from books.) I know that there's a Perl For Dummies book, but
> the reviews at Amazon were lukewarm - in particular it seemed to lack
> examples. Once she gets a start she can switch to one of the Learning Perl
> books.
>
> I'd be grateful for any suggestions.
>
> Jonathan Coupe
I really liked Randal's "Learning Perl", but it seems to be too
already-a-programmer-oriented for some people I have heard from.
You might check out this URL:
http://language.perl.com/critiques/index.html
"Teach Yourself Perl in 21 Days" might be the best starting place
for a non-programmer. Then once she feels comfortable with the
basics, she can move up to a better text which will cover more
of the modern bits.
Once she's ready for the OO parts, you might start her on tchrist's
perltoot. Still, Perl has enough stuff that she may want to
learn a little and then stop at some plateau for a while before
tackling another slope.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 06 Apr 1999 23:21:14 GMT
From: wingo01@my-dejanews.com
Subject: Perl for SunOS 4.1
Message-Id: <7ee4t3$q03$1@nnrp1.dejanews.com>
Anyone know where I could get the binary for Perl for SunOS 4.1
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 06 Apr 1999 18:30:04 -0400
From: Amy Wajda <awajda@limbo.ne.mediaone.net>
Subject: Perlshop "missing file title" error
Message-Id: <370A8AEC.34458D94@limbo.ne.mediaone.net>
Perlshop gurus--
I'm trying to call up my Perlshop catalog pages (having just finished
customizing the Perlshop script and setting up the catalog pages) and
keep getting a "missing file title" error.
I don't know much Perl--any, really--but I can see that there is a
reference to file_title in the parse_file subroutine that then calls the
check_file_title subroutine, which is what's generating the error
message. I'm guessing the error has to do with how I've coded my catalog
pages (or maybe how my directories are set up), although I've checked
them against the Perlshop manual and against I book I used to help me
set up Perlshop. I can't see that I've done anything wrong in the setup,
but I don't know enough to figure out what is causing the error.
Any help is much appreciated--
Amy Wajda
awajda@erg.com
ps Erik--I agree--we need a Perlshop list or group....
Here are snips of what I think are relevant bits of the script:
#------------------------------------------------------------------#
sub parse_file
<code snipped>
if (&check_file_title($catalog_page) == 0)
{
print $error_msg;
exit;
}
<snip>
#------------------------------------------------------------------#
sub check_file_title
{
my $file_title = $_[0];
if ($file_title eq "")
{
$error_msg = "Missing File Title\n";
return 0;
}
if ($file_title !~ /\.\./ )
{
return 1;
}
else {
$error_msg = "File Title '$file_title' is Invalid - Cannot contain
'..' \n";
return 0;
}
}
#------------------------------------------------------------------#
------------------------------
Date: Tue, 6 Apr 1999 18:27:38 -0500
From: "tavi" <tavi367@ibm.net>
Subject: Q - Mail::Header Module
Message-Id: <370a9800@news1.us.ibm.net>
I have this snippet...
use Mail::Header;
use Mail::Internet;
# Pull message in from pipe
my @mail = <STDIN>;
# Place message into Mail Object
my $r_mail_obj = new Mail::Internet(\@mail);
This bit works fine. I now have the message in Mail Object.
I can even use this...
$r_received = $r_mail_obj->get ('Received');
This will return a refernece to an array of 'Received' list.
But if I do this...
my @rct_list = $r_mail_obj->tags();
This is supposed to give me an array of all TAGs in the HEADer.
But I get this...
Can't locate auto/Mail/Internet/tags.al in @INC (@INC contains:
C:\Perl\5. ...
I have no idea what I am doing wrong here.
If anyone can show me the errors of my ways...?
Walter
# Use the MODule function to retrieve a complete list of HEADer TAGs
my @rct_list = $r_mail_obj->tags();
------------------------------
Date: Tue, 06 Apr 1999 22:18:40 GMT
From: frf <frf@energyinteractive.com>
Subject: regexp matching digits
Message-Id: <370A8846.8CD882EF@energyinteractive.com>
I am hoping someone can give me an elegant way to extract the
digits from a string. (sfour030299data.log)
I have a list of files that include the date of their creation in the
filename, and I want to extract that date string from the name.
All I can come up with is matching everything before the digits, and
then matching everything after the digits, but it seems lame.
Given $filename = sfour030299data.log
I'd like to get $filedate = 030299.
Thanks much
------------------------------
Date: Tue, 06 Apr 1999 16:24:38 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Regular Expression
Message-Id: <370A97B6.C490ACE2@mail.cor.epa.gov>
kelly_d@my-dejanews.com wrote:
>
> Hi,
>
> I am presently writing a Perl program and I am using regular expresssions a
> lot.
In that case, you might want to take a look at Jeffrey Friedl's book
'Mastering Regular Expressions'. The perlre section is pretty good too.
> I am relatively new with Perl and so far I have overcome most problems
> except of course this one.
>
> I am interested in creating a regular expression for finding words that are in
> CAPTIAL letters in any one line. All I have succeeded in doing is finding 1
> captial letter in every line by the use of
> /[A-Z]+/ expression.
Right. /[A-Z]+/ by itself matches any line with at least 1 cap in it. Not
quite what you want.
> However to get at least one full word I have to type [A-Z][A-Z] etc.
Or better yet, use the word boundary assertion \b like this:
/\b[A-Z]+\b/
so you get a string of caps only when it is surrounded by non-word
characters. That also includes the hyphen and single quote, so it
won't work quite right if you have some words like DAG-NAMMIT or ISN'T
in your string. \b will find word boundaries inside those words. But
you know your data better than I do.
> Can anyone help me in the creation of this R.E.
>
> Thanking you in advance
>
> Kelly
>
Since you want to pick up *all* the capitalized words in your string,
you'll want to use the /g option too.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 06 Apr 1999 16:02:35 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: setting env variables, sourcing, etc.
Message-Id: <370A928B.DE0BDCC4@mail.cor.epa.gov>
Tom Kralidis wrote:
>
> Hi,
>
> I have made a script to create a directory structure for day-to-day lab
> operations. It works fine, however, I tried setting an environment
> variable in one of the directories, and when executing the script, I
> received an error message. I tried this with a simple
>
> system("cd tables;setenv TABLES $cwd");
>
> and was not successful.
>
> Does anyone know why this won't happen, or is there a better way to do
> this? Note that the env variable is for a directory generated by the
> script itself.
>
> Any advice is much appreciated
When you say 'and was not successful', do you mean
[1] you got an error message about using 'setenv' that looked
like this:
sh: setenv: not found
[2] you got an error message about $cwd
[3] you got it to run, but the 'cd' didn't stick?
[1] would be because system uses sh instead of csh, and sh
doesn't have 'setenv'.
[2] would depend on the rest of the program.
[3] would be due to the fact that system() ran a child process
whose environment died with it. See perlfaq8, or try
'perldoc -q environment'.
HTH,
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 06 Apr 1999 16:18:27 -0700
From: Edwin Veelo <eveelo@artcenter.edu>
Subject: Thanx! (waas Re: Q: explain me "=")
Message-Id: <370A95E8.4B53B606@artcenter.edu>
Matthew Bafford wrote:
-> Hope This Helpz!
Sure did!
Thanx!
-Edwin
------------------------------
Date: Tue, 06 Apr 1999 23:29:16 GMT
From: bhaskaracharya@my-dejanews.com
Subject: typeglobs and strict....simple qn.
Message-Id: <7ee5c3$qcu$1@nnrp1.dejanews.com>
hi
I read through Tom C.'s long post on typeglobs but got lost somewhere along
the way. readthrough persub and perlref as well and sections on typeglob.
Anyways my qn. is simple:
* do typeglobs and strict go hand in hand?
the function in the book does not compile with use strict nor does my
simple_print function. COuld somebody care to explain in a more brief
way so that i could go and read the FAQ without getting lost...
or tell me how to be calling the two sub's?
thanks
-bhaskar
#!/local/perl -w
use strict;
sub func_from_book {
local(*c, *d) = @_;
if (@c > @d) {
return(\@c, \@d);
} else {
return(\@d, \@c);
}
}
sub simple_print {
local(*something) = @_;
print *something;# just trying, i know i can use $_[0]
print @something;
}
my @c = qw ( one two);
my @d = qw (one three four);
(*a, *b) = func_from_book(\@c, \@d);
simple_print(\@c);
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 06 Apr 1999 15:35:12 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Unpack Question
Message-Id: <370A8C20.A3FD9E3D@mail.cor.epa.gov>
David Delikat wrote:
>
> Jason Hissong wrote:
> >
> > David Delikat wrote:
> >
> > > using unpack to comunicate with C can be stessfull.
> > >
> > >
> > > good luck
> > >
> > > -dav
> > >
> > > --
> > > <((((><
> > > Consultant: Internet, Database, Business Systems
> > > Unix/Linux, Windows95/NT
> > > mailto:david-delikat@usa.net / http://obj.webjump.com/
> >
> > David,
> >
> > Thanks for your information. Assuming that the first 16 bits are the first
> > unsigned short, and the next 32 bits were the long in my example structure,
> > how would I access the sub-elements of that unsigned short? i.e., I only
> > want the first 5 bits in a scaler, the next 5 in another scaler, and then
> > the last 6 bits in another scalar. These bits are numbers:
> >
> > 00011 00010 000111
> >
> > The first set would be the number 3
> > The second set would be the number 2
> > The third set would be the number 7
> >
> > I am wondering if I need to unpack them as binary bits:
> >
> > "b5 b5 b6"
> >
> > and then pack them somehow into something meaningful...
> >
> > Your right, it can be stressful :)
> >
> > thanks
> >
> > Jason
>
> first, if there are bits in between, then you have to account
> for those in your unpack string. every bit of information
> MUST be accounted for save any trailing info you dont care about.
>
> if your data looks like this:
>
> 0001100010000111
>
> then 'b5 b5 b6' will do fine.
>
> but if it looks like this:
>
> 00011XX00010X000111
>
> then you need 'b5 b2 b5 b1 b6' and then ignore the
Or 'b5 x2 b5 x1 b6' to skip over those guys.
Assuming 'b' is what you want: a bit string,
in low-to-high order. Otherwise, you need a different
template. I believe the list is to be found under
pack(): 'perldoc -f pack'.
> ones you don't want. At this point I'll say that
> you should be careful if you are not taking your
> data apart tha same way you put it together. that
> is, if you put unsigned shorts and longs, then
> you should get unsigned shorts and longs back.
> unless you are writing out network byte order, you
> will not be portable if you try to grab only the
> interesting 'bits' of information.
>
> does this help?
>
> -dav
>
> --
> <((((><
> Consultant: Internet, Database, Business Systems
> Unix/Linux, Windows95/NT
> mailto:david-delikat@usa.net / http://obj.webjump.com/
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 06 Apr 1999 23:25:46 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Very large regular expressions
Message-Id: <370A99EE.EF64B28B@home.com>
[posted & mailed]
Sean McAfee wrote:
>
> Now if I can only figure what effect, if any, the \G assertion has.
>
> foreach $regex (@regex) {
> $letter =~ /$regex/g or die;
> # The above line seems to work exactly the same if I say:
> # $letter =~ /\G$regex/g or die;
Maybe $regex can always match at pos($letter)? It is only when it can't
that they will behave differently.
#!/usr/local/bin/perl -w
$letter = 'onetwo three onetwo three onetwo three';
@regex = qw(one two three);
foreach $regex (@regex) {
$letter =~ /\G$regex/g or die;
print "$& from first at ", pos($letter), "\n";
$letter =~ /$regex/g or die;
print "$& from second at ", pos($letter), "\n";
}
__END__
Died at temp line 8.
one from first at 3
one from second at 16
two from first at 19
two from second at 32
I wonder how reliable it is, though, to expect pos to not be reset when
$regex changes. This seems pretty handy but I don't recall seeing this
documented anywhere.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Tue, 6 Apr 1999 22:28:27 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Where can i find Net::SMTP module?
Message-Id: <ebohlmanF9sH3F.9AC@netcom.com>
agniora@usa.net wrote:
: I need to send emails from my windows NT ActivePerl. Does anyone know where
: and how i can get the Net::SMTP module, cause thats what the example in the
: activeperl documentation talks about. thanks
Net::SMTP is part of the libnet bundle, which you can install using PPM.
------------------------------
Date: Tue, 06 Apr 1999 15:40:59 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Which text editor should I use
Message-Id: <370A8D7B.E02E2E8C@mail.cor.epa.gov>
Jordan I. K. McClure wrote:
>
> gabriel_john_cohen@my-dejanews.com wrote:
> : Hello,
> :
> : I'm trying to learn PERL on a linux machine. Which text editor should I use?
>
> Appleworks.
<jumping up and down manically>
Good answer! Good answer!
</jumping up and down manically>
Well, what text editor do you already like? You can use that
one. You already know it. Fortunately, this ng is too polite
to burst into a flamewar over editors. This is covered in
some detail at http://reference.perl.com/
>
> --
> I'm writing a book. I've got the page numbers done. -- Stephen Wright
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 5314
**************************************