[12466] in Perl-Users-Digest
Perl-Users Digest, Issue: 6066 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 20 15:07:19 1999
Date: Sun, 20 Jun 99 12:00:20 -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 Sun, 20 Jun 1999 Volume: 8 Number: 6066
Today's topics:
Re: %IS THIS SCRIPT ANY GOOD ?% %IS THIS SCRIPT ANY GOO (sam@cheapnet.co.uk)
Re: 'Perl core' or 'perl core'? (Larry Rosler)
Re: 'Perl core' or 'perl core'? (Abigail)
About Apache Configuration (Ryan Ngi)
Re: About Apache Configuration <rootbeer@redcat.com>
Re: About Apache Configuration (Marcel Grunauer)
converting to eps file <ak@lets-print.de>
Re: converting to eps file <rootbeer@redcat.com>
Re: Cure for document deficiency (Dave Cross)
Re: function to read a line & return it (Larry Rosler)
Re: Having trouble making this work... <portboy@home.com>
Re: HOW DO I PAD A STRING IN PERL?? <bowman@montana.com>
Re: HOW DO I PAD A STRING IN PERL?? (Abigail)
How to remove space weicai@my-deja.com
I need a short sample which uses UNIX sendmail to send (Ron)
Re: I need a short sample which uses UNIX sendmail to s <tchrist@mox.perl.com>
Interpreting MS-ASCII - anyone have a filter? (Kenny McCormack)
Newbie help on complexity management? <jbc@shell2.la.best.com>
Re: Perl 2 C translator available? <firespring@nfx.net>
Perl breaks after install; not finding "require" files <greg@gpconsulting.com>
perlcc problem with subroutines <firespring@nfx.net>
Re: perlcc problem with subroutines <sb@sdm.de>
Re: Printing compound variables (?) (Marcel Grunauer)
Re: Problem installing 5.005_03 under Solaris FIXED <aperrin@mcmahon.qal.berkeley.edu>
Problem with DB_File (Anno Siegel)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 20 Jun 1999 16:41:57 GMT
From: sam@cheapnet.co.uk (sam@cheapnet.co.uk)
Subject: Re: %IS THIS SCRIPT ANY GOOD ?% %IS THIS SCRIPT ANY GOOD ?%
Message-Id: <376d19a3.115198437@news.cheapnet.co.uk>
On Sun, 20 Jun 1999 06:46:00 -0700, moseley@best.com (Bill) wrote:
>In article <376c91be.80404466@news.cheapnet.co.uk>, sam@cheapnet.co.uk
>says...
>> this is my first PERL script - i have been learning for 6 days.
>> it works fine but is it good or crap ?
>
>My internal parser crashed and returned "failed to 'use strict'"
>
>But I'd guess the answer is if it solves your problem correctly then it
>is perfect.
which platform and version of perl ?
i am using activestate 517 on NT 4 .
------------------------------
Date: Sun, 20 Jun 1999 08:41:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: 'Perl core' or 'perl core'?
Message-Id: <MPG.11d6ab8fec3fc07d989c04@nntp.hpl.hp.com>
In article <tx0b3.114$E4.55726@vic.nntp.telstra.net> on Sun, 20 Jun 1999
16:44:40 +0930, Wyzelli <wyzelli@yahoo.com> says...
> Larry Rosler <lr@hpl.hp.com> wrote in message
> news:MPG.11d62948512f8fc989c02@nntp.hpl.hp.com...
> > Uri Guttman and I are completing a paper for the upcoming Perl
> > Conference in Monterey, on new efficient sorting techniques. We
> > disagree on the capitalization in the following paragraph, and are
> > trying to get a consensus from the wise heads in this newsgroup.
> >
> > "Even the simplest custom sort in Perl will be less efficient than using
> > the default comparison. The default sort runs entirely in C code in the
> > [Pp]erl core, but any sortsub must execute Perl code. A well-known
> > optimization is to minimize the amount of Perl code executing and to try
> > to stay inside the [Pp]erl core as much as possible. Later we will show
> > various optimization techniques for Perl sorts that will reduce the
> > amount of Perl code executed."
> >
> > So, which should it be, 'Perl core' or 'perl core'?
...
> It is Perl everywhere else... why would it be perl?
perlfaq1: What's the difference between "perl" and "Perl"?
One bit. Oh, you weren't talking ASCII? :-) Larry now uses ``Perl'' to
signify the language proper and ``perl'' the implementation of it, i.e.
the current interpreter. Hence Tom's quip that ``Nothing but perl can
parse Perl.'' You may or may not choose to follow this usage. For
example, parallelism means ``awk and perl'' and ``Python and Perl'' look
ok, while ``awk and Perl'' and ``Python and perl'' do not. But never
write ``PERL'', because perl isn't really an acronym, aprocryphal
folklore and post-facto expansions notwithstanding.
> My vote is in...
Maybe you want another shot at it. There *is* a difference.
> Oh sorry you said 'wiser heads'... That excludes me... lol
No, I said 'wise heads'. Make your own value judgment.
> :^)
:-))
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 20 Jun 1999 03:16:31 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: 'Perl core' or 'perl core'?
Message-Id: <slrn7mp8qr.ch1.abigail@alexandra.delanet.com>
Larry Rosler (lr@hpl.hp.com) wrote on MMCXIX September MCMXCIII in
<URL:news:MPG.11d62948512f8fc989c02@nntp.hpl.hp.com>:
,,
,, So, which should it be, 'Perl core' or 'perl core'?
I would say 'perl core', as it refers to the actual binary, which Larry
(the other one) wishes to be identified as 'perl'.
But I only support this view for 65%.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 20 Jun 1999 07:27:05 GMT
From: ryanngi@hotmail.com (Ryan Ngi)
Subject: About Apache Configuration
Message-Id: <376c9773.663439@news.inet.co.th>
i'm setting Linux Apache 1.3.6 for runing CGI in the same directory of
HTML data: i use
Alias /funfunfun "/home/www/funfunfun"
ScriptAlias /funfunfun "/home/www/funfunfun"
......it's not work!...... it can only show html, but not cgi
if use
ScriptAlias ..........
Alias ...........
it can only show cgi but not html
please suggest
------------------------------
Date: Sun, 20 Jun 1999 10:41:15 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: About Apache Configuration
Message-Id: <Pine.GSO.4.02A.9906201040270.20762-100000@user2.teleport.com>
On Sun, 20 Jun 1999, Ryan Ngi wrote:
> Subject: About Apache Configuration
You seem to need the help of the docs, FAQs, and newsgroups about Apache
and other webservers. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 20 Jun 1999 17:26:37 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: About Apache Configuration
Message-Id: <377423e2.28031266@enews.newsguy.com>
On Sun, 20 Jun 1999 07:27:05 GMT it came to pass that
ryanngi@hotmail.com (Ryan Ngi) produced 18 lines that required the
following response:
>i'm setting Linux Apache 1.3.6 for runing CGI in the same directory of
>HTML data: i use
>
>Alias /funfunfun "/home/www/funfunfun"
>
>ScriptAlias /funfunfun "/home/www/funfunfun"
>
>......it's not work!...... it can only show html, but not cgi
>
>if use
>
>ScriptAlias ..........
>
>Alias ...........
>
>it can only show cgi but not html
>
>please suggest
I suggest you try a newsgroup that's concerned with Apache, like
comp.infosystems.www.servers.unix
Marcel
------------------------------
Date: Sun, 20 Jun 1999 18:30:24 +0200
From: "Anja Krause" <ak@lets-print.de>
Subject: converting to eps file
Message-Id: <7kj4vn$9tg$1@newsreader.ipf.de>
Hi to all,
we have read a few weeks ago that it will be possible to convert content of
a form into eps file automaticly by cgi. Everyone knows this will be true?
We can't find message again.
Thanks.
Pit
------------------------------
Date: Sun, 20 Jun 1999 09:56:33 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: converting to eps file
Message-Id: <Pine.GSO.4.02A.9906200955590.20762-100000@user2.teleport.com>
On Sun, 20 Jun 1999, Anja Krause wrote:
> we have read a few weeks ago that it will be possible to convert
> content of a form into eps file automaticly by cgi. Everyone knows
> this will be true? We can't find message again.
Maybe the message is in a newsgroup about the web, or about eps. Good
luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sun, 20 Jun 1999 15:07:19 GMT
From: dave@dave.org.uk (Dave Cross)
Subject: Re: Cure for document deficiency
Message-Id: <3772033d.15597364@news.demon.co.uk>
On Sun, 20 Jun 1999 07:22:39 -0700, moseley@best.com (Bill) wrote:
>In article <6t6b3.126$E4.56959@vic.nntp.telstra.net>, wyzelli@yahoo.com
>says...
>> Surely Tom could implement something similar to the FAQ autoposts making use
>> of Perl to scan for silly questions and then perform the appropriate e-mail
>> function...
>
>You know, in comp.infosystems.www.authoring.cgi I think your first
>message is not posted to the group. Instead you receive an email telling
>you to check the FAQs.
>
>I think Tom could implement something similar. Except the email could
>include copies of Programming Perl, Perl Cookbook, and Learning Perl.
There's already a message that gets sent out to first time posters to
this newsgroup which covers all of the obvious (?) advice on where to
get help.
>BTW -- If the documentation is so damn good, then why are those books so
>popular? Oh, I guess there is still room in this world for good
>teachers.
Also it's difficult to read the online docs in the bath or on the
train.
Dave...
--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>
------------------------------
Date: Sun, 20 Jun 1999 08:27:54 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: function to read a line & return it
Message-Id: <MPG.11d6a8322228167a989c03@nntp.hpl.hp.com>
In article <7ki1ra$2ke3@nrn2.NRCan.gc.ca> on Sun, 20 Jun 1999 02:29:33 -
0400, John A. Grant <zjagrantz@znrcanz.gcz.ca> says...
...
> On the issue of whether or not to supply EXPR with 'return',
> the docs for return say:
> "If no EXPR is given, returns an empty list in a list
> context, an undefined value in a scalar context, or
> nothing in a void context"
>
> It seems 'fragile' to rely on it getting the proper context to
> determine what "return;" should actually return. After all,
> "sub" doesn't exactly specify the type of the returned value.
> I'm not used to letting the interpreter make these decisions.
You can use the 'wantarray' function inside the subroutine, to make your
own decisions based on the calling context.
> Also, if the caller is explicitly testing for "eq undef" or if using
> defined(), I would think that the function should do an explicit
> "return undef" to match the explicitness of the test. Less prone
> to breakage?
In list context, 'return undef;' returns a list with one element, the
value of which is undef. 'return;' returns a list with no elements,
which is usually more appropriate.
> But Rick said:
> "...don't say
> return undef;
> because a plain
> return;
> will serve you better as a general rule."
>
> Can you elaborate on this in the context of my comments
> above about it being 'fragile' (IMO) and non-explicit?
The calling context is robustly determined. Why shouldn't it be? As
for explicitness, see my note above about 'wantarray'.
> Thanks for being gentle :).
Eric Bohlman says that you deserve it. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 20 Jun 1999 16:14:23 GMT
From: Mitch <portboy@home.com>
Subject: Re: Having trouble making this work...
Message-Id: <376D134B.8CDE6F84@home.com>
Jonathan Stowe wrote:
> On Sun, 20 Jun 1999 05:30:18 GMT Mitch wrote:
> >
> > Okay, I changed it to that. But when I'm printing it out the values, I get wierd
> > answers. here's how I'm printing it out.
> >
> > while (($var, $value) = each(%config)) {
> > print "the var is $var and value is $value\n";
> > }
> > And I'm getting answers like this:
> >
> > the var is coke and value is HASH(0x180998)
> > the var is pepsi and value is HASH(0x180a28)
> > the var is drpepper and value is HASH(0x1807e8)
> >
>
> The $value variable is a reference to a hash - you need to treat it
> appropriately :
>
> while (($var, $value) = each(%config)) {
> print "$var : \n";
> while (($key2,$value2) = each (%{$config}))
> {
> print "\tthe var is $key2 and value is $value2\n";
> }
> }
I tried it like this and got:
coke :
pepsi :
drpepper :
all of wihch are the variable names
> You can read about this sort of stuff in the perldata,perldsc and perlref
> manpages ...
>
I've read through those manpages, but I still can't get this to work. I think I"m
braindead or something. Why isn't this printing our properly? Also, how do I assign
(create) a new variable. So if I wanted:
mtdew rules - I could do that. Also, how do you go about deleting something like,
drpepper sucks?
.mitch
------------------------------
Date: Sun, 20 Jun 1999 09:35:42 -0600
From: bowman <bowman@montana.com>
Subject: Re: HOW DO I PAD A STRING IN PERL??
Message-Id: <376D0A4E.59574A1A@montana.com>
Andrew Johnson wrote:
>
> danger:jandrew:~]$ faqgrep pad
all that gets me is :
faqgrep: Command not found
------------------------------
Date: 20 Jun 1999 03:20:32 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: HOW DO I PAD A STRING IN PERL??
Message-Id: <slrn7mp92c.ch1.abigail@alexandra.delanet.com>
Uri Guttman (uri@sysarch.com) wrote on MMCXIX September MCMXCIII in
<URL:news:x7g13na28c.fsf@home.sysarch.com>:
%% >>>>> "TM" == Tad McClellan <tadmc@metronet.com> writes:
%%
%% TM> Perry Fecteau (perfecto@ct2.nai.net) wrote:
%% TM> : for example, i want 23 to look like 00023...
%%
%% TM> : how do i do that??
%%
%%
%% TM> $num = '000' . $num if $num == 23;
%%
%% substr( $num = '00000', 3, 2, 23) ;
$num = '00000';
$count = 23;
++ $num while $count --;
Abigail
--
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 20 Jun 1999 17:49:24 GMT
From: weicai@my-deja.com
Subject: How to remove space
Message-Id: <7kj9j1$lic$1@nnrp1.deja.com>
Hi, Friend
I am wondering if anyone know the right way to
remove the spaces at the begin of a new line
such as when you enter text in a text field in
HTML
the entered text is the following
" the begin has 15 space"
what I want is the folloing
"the bigin has 15 space"
Thanks
Wei
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Sun, 20 Jun 1999 17:31:24 GMT
From: e_ron.no.spam@netvision.net.il (Ron)
Subject: I need a short sample which uses UNIX sendmail to send mail. Anyone?
Message-Id: <376d2543.3149190@news.netvision.net.il>
------------------------------
Date: 20 Jun 1999 12:34:23 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: I need a short sample which uses UNIX sendmail to send mail. Anyone?
Message-Id: <376d342f@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
e_ron.no.spam@netvision.net.il writes:
>
I just sent you one with a program. Hope you like it.
--tom
--
"That's okay. Anyone whose opinion he cares about already knows that
he doesn't care about their opinion."
--Larry Wall
------------------------------
Date: 20 Jun 1999 12:22:59 -0500
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Interpreting MS-ASCII - anyone have a filter?
Message-Id: <7kj81j$83q$1@yin.interaccess.com>
In a recent religious war^W^Wthread about AWK vs. Perl, the subject of
the dreaded MS ASCII came up. Now, since a religious war would not be
complete w/o some MS bashing (probably the one thing upon which
AWKers and Perlies can agree on), I thought I'd continue the thread here.
Seriously, we all know that newbies frequently post text documents to
the net which have been prepared with MS-Word and have funny "High ASCII"
characters in them. I have, over the years, developed a filter (in GAWK)
to deal with this, by translating the two characters I know about - the
MS ASCII characters for the single and double quote marks. Then, I
simply delete all the other high ASCII chars.
I was wondering if anyone had actually done a full-implementation of
this idea - that is, one that is aware of all the MS funny chars, and
deals with each appropriately. I'm open to either an AWK or PERL (or,
lex, for matter) solution...
------------------------------
Date: 20 Jun 1999 17:19:57 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Newbie help on complexity management?
Message-Id: <376d22bd$0$228@nntp1.ba.best.com>
I'm looking for advice on the general subject of managing complexity
while writing software. I'm talking about very general advice here,
like choosing good variable names, avoiding namespace pollution, and
using subroutines with tidy interfaces.
The intended audience for this advice is the accidental programmer
camp; the amateurs using Perl for Web content creation and CGI scripts
and so on who don't have the benefit of the formal programmer's
training where I would assume this subject gets fairly extensive
coverage. I'm working on a tutorial-type resources for this particular
audience, and as someone who himself missed out on that formal
training, I'd appreciate any suggestions on the most important points
to cover.
Just to save us all time, I will stipulate that this question has
relatively little to do with Perl per se. I'm asking it here because
the particular target audience I have in mind is using Perl, not some
other language, and I think there might well be some Perl-specific
aspects to at least some of the answers (use/non use of -w and the
strict pragma, for example).
Anyway, I'm hopeful that anyone sufficiently annoyed by this level of
non-topicality will have configured his or her newsreader to filter out
articles with 'newbie' and 'help' in the subject line. Otherwise, feel
free to respond in whatever way you deem appropriate; droll asides on
the wrong-headedness of someone like me even trying to offer advice to
this particular audience will be appreciated almost as much as sincere
attempts to address the question.
Thanks.
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Sun, 20 Jun 1999 15:37:03 GMT
From: Rick Johnson <firespring@nfx.net>
Subject: Re: Perl 2 C translator available?
Message-Id: <376D0B62.185247AC@nfx.net>
Hello Armin,
I just learned of "perlcc" which is supposed to do what you want to do.
It is an integral part of PERL 5.005 on Linux and you can find details
in the man documentation. As far as other platforms go, I don't
know.
I'll also add that I just started using this last week and I have
NOT gotten it to work sucessfully yet, although I AM getting closer
(I can get it to compile, but not run.)
Rick Johnson
firespring@nfx.net
"Armin S. A. Roehrl" wrote:
>
> Dear Perl experts,
>
> suppose you got some Perl code -- too much to code it by hand into
> C, but would like to have a speed - up , o.k. if it's much less than
> hand-coded
> C code.
> I did a quick scan on the web, but didn't find any pointers. Is there
> sth. like
> a Perl-to-C translator?
> Do you have any book/links/online articles suggestions concerning Perl
> speed/performing
> issues.
>
> Thanks a lot for your input,
> Armin
------------------------------
Date: Sun, 20 Jun 1999 10:55:10 -0700
From: Greg Postlewait <greg@gpconsulting.com>
Subject: Perl breaks after install; not finding "require" files in @INC
Message-Id: <376D2AFE.10225D8D@gpconsulting.com>
I just upgraded by perl install from 4.x to the latest from activestate
(5.x). ALL of my scripts are now failing, so something has gone
terribly wrong. After reading as many FAQ's, tips, etc, I found the
"PerlIS-ERR.TXT" file in \bin which has helped a lot.
*** 'D:\inetpub\wwwroot\dworld\cgi-bin\job_editor.cgi' error message at:
1999/06/20 10:53:30
Can't locate dworld_globals.cgi in @INC (@INC contains: C:/PERL/lib
C:/PERL/site/lib .) at D:\inetpub\wwwroot\dworld\cgi-bin\job_editor.cgi
line 4.
JOB_EDITOR.CGI starts off as such...
#!/usr/bin/perl
require "dworld_globals.cgi";
require "job_services.cgi";
require "jobpagebuild_services.cgi";
#######################################
&parse_input(*form_fields);
$action = $form_fields{"action"};
if ($action eq ""){
&EditJob;
}
etc...
I've tried doing a chdir before the "require" statements, but that
doesn't work (neither does lib).
ANY ideas?
Thanks,
Greg Postlewait
------------------------------
Date: Sun, 20 Jun 1999 15:32:14 GMT
From: Rick Johnson <firespring@nfx.net>
Subject: perlcc problem with subroutines
Message-Id: <376D0A41.78197D55@nfx.net>
Hello,
I just started attempting to use perlcc with Redhat Linux 5.2 on an
Intel platform (Pentiume 133) and wondered if someone could help me
with a problem. Specifically, my perl code seems to compile okay using
perlcc, but it won't run. What is SEEMS to be choking on is
subroutine calls, even though it tells me the syntax of my code
was okay during the compile phase. What I get when I run my code
is a "segmentation fault" and a core dump. Note: I am NOT using any
modules and I have tested the problem by using a simple program which
does nothing except call a subroutine which prints "hello world".
HELP PLEASE!
Rick Johnson
firespring@nfx.net
------------------------------
Date: 20 Jun 1999 17:05:30 GMT
From: Steffen Beyer <sb@sdm.de>
Subject: Re: perlcc problem with subroutines
Message-Id: <7kj70q$1t1$1@solti3.sdm.de>
In article <376D0A41.78197D55@nfx.net>, Rick Johnson <firespring@nfx.net> wrote:
> I just started attempting to use perlcc with Redhat Linux 5.2 on an
> Intel platform (Pentiume 133) and wondered if someone could help me
> with a problem. Specifically, my perl code seems to compile okay using
> perlcc, but it won't run. What is SEEMS to be choking on is
> subroutine calls, even though it tells me the syntax of my code
> was okay during the compile phase. What I get when I run my code
> is a "segmentation fault" and a core dump. Note: I am NOT using any
> modules and I have tested the problem by using a simple program which
> does nothing except call a subroutine which prints "hello world".
Maybe you have that Linux Distribution with the broken Perl installation
I've heard rumors about.
Maybe you should try compiling Perl yourself!
Good luck!
Regards,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/
http://www.engelschall.com/u/sb/download/
http://www.perl.com/CPAN/authors/id/STBEY/
http://www.oreilly.de/catalog/perlmodger/bnp/
------------------------------
Date: Sun, 20 Jun 1999 18:03:08 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Printing compound variables (?)
Message-Id: <37752794.28977056@enews.newsguy.com>
On 19 Jun 1999 17:17:45 -0500 it came to pass that abigail@delanet.com
(Abigail) produced 66 lines that required the following response:
>David Cassell (cassell@mail.cor.epa.gov) wrote on MMCXVIII September
>MCMXCIII in <URL:news:376BF911.16AF42CE@mail.cor.epa.gov>:
>
>\\ [5] many of them have never programmed before, and hence have
>\\ no idea that there might be a better way than
>\\ $$fred = 23;
>
>Strange. I never get the impression beginning C or Pascal programmers
>ask for this.
I don't have much experience with C, but vividly remember Pascal from
the days of Turbo Pascal (way before Windows), but I don't remember
being able to create symbolic references, or having access to the
symbol table, or hashes, or any of the cool features of Perl.
So maybe when people first encounter these things, they go wild and
want to try them whether or not they're appropriate for the problem at
hand. Suddenly they forget all about arrays and hases and only want to
enjoy the newfound freedom.
Maybe.
Marcel
------------------------------
Date: Sun, 20 Jun 1999 09:14:35 -0700
From: Andrew J Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: Problem installing 5.005_03 under Solaris FIXED
Message-Id: <376D136A.E3C55375@mcmahon.qal.berkeley.edu>
Sorry for the premature fix - I dealt with it. Had to provide a path to the
gnu lib and include directories in Configure, and they're in odd places on
our system.
ap
Andrew J Perrin wrote:
> Greetings-
>
> Tried upgrading to 5.005_03 today on our Solaris 2.6 (sparc) system;
> everything appeared to work okay during configure, make, and make test,
> except that ld reported a bad flag -E; when I removed -E from the flags
> it compiled and tested fine; HOWEVER, now a script that has worked fine
> under 5.004 and uses (among other things) Socket.pm no longer works; it
> fails with the error:
>
> unsupported socket function "gethostbyname" called at mchp.pl line 205
>
> I suspect this has to do with the binary incompatibility between the two
> versions; any advice on how to proceed? All the libraries (including
> Socket.pm) were installed in their new locations, and these locations
> are appropriately in @INC.
>
> Thanks-
> Andy Perrin
>
> --
> -------------------------------------------------------------
> Andrew J. Perrin - NT/Unix/Access Consulting - (650)938-4740
> aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
> http://www.geocities.com/SiliconValley/Grid/7544/
> -------------------------------------------------------------
--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting - (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------
------------------------------
Date: 20 Jun 1999 18:52:09 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Problem with DB_File
Message-Id: <7kjd8p$2gh$1@lublin.zrz.tu-berlin.de>
Well, I'm having a whale ( tr/aew/el/d ) of a time debugging this
DB_File application. I'll reproduce a complete demo script at
the end, but the heart of the matter is this loop:
undef %b2w; undef %bag;
$wordcount = 0;
$bagcount = 0;
while ( $word = <W> ) {
$bag = bag_letters( $word);
if ( exists $b2w{ $bag} ) {
$b2w{ $bag} .= " $wordcount"; # Update entry in %b2w
} else {
$b2w{ $bag} = "$wordcount"; # New entry in %b2w...
$bag{ $bagcount++} = $bag; # ...and in %bag
}
$wordcount++;
}
You will agree that the way things are assigned to %b2w and %bag,
both should receive the same number of entries, no matter what the
function bag_letters returns. And they do if %b2w and %bag are
standard hashes. Yet, when they are tied to a DB_File database,
in the end a few keys are missing from the b2w hash; to be precise,
after running over the 45404 entries of my /usr/dict/words, %bag
contains 42156 entries while %b2w has only 42145, so eleven are
missing.
A few random notes:
1) Of course, the real program uses strict; I've done away with it
in an effort to shorten the code to the approved 40 lines. It
doesn't make a difference.
2) s/exists/defined/g doesn't make a difference either, as it shouldn't
with tied hashes.
3) The function bag_letter( $word) returns a string $bag where
vec( $bag, $i, 4) is the number of times the $i'th letter of
the alphabet occurs in $word, so $bag essentially contains
arbitrary binary data. I could not reproduce the effect of
"missing bags" using an alternative function that returns
printable strings. I could elaborate, but this is getting way
too long as is.
4) Of course, I've tried to catch the exact moment when a certain
key appears and disappears in the %b2w hash. In particular,
after identifying a bag $sample among the missing ones, I
inserted, at the beginning of the loop
$was_there = exists $b2w{ $sample};
and at the end something like
$is_there = exists $b2w{ $sample};
if ( $is_there and not $was_there ) {
print "sample appeared at word $wordcount\n";
}
if ( not $is_there and $was_there ) {
print "sample disappeared at word $wordcount\n";
}
I could see my samples appear alright but was never able to watch
a key disappear that way. In most cases, the key in question was
still missing *after* the end of the loop, though it never was
missing *at* the end of the loop, if you know what I mean.
In a few cases, a key that was normally missing would still be
visible when the loop was done. It's a bit as if the mere
asking for the existence is toggling the state of existence on
and off.
5) If anyone is still with me at this point, they may have guessed
what I'm up to with this script. I know there is excellent
anagram software out there, but where's the fun in that?
So, am I up against a... dare I say bug, in my implementation
of DB_File? Is there a restriction I should know of but don't?
Anno
-----------------------------------------------------------------------
[Below some hard data about my system, my perl, and a complete
demo script]
[anno4000@lublin ~]$ uname -a
Linux lublin.zrz.tu-berlin.de 2.0.36 #5 Fre Apr 23 14:43:16 CEST 1999 i586
[anno4000@lublin ~]$ cat /etc/redhat-release
Red Hat Linux release 5.2 (Apollo)
[anno4000@lublin ~]$ perl -v
This is perl, version 5.004_05 built for i386-linux
(with 1 registered patch, see perl -V for more detail)
[etc...]
#!/usr/bin/perl -w
use DB_File;
$word_source = '/usr/dict/words';
# Tieing the hashes
$bag_db = './bag.db';
$b2w_db = './b2w.db';
unlink( $bag_db, $b2w_db);
tie %bag, 'DB_File', $bag_db, O_CREAT|O_RDWR or
die "Can't tie to $bag_db\n";
tie %b2w, 'DB_File', $b2w_db, O_CREAT|O_RDWR or
die "Can't tie to $b2w_db\n";
# running the loop
open( W, $word_source) or die "Can't read $word_source: $!\n";
$wordcount = 0;
$bagcount = 0;
while ( $word = <W> ) {
printf "Doing lap %5d\n", $wordcount if $wordcount % 1000 == 0;
$bag = bag_letters( $word);
if ( exists $b2w{ $bag} ) {
$b2w{ $bag} .= " $wordcount";
} else {
$b2w{ $bag} = "$wordcount";
$bag{ $bagcount++} = $bag;
}
$wordcount++;
}
$n = keys %bag;
print "Hash 'bag' has $n keys\n";
$n = keys %b2w;
print "Hash 'b2w' has $n keys\n";
#############################################################
sub bag_letters {
local $_ = lc shift;
tr/abcdefghijklmnopqrstuvwxyz/\0\1\2\3\4\5\6\7\10\11\12\13\14\15\16\17\21\22\23\24\25\26\27\31/;
my $bag = '';
foreach my $l ( split '' ) {
vec( $bag, ord( $l), 4)++;
}
$bag;
}
__END__
------------------------------
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 6066
**************************************