[8105] in Perl-Users-Digest
Perl-Users Digest, Issue: 1724 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 25 10:17:15 1998
Date: Sun, 25 Jan 98 07:00:37 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 25 Jan 1998 Volume: 8 Number: 1724
Today's topics:
Re: /x regex mystery <*@qz.to>
Re: /x regex mystery <jhi@alpha.hut.fi>
Re: /x regex mystery (binkley)
Re: /x regex mystery <tchrist@mox.perl.com>
Re: ? random text string <jdporter@min.net>
Re: Accpeting command line input such as ".- .." (brian d foy)
Re: Cwd pragma/realpath conflict? <jdporter@min.net>
Decimal places <brad.grove@b131.aone.net.au>
Re: File::Find feature? How to preserve stat buffer? <alexis@danae.demon.co.uk>
Re: Finding the missing bracket? (Michael Budash)
Re: Freidl's book mystery <*@qz.to>
Re: Help w/ regexp <jdporter@min.net>
Re: Help w/ regexp <rjk@coos.dartmouth.edu>
Re: HELP!!! - How do you add #'s within an array (brian d foy)
Re: HELP!!! - How do you add #'s within an array <danboo@negia.net>
Re: HELP!!! - How do you add #'s within an array (brian d foy)
Interfacing a database through a perl script??? <coolj@zip.com.au>
Re: Looking for licensing software for perl scripts? (brian d foy)
Re: MacPerl CD-ROM, Version 0.5 (Chris Nandor)
Re: Newer than New . . . :-)) <lelyea@freeway.net>
Re: POSIX (?) under perl for Win95 (binkley)
Re: References to parent objects <jdporter@min.net>
Re: relational operators and negative numbers <jdporter@min.net>
Variable scope question/problem <felicity@dilbert.kluge.net>
Re: Variable scope question/problem <tchrist@mox.perl.com>
White Hats and Black <tchrist@mox.perl.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Jan 1998 09:09:23 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: /x regex mystery
Message-Id: <qz$9801250359@qz.little-neck.ny.us>
Abigail <abigail@fnx.com> wrote:
> change "void" to "kf8nh" (bsa@void.apk.net) wrote on 1607 September 1993
> ++ (/x is not psychic.)
> Well, it's time that it gets fixed then. Djee, isn't Perl supposed
> to do want you expect it to do?
Isn't the do-what-I-mean operator coming in perl 6?
> perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
Whooo, that one is fun.
Elijah
------
noticed TPJ has the old version of the prime number RE
------------------------------
Date: 25 Jan 1998 13:54:39 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: /x regex mystery
Message-Id: <oee3eicixa8.fsf@alpha.hut.fi>
bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh") writes:
> [clip]
> | print (($string =~ /Tom Christiansen .* perl .* com/x)
> | ? "yes\n" : "no\n");
> |
> | Shouldn't the /x just make the spaces around ".*" go away, effectively? Perl
> | is "5.004_03" running on Solaris 5.5.1, FWIW.
> +--->8
>
> It does. It also makes the space between "Tom" and "Christiansen" go away,
> causing it not to match. (/x is not psychic.)
Using \ will enhance the psychic abilities, though:
/Tom\ Christiansen .* perl .* com/x
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Sun, 25 Jan 1998 09:04:03 -0500
From: "B. K. Oxley (binkley)" <binkley@bigfoot.com>
Subject: Re: /x regex mystery
Message-Id: <6afgok$sah$1@ndnws01.ne.highway1.com>
Jarkko Hietaniemi wrote in message ...
>
>bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to
"kf8nh") writes:
>> [clip]
>> | print (($string =~ /Tom Christiansen .* perl .* com/x)
>> | ? "yes\n" : "no\n");
>> |
>> | Shouldn't the /x just make the spaces around ".*" go away, effectively?
Perl
>> | is "5.004_03" running on Solaris 5.5.1, FWIW.
>> +--->8
>>
>> It does. It also makes the space between "Tom" and "Christiansen" go
away,
>> causing it not to match. (/x is not psychic.)
>
>Using \ will enhance the psychic abilities, though:
>
> /Tom\ Christiansen .* perl .* com/x
However, wouldn't it be a nice enhancement to /x to have it only strip
whitespace adjacent to regex operators? In which case, the above example
would leave the space between "Tom" and "Christiansen" alone, but strip it
elsewhere.
--binkley
------------------------------
Date: 25 Jan 1998 14:35:47 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: /x regex mystery
Message-Id: <6afik3$i68$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"B. K. Oxley (binkley)" <binkley@bigfoot.com> writes:
:However, wouldn't it be a nice enhancement to /x to have it only strip
:whitespace adjacent to regex operators? In which case, the above example
:would leave the space between "Tom" and "Christiansen" alone, but strip it
:elsewhere.
That would be of dubious inconsistency, and certainly can't be
done this late in the game.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Can you sum up plan 9 in layman's terms? It does everything
Unix does only less reliably --Ken Thompson
------------------------------
Date: Fri, 23 Jan 1998 08:09:05 -0500
From: John Porter <jdporter@min.net>
Subject: Re: ? random text string
Message-Id: <34C89671.520F@min.net>
John Porter wrote:
>
> Lars Kr. Lundin wrote:
> >
> > Can anybody tell me how to produce a random text string that matches
> > /^\w{8}$/ ?
> >
> > I would be surprised if it is difficult...
>
> Sure.
> $_ = substr(('0'x8)!vi.int(rand 100000000),-8);
Here's an even better one:
$_ = ('0'x7).int(rand 2);
John Porter
------------------------------
Date: Sun, 25 Jan 1998 02:27:07 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Accpeting command line input such as ".- .."
Message-Id: <comdog-ya02408000R2501980227070001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6aeg0e$36u@nntp02.primenet.com>, Jerald Jackson <jsjacks@primenet.com> posted:
>I am trying to write a basic morse translation script. It works
>jsut fine when I read input from a file, but when I attempt to
>pass it code from the command line, I get errors that it cannot find
>a file ".-" or whatever character I passed it. The strange thing
>was that the letter e "." works from the command line but ".." will
>print "e e e".
>Ideas?
perhaps a peek at the source would be useful... :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Fri, 23 Jan 1998 08:28:55 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Cwd pragma/realpath conflict?
Message-Id: <34C89B17.428B@min.net>
On my system at least (SunOS 5.4, Perl 5.004_01), $! seems to be
affected not by readlink, but by any 'use' directive which reads a file,
including Cwd. Try eliminating all your 'use's in your test script;
then
add one; especially try adding one that isn't Cwd. You get the same
results.
The correct fix is to set $! = 0 before calling readlink.
In general a good idea anyway.
Hth,
John Porter
------------------------------
Date: Sun, 25 Jan 1998 23:49:00 +1100
From: "Brad Grove" <brad.grove@b131.aone.net.au>
Subject: Decimal places
Message-Id: <6affte$ech$1@news.mel.aone.net.au>
How do I control the number of decimal places or better still extract the
integer from a scalar variable. For instance :
$a = 1234;
$b = 23;
$percent = $b/$a*100;
How do I stop '$percent' displaying as 1.8638574 or whatever. Is there an
int() function or something similar to left(), mid() which I could use as if
it were a string.
Regards
Brad Grove
------------------------------
Date: 25 Jan 1998 13:26:50 GMT
From: Alexis Huxley <alexis@danae.demon.co.uk>
Subject: Re: File::Find feature? How to preserve stat buffer?
Message-Id: <encdcq.1c6@danae.demon.co.uk>
In <8ck9bp7263.fsf@gadget.cscaper.com> Randal Schwartz <merlyn@stonehenge.com> writes:
> Alexis> 3 ($dev,$ino,$mode,$nlink) = ($Is_VMS ? stat($_) : lstat($_));
> Alexis> 4 if (-d _) {
> Alexis> 5 # run finddir() on that subdirectory
> Uh, who's code are you reading? Line 3 will do an lstat on non-VMS.
> That's gonna set _. So line 4 is *always* gonna test the same thing
The camel book states:
lstat: ... does the same thing as the stat function
stat: ... if *stat* is passed the special file handle consisting of
an underline ... the current contents of the *stat* structure
... are returned
>From which it could be inferred that lstat(_) returns the the current contents
of the *stat* structure. I admit you'd have to be pretty desperate to infer
that, but I am!
I chopped my 3000 line program down and down and wound up with just this which
*still* reproduces the same feature:
#!/usr/bin/perl
use File::Find;
sub wanted
{
print "$File::Find::name\n";
}
&find(\&wanted, "/");
>From which I guess it must be a problem with my / hierachy. It is a standard
Debian structure with one notable addition:
danae$ ls -alR /mnt.staging
total 3
drwxr-xr-x 3 root root 1024 Jan 21 14:16 ./
drwxr-xr-x 21 root root 1024 Jan 21 14:14 ../
drwxr-sr-x 3 root staff 1024 Jan 21 12:17 crypt/
/mnt.staging/crypt:
total 3
drwxr-sr-x 3 root staff 1024 Jan 21 12:17 ./
drwxr-xr-x 3 root root 1024 Jan 21 14:16 ../
drwx------ 4 alexis alexis 1024 Jan 21 20:35 alexis/
/mnt.staging/crypt/alexis:
total 0
danae$
Note that the last part of this does not *even* produce entries for '.' and
'..' due to /mnt.staging/crypt being a TCFS (Transparent Cryptographic)
for which the key has not yet been registered by the user (with tcfslogin):
danae$ mount -t tcfs
localhost:/diska/crypt on /mnt.staging/crypt type tcfs (rw,addr=127.0.0.1)
danae$
*BUT* the above script seems to 'trip' up at this directory entry - perhaps
it's unable to cd back up out of the directory and continue finding, after all,
the shell does something similar - though at least it tells me:
danae$ cd /mnt.staging/crypt
danae$ cd alexis
danae$ cd ..
bash: cd: ..: Permission denied
danae$
[ Isn't there some NFS exports option that also results in a directory
being readable from the outside, but not from the inside? Something to do
with root user validity? (Vague idea) ]
The above script produces:
[ normal list of previous files snipped ]
/etc/apache/access.conf
/etc/apache/srm.conf
/etc/apache/httpd.conf.0
/mnt.staging
/mnt.staging/crypt <-- into TCFS
/mnt.staging/crypt/alexis
/usr <-- fails to descend into /usr!
/root <-- fails to descend into /root!
/dev <-- fails to descend into /dev!
/sbin <-- fails to descend into /sbin!
[ remaining subdirs of / snipped - all of which are not descended into ]
So now I'm even more confused! finddir() isn't warning mean about an unreadable
directory (Find.pm:115), wanted() *is* getting called (Find.pm:135). Perhaps
the stat() or lstat() calls are failing? (Find.pm:140), but at any rate, the
'(-d _)' (Find.pm:143) is mistakenly preventing recursing for /usr, /root,
/dev, ... (Find.pm:150).
What's going on? Should File::Find be able to cope with a directory that
is readable from the outside but *not* from the inside - as TCFS seems to
provide, should I be *expected* to realise that if it shouldn't, should I have
to hack my program to handle this? At any rate I've confused finddir()!
Any ideas?
Thanks
Alexis
--
Alexis Huxley Delfyn on IRC (EFNet)
alexis@danae.demon.co.uk Email key: 549812
http://www.danae.demon.co.uk/ PGP key, CV, Unix S/W, info, Rilke
"I think you think I can't think" Program in 1991 BCM Turing Test
------------------------------
Date: Sun, 25 Jan 1998 00:56:13 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Finding the missing bracket?
Message-Id: <mbudash-2501980056130001@d174.pm5.sonic.net>
In article <34CA2111.A178761B@coos.dartmouth.edu>, rjk@coos.dartmouth.edu wrote:
>> Michael Budash wrote:
>> >
>> > In article <Pine.GSO.3.96.980123134723.17597Q-100000@user2.teleport.com>,
>> > Tom Phoenix <rootbeer@teleport.com> wrote:
>> >
>> > >> A programmers' text editor should be able to help you indent code
properly
>> > >> and to match up braces in pairs.
>> >
>> > Could you (and/or the others 'round here) be so kind as to recommend such
>> > an editor, i.e., one that is perl-savvy?
>>
>> emacs
>>
>> Did you have a specific platform in mind?
>>
oops...win32 or mac, pls?
--
Michael Budash, Owner * Michael Budash Consulting
mbudash@sonic.net * http://www.sonic.net/~mbudash
707-255-5371 * 707-258-7800 x7736
------------------------------
Date: 25 Jan 1998 09:01:00 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Freidl's book mystery
Message-Id: <qz$9801250351@qz.little-neck.ny.us>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> Which one? Seems to me my coding style is standad, and perlstyle(1)
> even concurs. :-)
But is your English the standard one?
Elijah
------
just read the "who's" vs "whose" post in comp.lang.perl.modules
------------------------------
Date: Fri, 23 Jan 1998 08:06:08 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Help w/ regexp
Message-Id: <34C895C0.439D@min.net>
Douglas Clifton wrote:
>
> I'm trying to figure out a way to match a range of numbers.
> I know about the [0-9] syntax, but the numbers would be
> more like 15-31, [15-31] does not work.
>
> I know this is not that difficult to do, the problem is the
> range is not known untill run-time and would be in
> scalar variables like $beg and $end.
Probably the easiest the thing to do is to match any possible
positive integer, like so: (\d+)
or, if you know it's a two-character field always, like so:
(\d\d). The important thing is to enclose the expression
in parens. Then, assuming you got that match, take the
matching text, which will be in $1 (or $2, or whatever), and
compare that numerically to your range of validity, e.g.:
if ( /(\d+)/ and $1 >= $beg and $1 <= $end ) { ...
hth,
John Porter
------------------------------
Date: Sun, 25 Jan 1998 03:18:41 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: Help w/ regexp
Message-Id: <34CAF560.C3852C76@coos.dartmouth.edu>
brian d foy wrote:
>
> In article <34CA234D.675BE7C6@coos.dartmouth.edu>, rjk@coos.dartmouth.edu posted:
>
> > You can use the suggestions you've already received in the grep:
> >
> > @log = grep {/(\d+)$/ and $1 >= $beg and $1 <= $end} @log
>
> remember that he wanted only the last two characters... :)
>
> @log = grep {/(\d\d)$/ and $1 >= $beg and $1 <= $end} @log
Really? He didn't say so in either of his posts. He simply said he wanted
to match numbers from the ends of the strings within a certain range.
@log = grep {/(\d+)$/ and $1 >= $beg and $1 <= $end} @log
Chipmunk
------------------------------
Date: Sun, 25 Jan 1998 02:25:15 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: HELP!!! - How do you add #'s within an array
Message-Id: <comdog-ya02408000R2501980225150001@news.panix.com>
Keywords: from just another new york perl hacker
In article <885701196.712769541@dejanews.com>, webmaster@pclightning.com posted:
>I have an array called @file
>It contains the values of 8 7 6 4 9 3 and so.
>I want to add these numbers together to get 37.
that's good, because that is their sum.
>I know that I could add $file[0] + $file[1] + and so on after doing a
>split command, but this will become a constantly updated program ---
>meaning that there is now 6 numbers, but it will grow to over a hundred
>within a month.
unless a lot of of those numbers are zero, their sum won't be 37
>So, is there a way to give the sum of an array???
i think so...
#method zero
$sum = 37
#method one
foreach(0..$#array_name) { $sum += $array_name[$_] }
#method two
while( defined( $_ = shift @array_name ) ) { $sum += $_ }
#method three
map {$sum += $_ } @array_name
#method four
while( $count <= $#array_name ) { $sum += @array_name[$count,$count++] }
#method five
while(scalar @array_name){ $sum += splice(@array_name, 0, 1) }
#method six
grep { /^(\d+)$/ and $sum += $1 } @array_name
#method seven
$_ = join 'just another new york perl hacker', @array_name;
while( m/(\d+)/g ) { $sum += $1 }
#method seven bred with method three
$_ = join 'just another new york perl hacker', @array_name;
map { $sum += $_ } m/(\d+)/g;
#method eight (sum in $array_name[0]
while( $#array_name ) { $array_name[0] += pop @array_name }
#method nine
$_ = join ' + ', map { "\$array_name[$_]" } (0 .. $#array_name);
eval "\$sum = $_";
#method ten
$_ = join 'just another new york perl hacker', @array_name;
s/(\d+)/$sum += $1/eg;
but remember: TAMTTWTOI
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Sat, 24 Jan 1998 23:46:15 -0500
From: Dan Boorstein <danboo@negia.net>
Subject: Re: HELP!!! - How do you add #'s within an array
Message-Id: <34CAC397.AC450C48@negia.net>
webmaster@pclightning.com wrote:
>
> I have an array called @file
> It contains the values of 8 7 6 4 9 3 and so.
> I want to add these numbers together to get 37.
>
hint: you can find the last index of an array, @arrayName in a
variable named $#arrayName.
so for:
@file = (8, 7, 6, 4, 9, 3);
$#file has the value 5.
this knowledge, combined with your favorite iterative procedure,
will get your sum. and, if used appropriately, automatically updates
itself as your array grows/shrinks in length.
good luck,
dan boorstein
------------------------------
Date: Sun, 25 Jan 1998 05:47:25 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: HELP!!! - How do you add #'s within an array
Message-Id: <comdog-ya02408000R2501980547250001@news.panix.com>
Keywords: from just another new york perl hacker
In article <qz$9801250411@qz.little-neck.ny.us>, Eli the Bearded <*@qz.to> posted:
>brian d foy <comdog@computerdog.com> wrote:
>> Date: Sun Jan 25 02:25:15 EST 1998
>> X-dessert: strawberries, silly
>
>Actually, I think it was New York Cheesecake.
just a slice actually, but then it was a slice sort of night.
nothing like free issues of the Perl Journal to make one
feel better about one's dessert.
>> >So, is there a way to give the sum of an array???
>> i think so...
>> #method ten
>> $_ = join 'just another new york perl hacker', @array_name;
>> s/(\d+)/$sum += $1/eg;
>
>You really missed an obvious one there:
>
> $_ = join '+', @array_name;
> $sum = eval;
i would have had to take off my shoes to come up with any
more than ten. but i missed more than a few methods - i
didn't want to beat a dead horse.
--
brian d foy <comdog@computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
don't inject yourself with sulfuric acid. i hear it's not good.
------------------------------
Date: Sun, 25 Jan 1998 23:25:50 +1100
From: Jason Bainbridge <coolj@zip.com.au>
Subject: Interfacing a database through a perl script???
Message-Id: <34CB2F4E.9F953ED8@zip.com.au>
I'm having trouble locating a way to get a perl chat script to interface
with a database, which it neeeds to read from and also write to. I have
gone to all the usual places looking for some sort of database module,
but either I'm not understanding what they do properly or it just isn't
a simple thing to do.
All I need is a database containing things like username, password,
homepage, email address and so on, I want to be able to access this from
the main chat script, to both display them in the html file generated by
the script and to be able to modify various fields from within the chat
script using commands whilst chatting.
If anyone can explain to me how to do this or even just point me in the
right direction, can you please either respond to this post or email me?
Thankyou.
------------------------------
Date: Sun, 25 Jan 1998 02:30:53 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Looking for licensing software for perl scripts?
Message-Id: <comdog-ya02408000R2501980230530001@news.panix.com>
Keywords: from just another new york perl hacker
In article <Pine.GSO.3.96.980124223711.27755a-100000@user2.teleport.com>, Tom Phoenix <rootbeer@teleport.com> posted:
>On Sat, 24 Jan 1998 mahesh@mahesh.com wrote:
>
>> I am looking for some solution to prevent the piracy of our
>> perl scripts :-)
>
>That's why god (or someone) invented lawyers. But see what section 3 of
>the FAQ has to say about this before you try any other methods. Good luck!
but remember that lawyers don't prevent anything. they can be useful
when others annoy you though. :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
------------------------------
Date: Sun, 25 Jan 1998 09:49:01 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: MacPerl CD-ROM, Version 0.5
Message-Id: <pudge-2501980949010001@ppp-7.ts-1.kin.idt.net>
In article <1d3dnqm.wafm81ev9mp6N@du98-6.ppp.algonet.se>,
tony@svanstrom.com (Tony L. Svanstrom) wrote:
# Chris Nandor <pudge@pobox.com> wrote:
#
# > In article <1d3d3n4.1p1grp615sdli8N@du31-253.ppp.algonet.se>,
# > tony@svanstrom.com (Tony L. Svanstrom) wrote:
# >
# > # Rich Morin <rdm@cfcl.com> wrote:
# > #
# > # > Prime Time Freeware (PTF; http://www.ptf.com) is pleased to announce the
# > # > MacPerl CD-ROM (Version 0.5). This disc,
# > #
# > # Is this a good buy for someone that wants to learn Perl when the scripts
# > # will be used on UN*Xmachines only?
# >
# > If you will only be using Unix, no. It is an HFS (Mac-format) disk. If
# > you will be using MacPerl to write scripts for use on Unix, then yes, it
# > is good for that.
#
# My questions should really have been: If it works on UN*X does it then
# work on Mac, and if it works on a Mac...?
If what works on Unix does what work on the Mac? I already said, the
CD-ROM is Mac-formatted. Are you asking about an actual MacPerl script,
does that work on Unix? Maybe, maybe not. If it is written properly it
should, in most cases, work on any platform that supports Perl, unless it
requires platform-specific stuff (such as a Mac:: module) or one of the
few things a given platform does not support (like exec/fork in Mac OS).
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: Sun, 25 Jan 1998 02:07:40 -0500
From: L Elyea <lelyea@freeway.net>
Subject: Re: Newer than New . . . :-))
Message-Id: <34CAE4BC.61EED7DC@freeway.net>
Bob - I am about in the same shape as you and can recommend two books, and
recommend you get them both. (1) Learning Perl by Randal L Schwartz ISBN
1-56592-042-2 (Cover Price $24.95) and (2) Perl 5 'How To' published by the
Waite Group ISBN 1-57169-118-9
Len
> I
> wonder if someone could recommend a descent book on the subject. Not an
> overly technical book, as I would not want to become disheartened right from
> the start. But, nor am I interested in a "******** for dummies" either. Any
> recommendations would be great. And big thanks in advance...
>
> Bob
------------------------------
Date: Sun, 25 Jan 1998 09:08:30 -0500
From: "B. K. Oxley (binkley)" <binkley@bigfoot.com>
Subject: Re: POSIX (?) under perl for Win95
Message-Id: <6afh0t$sdo$1@ndnws01.ne.highway1.com>
But honestly, one needn't go whole hog with POSIX support under Win32 to at
least ship something with Standard Perl for Win32 that will build!
Some of the most recent posts have asked for access to the read/write flags
for open, or for the math functions (floor, ceil, et al). These are easily
supported under the Win32 subsystem. Tricky parts like user/group or
process control can just return "unsupported". That would go a long ways
toward helping with cross-platform scripts which use the POSIX module.
--binkley
Gurusamy Sarathy wrote in message <6aen4c$joh@srvr1.engin.umich.edu>...
> [ mailed and posted ]
>
>In article <885623049.153157643@dejanews.com>, <rodney@bond.net> wrote:
>>In article <6aajka$pfs@srvr1.engin.umich.edu>,
>> gsar@engin.umich.edu (Gurusamy Sarathy) wrote:
>>> Unfortunately, no. Win32 is not POSIX compliant and that perl is a
>>> *Win32* port. MS claims Windows NT is POSIX capable, but the POSIX
>>> subsystem can't access the Win32 subsystem and vice versa, so it is
>>> not much good.
>>
>>The MS Posix subsystem is Posix.1. But it is hard to use. If you replace
>>the MS Posix subsystem with the OpenNT subsystem (read Unix) the above
>>problems largely go away.
>
>Yeah. If you replace WindowsNT with Linux, the above problems completely
>go away, too. ;-)
------------------------------
Date: Fri, 23 Jan 1998 08:34:50 -0500
From: John Porter <jdporter@min.net>
Subject: Re: References to parent objects
Message-Id: <34C89C7A.464F@min.net>
Martien Verbruggen wrote:
>
> In article <34c77225.31485503@news.demon.co.uk>,
> dan@gulch.demon.co.uk (Dan Sumption) writes:
>
> > I have hit a point where I have an object which needs to reference
> > some of its parent's properties, and although I can't see any problems
>
> object, parent.. Are you talking about blessed references and
> inheritance here? You're using some of the terminology, but in the
> code you submitted you're not really using the methodology.
>
> [snipped stuff]
>
> If your objects are blessed references (using the two argument version
> of bless), and you actually mean parent as in: This object's class has
> inherited it's properties from this parent (using @ISA), you can use
> the special pseudoclass SUPER.
Well this is clearly not what he was talking about.
He has tree-structured data, consisting of internal nodes and leaf
nodes. The internal node objects can be called the parent objects
of the node objects below them in the tree. Confusing, yes, but
not really incorrect.
In answer to Dan's question, I say, "Yes, go for it." Just be aware
that you will have circular references, which means objects might
live longer than you expect. Read the note on garbage collection in
the Camel.
hth,
John Porter
------------------------------
Date: Sat, 24 Jan 1998 13:33:28 -0500
From: John Porter <jdporter@min.net>
Subject: Re: relational operators and negative numbers
Message-Id: <34CA33F8.2D4E@min.net>
Michael Rocchetti wrote:
>
> Dear God - I pray that this is not a stupid question.....
>
> I want to compare numbers and execute a bad_entry subroutine if b is greater
> than a.
What's happening that you think shouldn't be (or vice versa)?
Do you expect -1 to be greater than or less than -2?
Maybe you have a confusion as to absolute values.
Unless you mean to deal with absolute values,
-2 < -1 < 1 < 2.
If you want to compare absolute values, you have to use the abs()
function.
hth,
John Porter
------------------------------
Date: 25 Jan 1998 08:25:17 GMT
From: Theo Van Dinter <felicity@dilbert.kluge.net>
Subject: Variable scope question/problem
Message-Id: <6aestd$oc1$1@bigboote.WPI.EDU>
I have a simple script which has some odd scoping behavior (IMO):
---------------------
#!/usr/local/bin/perl
use strict;
my($temp);
sub subr {
$temp = 1;
}
---------------------
This works without error on Perl 5.004_03 (and 04). Is the 'my($temp)' just
declaring the variable globally which is why I don't have to declare anything
in the subr routine? I assumed (incorrectly?) that commands not within a
subroutine were considered to be in a 'main' function, with it's own scope.
Any thoughts?
------------------------------
Date: 25 Jan 1998 14:32:17 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Variable scope question/problem
Message-Id: <6afidh$i68$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Theo Van Dinter <felicity@dilbert.kluge.net> writes:
:I have a simple script which has some odd scoping behavior (IMO):
:
:#!/usr/local/bin/perl
:use strict;
:my($temp);
:sub subr {
: $temp = 1;
:}
:
:This works without error on Perl 5.004_03 (and 04). Is the 'my($temp)' just
:declaring the variable globally which is why I don't have to declare anything
no.
:in the subr routine? I assumed (incorrectly?) that commands not within a
:subroutine were considered to be in a 'main' function, with it's own scope.
There is no main function in Perl, and s/it's/its/.
:Any thoughts?
I think I don't understand why people think this. Let's consider the
following:
If you were coding in C, and you did this:
int Fred = 20;
subr() {
Fred = 1;
}
Would you be surprised for that to work?
Or what about this:
subr() {
int Fred = 20;
if (SOME CONDITION) {
Fred = 1;
}
}
Would that surprise you? Notice that the assignment
is not at exactly the same level as the declaration.
Does that mean it's inaccessible?
Let's move from C to Perl.
my $Fred = 20;
if (1 > 0) {
my $Barney = 30;
if ($Barney > $Fred) {
print "$Fred is greater than $Barney\n";
}
}
Is there anything about this code above that would lead you to believe
that some of those variables would be inaccessible from the interior
blocks? Were that the case, it would be impossible to write code as
we are expecting. Just because the declaration of $Barney occurred
outside the body of the if() containing the print() statement doesn't
mean that $Barney is inaccessible. Repeat that sentence, substituting
$Fred for $Barney.
Contrary to popular belief, my() has nothing to do with subroutines.
It has to do with scopes. A scope is a block. A block is either a set
of curleys, a file, or an eval. Or think of it this way: a file and an
eval both have an implicit set of curleys around them.
Is there anything about this code above that would lead you to believe
that some of those variables would be inaccessible from the interior
blocks? Were that the case, it would be impossible to write code as
we are expecting. Just because the declaration of $Barney occurred
outside the body of the if() containing the print() statement doesn't
mean that $Barney is inaccessible. Repeat that sentence, substituting
$Fred for $Barney.
Perl is a block structured language whose scopes nest, just as are C
and Pascal. In all these languages, scope is staticly inferrible at
compile time. That's why my() variables are of static scope, also called
lexical scope. I'll call my() variables lexicals, distinguishing them
from the other kind of variables, which are variously called globals or
dynamics, or even locals, perversely enough.
Because blocks nest, all blocks nested within a given block and textuaally
below the declaration of a my variable can access that variable. This is
the same as in C or Pascal. There are no surprises here, aside fmor
the fact that I'm astonished that this has taken you by surprise.
If you declare a lexical at the "outer scope", that is, outside
of any particular function, then it is NOT GLOBAL. Its scope is
the implicit block which is the file or eval. Scopes nested
within that file and below it textually (lexically), are perfectly
within their rights to access those lexicals. Think of it not as
a global/extern variable in C, but as a file-scoped static in C.
Thus, it's more like
/* This is C code */
static int Fred = 20;
sub1() {
Fred = 1;
}
sub2() {
Fred = 2;
}
Nothing outside that file's scope can access Fred, but it
is not global. It is private unto that file.
# this is Perl code
my $Fred = 20;
sub sub1() {
$Fred = 1;
}
sub sub2() {
$Fred = 2;
}
Now, the same holds true here. $Fred is not a global -- if
it were meant to be such, the my wouldn't have been used.
But nothing outside its scope can see it. The two functions
there, however, ARE NESTED WITHIN THE SAME SCOPE. Here's
another example:
# this is Perl code
{
my $Fred = 20;
sub sub1() { $Fred = 1 }
sub sub2() { $Fred = 2 }
}
sub sub3() { $Fred = 3 }
Now you have an interesting demo: sub3 is not in the same scope as
sub1 and sub2. Thus sub3 has no access to the lexical $Fred which
they sub1 and sub2 are seeing. The scope of $Fred was closed off
and finished by the curley brace.
To be perfectly save, you should usually write that as a BEGIN
block to guarantee early initialization of $Fred.
# this is Perl code
BEGIN {
my $Fred = 20;
sub sub1() { return $Fred }
sub sub1() { $Fred = 1 }
sub sub2() { $Fred = 2 }
}
sub sub3() { $Fred = 3 }
Otherwise it might not be set to 20 before sub1 or sub2 get called.
In this case, it honestly doesn't matter for sub1 and sub2, since we
don't use that value, but sub0 would.
Ok, if you haven't gotten it yet, you probably never will, at least
so long as I'm the one explaining it. So I'll stop.
I wish I knew why scope so baffled beginning Perl programmers.
Haven't you ever had a block structured language before?
Remind me to mention closures someday.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
With a PC, I always felt limited by the software available. On Unix, I am
limited by my knowledge. --Peter J. Schoenster <pschon@baste.magibox.net>
------------------------------
Date: 25 Jan 1998 13:54:47 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: White Hats and Black
Message-Id: <6afg77$frc$1@csnews.cs.colorado.edu>
White Hats and Black
Thursday, 22 January 1998
Tom Christiansen
tchrist@perl.com
There is no question that today was a day packed full with far more than
merely its allotted share of news. We're heard the Unibomber confess his
hideous crimes. We've watched the Pope say Mass to his faithful in one
of the last remaining communist dictatorships. We've largely ignored for
a day or two the building pressure with Iraq. We've nearly overlooked
important visiting dignitaries from the ever-flammable Middle East.
We casually launched an American spacecraft in a spectacular nighttime
blast-off to meet up with our newfound non-enemies, the Russians.
We've watched Bill Gates finally blink in a game of chicken with the
Attorney General as Microsoft gave in to the government's demands in an
historic anti-trust suit, deftly and nearly belatedly dodge the falling
sword of an angry judge. And we've watched in sickened horror as the
tabloidish media frenzy threatens to unravel the American presidency.
Although some of today's stories may well eventually find their way
into future history books, none is so personally relevant to those of
us caught up in the Internet Revolution as the wholly unexpected press
release from Netscape Communications that not only will they be providing
their famous browser gratis as had been anticipated for several weeks
now, but that far beyond this, they are taking the unprecedented step of
releasing the full source code for that program. This is tremendously
exciting news for those of us in the freeware community, one that lends
credence to our entire ethic. For a while, it wasn't clear what color
hat Netscape was wearing. Few in the freeware community thought that
hat any lighter than a dirty grey, only a shade better than the black
hat perceived to rest upon Microsoft's corporate head.
That's all changed now.
Netscape is shrewd, more clever by half than they let on. Why did they
do this? Who benefits and who suffers? Think back to Eric Raymond's
thesis regarding two models of software development, the Cathedral and
the Bazaar. Eric notes that under the bazaar model, all bugs are shallow,
quickly evaporating under the scrutiny of infinite eyes. Furthermore, the
wonderfully diverse environment of that bazaar fosters rich creativity.
Suffering under the ever-tightening vise of Microsoft's monopoly of
the mediocre, Netscape has hit upon a solution none of us foresaw.
Netscape's quandary was simple: how to compete against an opponent
so flush with wealth and power that it dwarfs many sovereign nations?
The answer was brilliant in its simplicity, breathtaking in its audacity.
By releasing the source code of their browser, they return the browser
from its exile back to its roots, the freeware world of open systems
that created Mosaic.
The number of programmers in the world who do not work for Bill Gates far
exceeds those who do. That's where Netscape wins. A person will do for
love -- in this case, the love of creation, the respect of one's peers
-- what they will not do for money. The gift culture of uncounted free
programmers everywhere will now turn its eye to improving and extending
Netscape's browser. The fruits of those labors will be returned back
to the world, a free gift.
For the Perl community, several intriguing possibilities immediately
come to mind. The first and most obvious of these is that the door is
now open for a Perl-augmented browser that would allow us to use Perl
with Netscape much as Java and Javascript had been used previously.
If you've ever tried programming in those languages, you know why this
notion excites us. Another area for exploration may be cross-platform
graphical support. Netscape runs a common code base across Unix, Macs,
and Windows. Is this a technology that the whole net can benefit from?
It doesn't matter whether that technology is under some sort of license
to keep it freeware. After all, Perl is already freeware.
For that matter, so is Apache, the net's most popular web server. This
means that the World Wide Web's most popular web server, web browser,
and web programming language are now all available for free in full
source form. The synergistic interactions are certain to outshine all
possible closed, proprietary solutions. In their response to Netscape's
dramatic announcement today, Microsoft disingenuously asks just how easy
it will be to modify the Netscape source. The obvious answer is clear
and compelling: infinitely easier than it will be to modify Internet
Explorer's source.
Now in one bold stroke, Netscape is a contender again, one who has changed
the stakes and upped the ante in a way that Microsoft dare not follow.
Operating under a completely different set of principles than those which
dominate American corporate culture, the freeware gift culture awards
prestige and honor not by how many competitors you kill, nor by how much
money you earn, but rather by the value (usually determined by effort,
elegance, and usefulness) of what you give away. Under this ethic,
Netscape's prestige has just soared to unprecedented heights.
Tom Christiansen
tchrist@perl.com
BIBLIOGRAPHY:
Cathedral and the Bazaar paper
http://www.ccil.org/~esr/writings/cathedral-paper-1.html
Apache Web Browser
http://www.apache.org
Perl Programming Language
http://www.perl.com
Netscape Communications
http://www.netscape.com
--
Tom Christiansen tchrist@jhereg.perl.com
Unix is like a toll road on which you have to stop every 50 feet to
pay another nickel. But hey! You only feel 5 cents poorer each time.
--Larry Wall in <1992Aug13.192357.15731@netlabs.com>
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
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 1724
**************************************