[8421] in Perl-Users-Digest
Perl-Users Digest, Issue: 2038 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 5 22:07:33 1998
Date: Thu, 5 Mar 98 19:00:34 -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 Thu, 5 Mar 1998 Volume: 8 Number: 2038
Today's topics:
Codewright Programmer's Editor Supports Perl As Macro L (Nicholas Carey)
Re: complex reg expression help <beans@bedford.net>
Re: Connecting to a Database with Perl <mishra.aditya@emeryworld.com>
Extract URL from search query <scriptabuser@127.0.0.1>
Re: How to build perl Additional Modules <mishra.aditya@emeryworld.com>
Re: In defense of Netcom <dformosa@st.nepean.uws.edu.au>
Lost trying to compare two times larry@larrysbabes.com
Re: Need BMP to GIF converter Howard.Cohodas@dkt.com
Re: overreached my grasp of references <mishra.aditya@emeryworld.com>
Re: padding a file -- Better way?? (Craig Berry)
Passing Formats? (Dave Hightower)
Re: passing wildcard file args to NT perl script jason@dtlweb.com
Re: Perl & Personal Web Server <sowmaster@juicepigs.com>
Perl Script count lines of c/c++ code <gibson@doitnow.com>
Re: Portable I/O Multiplexing <mishra.aditya@emeryworld.com>
Re: Portable I/O Multiplexing (dave)
Re: problems with one-liners on the command line <fearless@nospam.io.com>
Re: Quoting ^M? <fearless@nospam.io.com>
Regular Expressions - Real Basic Help. (Bruce Blanchard)
Re: Special Characters <uri@sysarch.com>
Re: What is PERL? Learn JAVA instead? (Ilya Zakharevich)
Re: What is PERL? Learn JAVA instead? (Ilya Zakharevich)
Re: What is PERL? Learn JAVA instead? <evan@garrett.hpl.hp.com>
Re: What is PERL? Learn JAVA instead? <evan@garrett.hpl.hp.com>
Re: Why does <> discard value? <uri@sysarch.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 06 Mar 1998 01:01:44 GMT
From: a-bnc@microsoft.com (Nicholas Carey)
Subject: Codewright Programmer's Editor Supports Perl As Macro Language
Message-Id: <34ff46a9.18902734@newsvr>
I surfed through the web site of the company that makes my editor of
choice, Premia's Codewright [see http://www.premia.com ] yesterday.
They've got a new version (v5.1) coming out (the web page said 4
March, but...) and it appears that they've implemented Perl as one of
3 supported macro languages (Perl, MS AppBasic and some proprietary
language) for extending the editor. Plus, the existing technique of
extending the editor by building extension DLLs.
Joe Bob sez...Check It Out at http://www.premia.com -- I know I'm
going to be upgrading. Codewright is a very nice editor. Unfortunately
though, it's Windows NT/95/3.1 only -- *nix/Mac/OS2 guys are OOL.
Hmmm...maybe a Codewright-based mail/news reader with decent killfile
support. Hmmm...
N.
--
Who has absolutely NO CONNECTION with Premia in any way shape or form.
Except as a satisfied customer.
------------------------------
Date: 6 Mar 98 01:11:34 GMT
From: "TomH" <beans@bedford.net>
Subject: Re: complex reg expression help
Message-Id: <01bd4551$a9cb9180$3b9163ce@beans.bedford.net>
Mike Binkley <Zena_Goddess_Of_Fire@mindless.com> wrote in article
<Zena_Goddess_Of_Fire-0403982308430001@magmysmac.lfc.edu>...
> All right, I need to search a string for several regular expressions.
...
> but that is obviously not pretty, and I'd like to do it as elegantly as
> possible (preferably along the lines of the one line foreach up toward
the
> top).
One way is to put the full regular expression you are looking for into the
array. This moves the ugliness to where it belongs...
-Tom
################################
$\ = "\n";
$reg[0] = '(^|[^a-z])(end)([^a-z]|$)';
$reg[1] = '(.?)(;)(.?)';
$reg[2] = '(.?)(\+)(.?)';
$_ = "end of game do+ ;you surrender?";
foreach $re (@reg){
s/$re/$1 $2 $3/g;
}
print $_;
------------------------------
Date: Thu, 5 Mar 1998 17:06:15 -0800
From: "Mishra, Aditya" <mishra.aditya@emeryworld.com>
Subject: Re: Connecting to a Database with Perl
Message-Id: <6dng6e$2gd0@ljcqs003.cnf.com>
This question has been asked a million times here.
If you read the FAQ you would not ask this question...
Get DBI.(www.perl.com/CPAN-local/modules/by-module/DBI)
Get Oracle DBD (www.perl.com/CPAN-local/modules/by-module/DBD/)
get going!
Adi
------------------------------
Date: Fri, 6 Mar 1998 00:45:37 +0000
From: Mark Worsdall <scriptabuser@127.0.0.1>
Subject: Extract URL from search query
Message-Id: <8CRc6xDxc0$0EwXE@worsdall.demon.co.uk>
Hi,
I am trying to work out how to get url address to splitt. Note it could
be an address without subdirectorys or one with, i.e.:-
WITH: http://www.altavista.digital.com/cgi-bin
WITHOUT: http://www.altavista.digital.com
So using one of these modules I guess...
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;
use HTML::Parse;
use URI::URL;
but which one:-)
Below is an example of data given.
$referer = "http://www.altavista.digital.com/cgi-bin/query?pg=q&stq=50&w
hat=web&kl=XX&q=building+the+core+muscles+of+the+athalete&navig60.x=7&na
vig60.y=11";
--
Mark Worsdall (Webmaster) - WEB site:- http://www.shadow.org.uk
Shadow:- webmasterATshadow.org.uk
Home :- shadowwebATworsdall.demon.co.uk
Any opinion given is my own personal belief...
------------------------------
Date: Thu, 5 Mar 1998 17:08:59 -0800
From: "Mishra, Aditya" <mishra.aditya@emeryworld.com>
Subject: Re: How to build perl Additional Modules
Message-Id: <6dngbi$160o@ljcqs003.cnf.com>
Read the README with each module
....
tar -xvf urmodule
perl Makefile.PL
make
make test
make install
Adi
------------------------------
Date: 6 Mar 1998 00:14:16 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: In defense of Netcom
Message-Id: <889143255.458553@cabal>
In <889138842.523521@thrush.omix.com> Zenin <zenin@best.com> writes:
>Brand and Karina Hilton <bkhilton@netcom.com> wrote:
> >snip<
>: Netcom appears to be making more of an effort to deter
>: spammers. We received the following email yesterday:
> Yes, but not enough (IMHO). Isn't Netcom still under
> a UDP (Usenet Death Penalty) action?
No Netcom was given a reprive when there preformence improved, its even
left the probationary period (with time off for good behavour). However
IIRC it still hasn't solved its problem with mail relaying.
--
Please excuse my spelling as I suffer from agraphia see the url in my header.
Never trust a country with more peaple then sheep.
Support NoCeM http://www.cm.org/
I'm sorry but I just don't consider 'because its yucky' a convincing argument
------------------------------
Date: Fri, 06 Mar 1998 01:43:08 GMT
From: larry@larrysbabes.com
Subject: Lost trying to compare two times
Message-Id: <34ff5249.268245931@cnews.newsguy.com>
What I am trying to do is retrive a time from a file, compare
it with the current time. If enough time has not elapsed, exit the
script. Here is the snippet that is giving me the problem.
foreach (@database_array) {
@refferer_array= split(/\|/,$database_array[$matched]);
if ($refferer_array[5] eq $therefferer && $time -
$refferer_array[2] < $interval){
exit;
}
if ($refferer_array[5] eq $therefferer){
$refferer_array[0]++;
$refferer_array[1]++;
$refferer_array[2] = $time;
$refferer_array[3] = $date;
$refferer_array[4] = $wday;
@refferers_array = @refferer_array;
$found=1;
$foundurl = $matched;
}
$matched++;
}
If I comment out the first 'if' statement it works fine. Actually just
commented out the 'exit' allows the second 'if' statement to work. So,
no matter what $time is equal to the 'exit' is coming into play and
ending the script.
I would assume that the problem lies in the way I store the time
(refferer_array[2]), and the content of $time. Both represent the
time as huors:minutes:seconds. Is there a way to convert these
temporarily into seconds. Or, am I just going at it wrong.
Thanks in advance for any help.
Larry
------------------------------
Date: Thu, 05 Mar 1998 20:42:59 -0600
From: Howard.Cohodas@dkt.com
To: barg@nickel.as.arizona.edu
Subject: Re: Need BMP to GIF converter
Message-Id: <6dnnq3$ait$1@nnrp1.dejanews.com>
We sell an ActiveX dll (32-bit) GIF encoder that could very easily be packaged
as a command line program. Additionally, it does not contain the patented LZW
code so that a Unisys license is not required to use it.
Howard Cohodas
--
Design Knowledge Technologies Inc.
330.492.9900 (Voice)
330.492.1100 (FAX)
BMP2GIF otf_GIF Encoder: http://www.dkt.com/otfGIF
_______________________________________________________________________
In article <6def43$cfm$1@news.ccit.arizona.edu>,
barg@nickel.as.arizona.edu (Irene Barg) wrote:
>
> Hello,
>
> Has anyone written a Perl script to convert BMP to GIF (or JPEG)?
>
> Thanks,
>
> Irene Barg
>
> -------------------------------------------------------------------
> Irene Barg Email: ibarg@as.arizona.edu
> Steward Observatory Phone: 520-621-2602
> University of Arizona FAX: 520-621-1891
> Tucson, AZ 85721 http://nickel.as.arizona.edu/~barg
> -------------------------------------------------------------------
>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 5 Mar 1998 17:20:46 -0800
From: "Mishra, Aditya" <mishra.aditya@emeryworld.com>
Subject: Re: overreached my grasp of references
Message-Id: <6dnh1l$pcm@ljcqs003.cnf.com>
Is there a question/answer here or do you like to share your exasperation
with the perl community?
Adi
------------------------------
Date: 6 Mar 1998 00:50:25 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: padding a file -- Better way??
Message-Id: <6dnh8h$ej5$2@marina.cinenet.net>
John Porter (jdporter@min.net) wrote:
[snip]
: > @paddedval = (@paddedval, sprintf "%-80.80s", $_ );
[snip]
: Why do you have 80.80 ??? This works the same for me:
:
: sprintf("%-80s",$_)
Doesn't work the same if $_ is longer than 80 characters. The - means
'left justify'; the first 80 means 'pad to 80 characters width'; the
final .80 means 'truncate to 80 characters width'. Without the .80 part,
an 85 character $_ would remain 85 characters long on the output,
spoiling the formatting.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Thu, 05 Mar 1998 19:29:01 -0600
From: hightowr@usa.net (Dave Hightower)
Subject: Passing Formats?
Message-Id: <hightowr-0503981929010001@dial474.radiks.net>
OK, I'm stumped.
I have a perl module in which I'm doing some formatted printing. Now, the
format for this printing is subject to change, so I figured "hey! I'll
just put the format definition in another file and 'include' it!"
So, off I went, and created a text file "formats" in which it only
contains format definitions. No package name, no exporter, nothing like
that.
So how do I get my module to read the format? Is there any way to get
perl to just take a file and paste it in-place, much like an #include
directive?
I even tried making it a package, and EXPORTing the format name; no dice,
it complains that it can't find the subroutine <format name>.
Arrghh! Any and all help appreciated!
Dave Hightower
------------------------------
Date: Thu, 05 Mar 1998 18:16:59 -0600
From: jason@dtlweb.com
Subject: Re: passing wildcard file args to NT perl script
Message-Id: <6dnf8h$15$1@nnrp1.dejanews.com>
Very nice solution, and much better than the version I tried to cobble
together myself. And I'm glad to have learned of the existence of the PERL5OPT
environment variable, which seems to be a rather underdocumented
feature--I have not been able to find any reference to it in my Camel
book, nor in my Advanced Perl Programming book, nor in my perldoc and man page
documentation, nor in any of the FAQs at www.perl.com!
I'm worried, though, about having wild.pm included in every invocation of my
perl interpreter--I came across a posting (pasted at bottom) where someone had
found that it gets you into trouble one in a while, and it would be a hard
thing to track down.
So I tried modifying wild.pm into a wrapper program that one can use
selectively on a script when one wants to have wildcard completion:
-------------------------
# "wc.pl"
# wrapper program to do wild card expansion on NT command line
# Note; this version assumes that PATHEXT is set so that perl scripts can
# be run just with "script" rather than "perl script.pl"
use File::DosGlob 'glob';
$script = shift;
@ARGV = map {
my @g = File::DosGlob::glob($_) if /[*?]/;
@g ? @g : $_;
} @ARGV;
system("$script @ARGV");
-----------------------------
With this progam I can run a script with wildcards like this:
wc script *.*
I would even be able to run
wc perl -e "print @ARGV;" *.*
except that the double quotes get ripped out somehow, and perl sees just
-e print @ARGV; *.*
which doesn't work...
Is there a solution to the doublequote problem, or am I better off just
setting my PERL5OPT variable and remembering to turn it off when I run into
trouble?
thanks,
Jason Duell
In article <34fda7a1.524144494f47414741@radiogaga.harz.de>,
MARTIN@RADIOGAGA.HARZ.DE wrote:
>
> jason@dtlweb.com wrote:
> : I'm just trying to write a simple script to do some text substitutions in
a
> : batch of files on NT, i.e, I want to be able to enter
> : perl myscript.pl *.txt
> : and have it run on all the .txt files in the directory. But instead I just
get
> : a pesky "Can't open *.*: No such file or directory" message.
> : I'm ftp-ing all my files up to my Unix box, where this syntax works, but
I'm
> : most curious to know if there is some easy way to accomplish the same
thing
> : on NT. It seems like such a common thing to need to do...
>
> Put the following into a path in @INC, SET PERL5OPT=-MWild, and there you
go.
> To give credit: I think it's from Gurusamy Sarathy, but I deleted the
reference.
>
> Hope it helps,
> Martin
>
> [--Wild.pm--]
> =pod
>
> =head2 Why won't my perl understand wildcards in arguments?
>
> The default command shells on DOS descendant operating systems (such
> as they are) usually do not expand wildcard arguments supplied to
> programs. They consider it the application's job to handle that.
> This is commonly achieved by linking the application (in our case,
> perl) with startup code that the C runtime libraries usually provide.
> However, doing that results in incompatible perl versions (since the
> behavior of the argv expansion code differs depending on the
> compiler, and it is even buggy on some compilers). Besides, it may
> be a source of frustration if you use such a perl binary with an
> alternate shell that *does* expand wildcards.
>
> Instead, the following solution works rather well. The nice things
> about it: 1) you can start using it right away 2) it is more powerful,
> because it will do the right thing with a pattern like */*/*.c
> 3) you can decide whether you do/don't want to use it 4) you can
> extend the method to add any customizations (or even entirely
> different kinds of wildcard expansion).
>
> C:\> copy con c:\perl\lib\Wild.pm
>
> =cut
>
> # Wild.pm - emulate shell @ARGV expansion on shells that don't
> use File::DosGlob 'glob';
> @ARGV = map {
> my @g = File::DosGlob::glob($_) if /[*?]/;
> @g ? @g : $_;
> } @ARGV;
> 1;
>
> =pod
> ^Z
> C:\> set PERL5OPT=-MWild
> C:\> perl -le "for (@ARGV) { print }" */*/perl*.c
> p4view/perl/perl.c
> p4view/perl/perlio.c
> p4view/perl/perly.c
> perl5.004_02/win32/perlglob.c
> perl5.004_02/win32/perllib.c
> perl5.004_03/win32/perlglob.c
> perl5.004_03/win32/perllib.c
> perl5.004_531/win32/perlglob.c
> perl5.004_531/win32/perllib.c
>
> Note there are two distinct steps there: 1) You'll have to create
> Wild.pm and put it in your perl lib directory. 2) You'll need to
> set the PERL5OPT environment variable. If you want argv expansion
> to be the default, just set PERL5OPT in your default startup
> environment.
---------------------
Footnote regarding perl Makefile.PL:
I use the Wild.pm package to allow dos to glob properly:
#Wild.pm - emulate shell @ARGV expansion on shells that don't
use File::DosGlob;
@ARGV = map { my @g = File::DosGlob::glob($_) if /[*?]/; @g?@g:$_ } @ARGV;
#Return 1 so this is true even if there are no parameters.
1;
This is set as the environment variable PERL5OPT=-MWild.pm
This causes the following problems
Use of uninitialized value at C:\PERL\lib/File/DosGlob.pm line 112.
Subroutine doglob redefined at C:\PERL\BIN/perlglob.bat line 30.
Subroutine glob redefined at C:\PERL\BIN/perlglob.bat line 112.
Subroutine import redefined at C:\PERL\BIN/perlglob.bat line 114.
t\quoted-print.t t\base64.tWriting Makefile for MIME::Base64
Simple to fix, remove the environment variable. May be of interest to
any others using the Wild.pm bits (wish I could remember the name of
the poster of this bit, you did save a life with that one).
--
Chris Searle
chris@searle1.demon.co.uk
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Thu, 05 Mar 1998 18:48:17 -0500
From: Bob Trieger <sowmaster@juicepigs.com>
To: Adam Carden <adam@pacific-artists.demon.co.uk>
Subject: Re: Perl & Personal Web Server
Message-Id: <34FF39C0.4B0D@juicepigs.com>
Adam Carden wrote:
>
> I currently design perl scripts however I find myself spending ages testing
> the scripts via telnet. I am running MS Personal Web server on Windows95.
> I can run perl scripts from the command line. What I wish to know is that
> is it possile to get perl(win32) running with ms personal webserver.
>
Yes, it is possible and the documentation for Personal Web server will
tell you how.
This is not a perl question and if you can't find your answer in the PWS
docs, try posting to news:comp.infosystems.www.authoring.cgi
HTH
Bob Trieger
sowmaster@juicepigs.com
------------------------------
Date: Thu, 05 Mar 1998 19:01:16 -0700
From: gip <gibson@doitnow.com>
Subject: Perl Script count lines of c/c++ code
Message-Id: <34FF58EC.390@doitnow.com>
Does someone have a script that counts lines of C and/or C++ code? Yeah
I know I can write it, but I thought it may have already been done ;}
Thanks for your time.
gibsonc@doitnow.com
------------------------------
Date: Thu, 5 Mar 1998 17:35:02 -0800
From: "Mishra, Aditya" <mishra.aditya@emeryworld.com>
Subject: Re: Portable I/O Multiplexing
Message-Id: <6dnhse$182s@ljcqs003.cnf.com>
use IO::Select;
perldoc IO::Select
Adi
------------------------------
Date: Fri, 06 Mar 1998 01:50:42 GMT
From: meet@the.zoo (dave)
Subject: Re: Portable I/O Multiplexing
Message-Id: <34ff562b.7199008@news.isoc.net>
On Thu, 5 Mar 1998 17:35:02 -0800, "Mishra, Aditya"
<mishra.aditya@emeryworld.com> wrote:
>use IO::Select;
>perldoc IO::Select
>Adi
>
>
I tried this with Win 95 and it didn't work the first time. Are you
sure select() works on Win32?
Dave
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dlripberXisoc.net (sub X with shunned char)
http://www.isoc.net/dlripber
/--\./==\./ee\./oo\./--\
------------------------------
Date: Thu, 5 Mar 1998 16:34:16 -0800
From: "Creede Lambard" <fearless@nospam.io.com>
Subject: Re: problems with one-liners on the command line
Message-Id: <6dngdp$ek8@news.microsoft.com>
If you just type
perl
at the command line and hit Enter, Perl will wait to receive its commands
from standard input (i.e., you have to type them in). To finish typing and
run your script, end the process with your system's end-of-file marker
(control-D in Unix/Linux, control-Z in Windows/DOS/OS2, I-forget-what in
MacPerl). So, you could type these lines from the shell prompt to run the
world's 43rd most pointless script:
$ perl
prit "Hello, world.\n";
print "How are you today? ";
$input = <STDIN>;
print "That's nice.\n";
^D
I'm really not sure why you'd do this, though, if only for the simple reason
that if you make a typo on line 1 (like I did) you have to start all over
again.
-- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl
Kevin B Cohen <kcohen@julius.ling.ohio-state.edu> wrote in message
news:6dnag5$fcv@julius.ling.ohio-state.edu...
>i've never been able to get the hang of running one-liners on the
>command line (much less the >1-liners that apparently are possible!).
>i can pull off a substitution (thanks to tchrist) with something like
>
>perl -pi.bak -e s/foo/bar/g; myfile.txt
>
>but i can't manage much else. i'm trying to do a little grep-like
>operation---say, finding and printing any word in a one-word-per-line
>file that contains "ea" followed by 1 to 3 consonants. here's a bunch
>of stuff that DOESN'T work:
>
>perl -p -e /ea.{1,3}/ && print $_; lexicon.txt
>perl -p -e m/ea.{1.3}/ && print $_; lexicon.txt
>perl -p -e if(m/ea.{1,3}/) {print $_; } lexicon.txt
>perl -p -e if(m/ea{1,3}/) {print $_ }; lexicon.txt
>perl -p -e if(m/ea{1,3}/) {print $_; }; lexicon.txt
>perl -p -e if(m/ea{1,3}/) {print $_ } lexicon.txt
>
>so, those are my attempts at one-liners. i can't even imagine a
>multi-line attempt; when would it start running??
>
>kevin
>
>
------------------------------
Date: Thu, 5 Mar 1998 16:36:52 -0800
From: "Creede Lambard" <fearless@nospam.io.com>
Subject: Re: Quoting ^M?
Message-Id: <6dngik$fut@news.microsoft.com>
Or you can try
s/\015//g;
\015 being octal for ^M. TIMTOWTDI
Steve Wells <steve@prilnari.com> wrote in message
news:34FF1265.4ADCFB3@prilnari.com...
>Jeff Stewart wrote:
>>
>> This probably isn't precisely Perl related, but can I use regular
>> expressions to wipe out all occurrences of ^M in a text file?
<snip>
>
> try: s/\cM//g;
>
------------------------------
Date: Fri, 06 Mar 1998 02:20:23 GMT
From: blanchard@nospam.aiov.com (Bruce Blanchard)
Subject: Regular Expressions - Real Basic Help.
Message-Id: <35024a43.12816553@news.nac.net>
Hi there,
I've read quite a bit about Perl(Lama & Camel & other books). And I can
figure our everything except regular expressions.
I understand how they work and how to code them, but what I don't understand
is how once I know I found a match, to grab information around the area.
I.e.
If a file contained lines with a keyword followed by an equal sign then the
value, I know how to set up the expression to find if the line has the value
just not how to grab the value(I know in this example it would be easier to use
split() ).
Any one??
- Bruce - blanchard@nospam.aiov.com
Remove nospam from address to reply
------------------------------
Date: 05 Mar 1998 19:52:42 -0500
From: Uri Guttman <uri@sysarch.com>
To: abigail@fnx.com
Subject: Re: Special Characters
Message-Id: <x7pvk0wsh1.fsf@sysarch.com>
abigail@fnx.com (Abigail) writes:
>
> Puzzle: How do I escape $, @ and \ in interpolative strings without using \?
print "@{[q|ab$c\@d|]}\n" ;
prints
ab$c\@d
but you can't have \ as the last char since it escapes the closing |
quote. it's ugly but solves the puzzle.
abby, you are a perl hacker after my heart,
uri
--
Uri Guttman SYStems ARCHitecture and Software Engineering
uri@sysarch.com Have Perl, Will Hack
http://www.sysarch.com (781) 643-7504 x*2 FAX: (781) 643-2710
Try the Best Search Engine on the Net --------> http://www.northernlight.com
------------------------------
Date: 6 Mar 1998 00:01:32 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <6dnecs$2ig$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <6dn8pb$pss$1@csnews.cs.colorado.edu>:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> :Perl has no (and will not have in any forseeable future) garbage
> :collection.
>
> You have a queer idea of garbage collection. Reference
> counting is GC. You want a different flavor of it, that's all.
GC should collect. Perl does not (unless in DAG situation, or after
termination, when it is - typically - too late).
Perl reference handling *is* cool, but only until you hit into its
limitations - exactly what Perl was designed to be not.
Ilya
------------------------------
Date: 6 Mar 1998 00:42:14 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <6dngp6$77r$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Abigail
<abigail@fnx.com>],
who wrote in article <6dnbdl$lq2$3@client2.news.psi.net>:
> Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on 1647 September 1993
> ++ Perl has no (and will not have in any forseeable future) garbage
> ++ collection. There is some vague talk on p5p about adding
> ++ user-triggered garbage collection, but I did not see any viable
> ++ approach so far.
>
>
> So, the pages 299 - 301 of the Camel are wrong?
No idea. Do not have it.
Judging by other sources (say L<perlobj/Two-Phase Garbage Collection>)
I would expect quite low proportion of marketing tricks in the new
Camel (in the above reference all but the name is up to the notch).
However, even if it is true *in letter*, it is probably not true *in
spirit*, since it made you come to wrong conclusions.
Ilya
------------------------------
Date: 05 Mar 1998 09:53:08 -0800
From: Evan Kirshenbaum <evan@garrett.hpl.hp.com>
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <v9hogzlm3cr.fsf@garrett.hpl.hp.com>
abigail@fnx.com (Abigail) writes:
> Evan Kirshenbaum (evan@garrett.hpl.hp.com) wrote on 1646 September 1993
> in <URL: news:v9hogzmm84n.fsf@garrett.hpl.hp.com>:
> ++
> ++ I do a lot more Perl programming than Java programming (and both are
> ++ dwarfed recently by C++), but I think I've done enough of both to be
> ++ qualified to hold an opinion.
> ++
> ++ That being said, two things that are easy to do in Java but
> ++ exceedingly difficult to do in Perl include:
> ++
> ++ - Work with cyclic structures. (AFAIK, Perl still uses
> ++ reference counting rather than true garbage collection, and so
> ++ cannot reclaim them automatically.)
>
> Bullocks. Perl does have true garbage collection, and more precisely,
> you know exactly when it kicks in.
I'm delighted to hear it, and running a test, this does appear to now
be the case. I was basing my assumption on Srinivasan's _Advanced
Perl Programming_, which I thought to be an accurate source of
information. On pp. 18-19, he discusses reference counting in Perl
and makes special mention of the problem of circular references
causing graphs not to get freed. Much the same warning is on p. 299
of the blue camel: "When building recursive data structures, you'll
have to break the self-reference yourself explicitly if you don't care
to cause a memory leak". I think I can be forgiven for my
misunderstanding.
On second thought, it appears that I may be being to charitable. A
reading of perlobj points out that yes, there is true garbage
collection going on, but it happens *only* at interpreter shutdown (by
running a mark/sweep). A test confirms that this appears to be what
happens. This does guarantee that destructors are (eventually)
called, but it also means that a program that needs to repeatedly
build large temporary graphs is still going to find itself rapidly
growing and/or running out of memory due to uncollected garbage.
> ++ - Anything involving multiple threads of control.
> ++
> ++ I understand that this last will *finally* be addressed in Perl in the
> ++ near future..
>
> Yes, but threads are overhyped (just like Java). Many things don't
> really need threads.
And a fair number do. Those tasks are far easier to program in Java
(or C++).
Recall that the challenge was to find two things easier to do in Java
than in Perl. I think I can stand by my examples.
Please remember, I really do prefer Perl for most tasks. That doesn't
mean that I don't think that it's perfect or can't be improved. I
have several tasks on hold awaiting the release of a multithreaded
version.
--
Evan Kirshenbaum +------------------------------------
HP Laboratories |A handgun is like a Lawyer. You
1501 Page Mill Road, Building 1U |don't want it lying around where
Palo Alto, CA 94304 |the children might be exposed to
|it, but when you need one, you need
kirshenbaum@hpl.hp.com |it RIGHT NOW, and nothing else will
(650)857-7572 |do.
| Bill McNutt
http://www.hpl.hp.com/personal/Evan_Kirshenbaum/
------------------------------
Date: 05 Mar 1998 11:34:35 -0800
From: Evan Kirshenbaum <evan@garrett.hpl.hp.com>
Subject: Re: What is PERL? Learn JAVA instead?
Message-Id: <v9hlnuplyno.fsf@garrett.hpl.hp.com>
John Porter <jdporter@min.net> writes:
> Evan Kirshenbaum wrote:
> >
> > That being said, two things that are easy to do in Java but
> > exceedingly difficult to do in Perl include:
> >
> > - Work with cyclic structures. (AFAIK, Perl still uses
> > reference counting rather than true garbage collection, and so
> > cannot reclaim them automatically.)
>
> The Camel has a nice section on gc. I suggest you read it.
I have. It says that during a run, all you get is reference counting,
and therefore cyclic garbage stays garbage. When the interpreter
dies, you get a mark/sweep. Until then, your process grows, and your
destructors don't free up resources. Having spent a lot of time in
the lisp world, I'd call this a far cry from true garbage collection,
and the somewhat wistful footnote on p. 300 leads me to believe that
Larry thinks the same.
> > There are a number of things that are more convenient in Java but
> > doable in Perl
>
> > (reflection,
>
> Ha. Perl has no need of "reflection" (java's hacked API which
> enables dynamic introspection) as a distinct capability,
> because perl is a dynamic language from the ground up;
> perl supports introspection (call it dynamic if you want)
> intrinsically.
Perl is very good at "try it and cope if it's undefined", which is one
of the uses for reflection. It is less good at enumerating *what*
methods are defined for an object. I'm pretty sure that it can be
done by going through the symbol tables for the package, but I'd count
this as "less convenient". Another reflection question I have is
whether, without resorting to symbolic references, one can get a
reference to a sub such that when invoked on an object, the
appropriate overridden instance is called.
> > exception handling,
>
> The following is semantically equivalent to try/throw/catch.
> Have you ever done this in your code?
>
> eval { # "try"
> $r = &some_func();
> if ( $r ) {
> die 'yikes'; # "throw"
> }
> }
> if ( $@ eq 'yikes' ) { # "catch"
> # ...
> }
Yes, I have. There are a couple of differences between this and (what
I'd consider) true exception handling. The first is that your
exceptions can only be strings, rather than things that contain data.
Granted, the string can be used as the key into some table somewhere,
but then you have to remember to take the object out of the table or
it won't get reclaimed.
Second, and more important, in Perl, I have to catch at every level
and rethrow if the exception isn't of the correct class, while in Java
or C++, the language itself guarantees that only the handler at the
correct level is executed.
Third, code within an eval cannot do a return.
Finally, in Java there is the notion of the "finally" clause that
ensures that cleanup is handled correctly on the path from the throw
to the catch or, alternatively, by the normal return.
> > switch statements,
>
> I -- and I think most perl programmers would agree -- find
> no inconvenience whatsoever is perl's multi-way braching
> capability.
Perhaps I'm an exception. I've run into bugs several times saying
SWITCH:
{
if ($a eq "foo") { $x = 1; last SWITCH; }
if ($a eq "bar") { $y = 25; last SWITCH; }
if ($a eq "baz") { $z = "nope"; last SWITCH; }
die "None matched";
}
Generally I run into problems when the name of the variable being
switched over changes and the change isn't reflected in all the cases.
I will admit that this has gotten considerably better (in terms of
clarity and maintainability) now that we can say things like
sub switch
{
&{$_[1]->{$_[0]} || $_[2]};
}
$a = "a";
switch($a,
{"a" => sub { print "It's an a\n"; },
"b" => sub { print "It's a b\n"; }},
sub { print "Nothing\n"; });
but this imposes new restrictions (can't return from the external
context within a branch), and probably can't be optimized.
--
Evan Kirshenbaum +------------------------------------
HP Laboratories |The misinformation that passes for
1501 Page Mill Road, Building 1U |gospel wisdom about English usage
Palo Alto, CA 94304 |is sometimes astounding.
kirshenbaum@hpl.hp.com
(650)857-7572
http://www.hpl.hp.com/personal/Evan_Kirshenbaum/
------------------------------
Date: 05 Mar 1998 19:58:38 -0500
From: Uri Guttman <uri@sysarch.com>
To: dlripber@isoc.net
Subject: Re: Why does <> discard value?
Message-Id: <x7lnuows75.fsf@sysarch.com>
unspamproofed since i got bounced! they will find you now!
dlripber@isoc.net (dave) writes:
> Why does <> only put value in $_ when it is used with "while"
> statement?
because it does! why ask why?
uri
--
Uri Guttman SYStems ARCHitecture and Software Engineering
uri@sysarch.com Have Perl, Will Hack
http://www.sysarch.com (781) 643-7504 x*2 FAX: (781) 643-2710
Try the Best Search Engine on the Net --------> http://www.northernlight.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 2038
**************************************