[16685] in Perl-Users-Digest
Perl-Users Digest, Issue: 4097 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 22 18:05:45 2000
Date: Tue, 22 Aug 2000 15:05:26 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966981925-v9-i4097@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 22 Aug 2000 Volume: 9 Number: 4097
Today's topics:
Re: #ifdef filtering program ? sibban@my-deja.com
Re: #ifdef filtering program ? sibban@my-deja.com
Best General HTTP Proxy? <mkruse@netexpress.net>
Callback 1.02 - now with method invocation syntax (David Muir Sharnoff)
Re: Comparing the content of two files <lr@hpl.hp.com>
Re: Comparing the content of two files (Abigail)
Re: Cookie problem (chrs in value) <lr@hpl.hp.com>
Re: Cookie problem (chrs in value) (Abigail)
creating an enviroment variable <a58289@yahoo.com>
Re: creating an enviroment variable <tony_curtis32@yahoo.com>
Re: creating an enviroment variable <newsposter@cthulhu.demon.nl>
Diablo II site -> Diablo II Exchange <kernel@start.no>
Re: Direct screen access (Eric Bohlman)
errno 22 1024 char limit writing to DB's perlnewbie@my-deja.com
Re: errno 22 1024 char limit writing to DB's perlnewbie@my-deja.com
Re: Fork & Waitpid andrewjasper@my-deja.com
Re: Functions and reference notation. (Abigail)
gdbm_open() NOT Found - Please help! <OfficerS@aries.tucson.saic.com>
Re: Hash list comparing <lr@hpl.hp.com>
Re: help with simple regexp - does my head in <russ_jones@rac.ray.com>
Re: help with simple regexp - does my head in <ren.maddox@tivoli.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 22 Aug 2000 18:16:58 GMT
From: sibban@my-deja.com
Subject: Re: #ifdef filtering program ?
Message-Id: <8nug25$162$1@nnrp1.deja.com>
The program shall only filter any textfile according
to "define" flag(-s) passed as input arguments, regardless of
the file's content.
No preprocessing of any kind is wanted except for
handling of the mentioned #ifdef clauses that enclose
the text chunks to be filtered out (or preserved).
How would you prevent "language specific" preprocessors
from imposing semantics on the file content ?
In article <slrn8q5620.5ap.mgjv@martien.heliotrope.home>,
mgjv@tradingpost.com.au wrote:
> On Tue, 22 Aug 2000 14:22:58 GMT,
> sibban@my-deja.com <sibban@my-deja.com> wrote:
> > I was wondering if there exists a filtering program
> > already to process textfiles with C-style preprocessor
> > directives (even nested ifdefs) such as:
>
> It's called cpp, and if you have a C compiler installed it is
installed
> as well. Perl has the -P option, but that just uses the C
preprocessor,
> and only on the current source file.
>
> # perl -MCPAN -e shell
> cpan> i /cpp/
> Module id = Filter::cpp
> DESCRIPTION Filters script through C preprocessor
> CPAN_USERID PMQS (Paul Marquess <Paul.Marquess@btinternet.com>)
> CPAN_VERSION 1.01
> CPAN_FILE P/PM/PMQS/Filter-1.19.tar.gz
> DSLI_STATUS bdcf (beta,developer,C,functions)
> INST_FILE (not installed)
>
> But I would definitely use a real C preprocessor, if at all possible.
>
> Martien
> --
> Martien Verbruggen |
> Interactive Media Division | That's funny, that plane's dustin'
> Commercial Dynamics Pty. Ltd. | crops where there ain't no crops.
> NSW, Australia |
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 22 Aug 2000 18:19:56 GMT
From: sibban@my-deja.com
Subject: Re: #ifdef filtering program ?
Message-Id: <8nug7m$1f7$1@nnrp1.deja.com>
The program shall only filter any textfile according
to "define" flag(-s) passed as input arguments, regardless of the
file's content.
No preprocessing of any kind is wanted except for
handling of the mentioned #ifdef clauses that enclose
the text chunks to be filtered out (or preserved).
How would you prevent "language specific" preprocessors from imposing
semantics on
the file content ?
In article <slrn8q5620.5ap.mgjv@martien.heliotrope.home>,
mgjv@tradingpost.com.au wrote:
> On Tue, 22 Aug 2000 14:22:58 GMT,
> sibban@my-deja.com <sibban@my-deja.com> wrote:
> > I was wondering if there exists a filtering program
> > already to process textfiles with C-style preprocessor
> > directives (even nested ifdefs) such as:
>
> It's called cpp, and if you have a C compiler installed it is
installed
> as well. Perl has the -P option, but that just uses the C
preprocessor,
> and only on the current source file.
>
> # perl -MCPAN -e shell
> cpan> i /cpp/
> Module id = Filter::cpp
> DESCRIPTION Filters script through C preprocessor
> CPAN_USERID PMQS (Paul Marquess <Paul.Marquess@btinternet.com>)
> CPAN_VERSION 1.01
> CPAN_FILE P/PM/PMQS/Filter-1.19.tar.gz
> DSLI_STATUS bdcf (beta,developer,C,functions)
> INST_FILE (not installed)
>
> But I would definitely use a real C preprocessor, if at all possible.
>
> Martien
> --
> Martien Verbruggen |
> Interactive Media Division | That's funny, that plane's dustin'
> Commercial Dynamics Pty. Ltd. | crops where there ain't no crops.
> NSW, Australia |
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 22 Aug 2000 16:40:16 -0500
From: "Matt Kruse" <mkruse@netexpress.net>
Subject: Best General HTTP Proxy?
Message-Id: <39a2f2e5$0$11344@wodc7nh0.news.uu.net>
Hi,
I'm looking for the best example of a simple HTTP proxy. I've found several,
but they are mainly "hacks" and some are even written for Perl4. FilterProxy
seems like an option, yet is more sophisticated than I need to work with.
I'll probably default to that if I don't find anything more suited to my
needs.
MY GOAL:
I want a general "debugging" proxy. When browser<->Server communications
don't seem to be happening the way I expect (cookies, expires headers,
authentication, etc) I want to view exactly what is happening.
What I'd like to do is insert the request and response headers into the HTML
document at the top, as plain old text. It may look weird, but I don't
care - this is just for testing.
A Proxy that would correctly handle SSL would be a bonus.
Thanks.
--
Matt Kruse
http://www.mattkruse.com/
------------------------------
Date: 22 Aug 2000 11:33:50 -0700
From: muir@idiom.com (David Muir Sharnoff)
Subject: Callback 1.02 - now with method invocation syntax
Message-Id: <sq5id7met9123@corp.supernews.com>
Now available at a CPAN near you...
Thanks to Raphael Manfredi <Raphael.Manfredi@st.com> for
the method invocation syntax.
http://www.cpan.org/modules/by-module/Callback/Callback-1.02.tar.gz
-Dave
NAME
Callback - object interface for function callbacks
SYNOPSIS
use Callback;
my $callback = new Callback (\&myfunc, @myargs);
my $callback = new Callback ($myobj, $mymethod, @myargs);
$callback->call(@some_more_args);
DESCRIPTION
Callback provides a simple interface for function callbacks. It would be
possible to provide nearly all of the functionality using inline code
references. Callback was written before inline code references were
added to perl.
What callback does provide is a simple interface for common situation:
passing around a function.
When a callback is constructed, a base set of arguments can be provided.
These function arguments will preceed any arguments added at the time
the call is made.
There are two forms for the callback constructor, depending on whether
the call is a pure functional call or a method call. The rule is that if
the first argument is an object, then the second argument is a method
name to be called on that object.
TRACING
use Callback qw(@callbackTrace);
If you're writing a debugging routine that provides a stack-dump (for
example, Carp::confess) it is useful to know where a callback was
registered.
my $ct = 0;
while (($package, $file, $line, $subname, $hasargs, $wantarray) = caller($i++)) {
...
if ($subname eq 'Callback::call') {
print "callback registered $Callback::callbackTrace[$ct]\n";
$ct++;
}
}
Without such code, it becomes very hard to know what's going on.
COPYRIGHT
Copyright (C) 1994, 2000, David Muir Sharnoff. All rights reserved.
License hearby granted for anyone to use this module at their own risk.
Please feed useful changes back to muir@idiom.com.
--
--
Notice: Your mouse has been moved. Windows will now restart so this
change can take effect.
------------------------------
Date: Tue, 22 Aug 2000 11:28:41 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Comparing the content of two files
Message-Id: <MPG.140c663164c3506e98acbc@nntp.hpl.hp.com>
In article <39a983a1.49992780@news.newsguy.com> on Tue, 22 Aug 2000
13:48:14 GMT, Keith Calvert Ivey <kcivey@cpcug.org> says...
> "Minh Le" <lem@ocean.com.au> wrote:
>
> >The resulting file has shwon as follows:
> >
> >+ sdadas ( + sign indicates this row has been added in B file)
> >- fdsfdsd ( - sign inidcates this row has been deleted in B file)
> >! dsdasds ( ! sign indicates this row has been modified in B file)
> >
> >By using perl, can I extract the result into 3 different files, say,
> >mod.txt, del.txt and insert.txt.
>
> Something like this (untested), assuming you've opened the four
> files:
>
> while (<INPUT>) {
> print { /^!/ ? MOD :
> /^-/ ? DEL :
> /^\+/ ? INSERT :
> STDERR } $_;
> }
To get it past "use strict 'refs';", you must use typeglobs, not bare
filehandles.
*MOD, *DEL, ...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Aug 2000 20:22:57 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Comparing the content of two files
Message-Id: <slrn8q5o7m.tj3.abigail@alexandra.foad.org>
Minh Le (lem@ocean.com.au) wrote on MMDXLVIII September MCMXCIII in
<URL:news:8nth8s$lk6$1@perki.connect.com.au>:
-- Hi,
-- In my perl script, I'm using diff ( Unix command) to work out the difference
-- in content between the two text files say A and B. The A file is my
-- reference file and used to check if any row in file B has been modified,
-- deleted or added.
-- The resulting file has shwon as follows:
--
-- + sdadas ( + sign indicates this row has been added in B file)
-- - fdsfdsd ( - sign inidcates this row has been deleted in B file)
-- ! dsdasds ( ! sign indicates this row has been modified in B file)
--
-- By using perl, can I extract the result into 3 different files, say,
-- mod.txt, del.txt and insert.txt.
-- Your help will be very much appreciated .
Pipe the output of diff into this:
#!/opt/perl/bin/perl -wp
use strict;
use vars qw /%files/;
BEGIN {
foreach (qw /+insert -del !mod/) {
/./; open $files {$&} => "> $'.txt" or die "$'.txt: $!";
}
}
select $files {/./ and $&}
__END__
--
perl -wle 'eval {die ["Just another Perl Hacker"]}; print ${$@}[$#{@${@}}]'
------------------------------
Date: Tue, 22 Aug 2000 11:15:00 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Cookie problem (chrs in value)
Message-Id: <MPG.140c6300bf541ac798acba@nntp.hpl.hp.com>
In article <3535qssgp2t54ebbot2k3qgajotn1cn2ch@4ax.com> on Tue, 22 Aug
2000 15:52:36 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Randal L. Schwartz wrote:
>
> >Moral - stop using printf so much. I can't recall the number
> >of beginner programs that look like this:
> >
> > printf $string;
> >
> >Gah! Do they know what they just did? Scary.
>
> I personally would like printf() to be dropped from Perl, and leave only
> sprintf() in. The reason you quote is one reason. The fact that it is
> superfuous, is another. And thirdly, IMO, you should always format text
> into strings, and not print it out straight away. But that may be just
> my preference. You'd end up doing a lot of small writes to files, which
> isn't optimal, since each takes quite an overhead.
Why is that? What about buffering in the output routines?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Aug 2000 20:29:17 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Cookie problem (chrs in value)
Message-Id: <slrn8q5ojk.tj3.abigail@alexandra.foad.org>
Bart Lateur (bart.lateur@skynet.be) wrote on MMDXLVIII September MCMXCIII
in <URL:news:3535qssgp2t54ebbot2k3qgajotn1cn2ch@4ax.com>:
[] Randal L. Schwartz wrote:
[]
[] >Moral - stop using printf so much. I can't recall the number
[] >of beginner programs that look like this:
[] >
[] > printf $string;
[] >
[] >Gah! Do they know what they just did? Scary.
[]
[] I personally would like printf() to be dropped from Perl, and leave only
[] sprintf() in. The reason you quote is one reason. The fact that it is
[] superfuous, is another.
The fact that it's superfluous? THIS IS PERL! Perl is about convenience
for the programmer. If we'd remove anything that's redundant from Perl,
we'd end up with C. Without libc of course, because that's all redundant.
Heck, we might as well remove both printf and sprintf. After all, you have
print.
[] And thirdly, IMO, you should always format text
[] into strings, and not print it out straight away.
And why is that? Is that for the same reason you should always read in a
file in a string, and not process it line by line? I guess it's always
good to reach to all dusty little corners of your RAM chips. Can't make
them bits and bytes lazy.
[] But that may be just
[] my preference. You'd end up doing a lot of small writes to files, which
[] isn't optimal, since each takes quite an overhead.
Bullocks. That's why we've had stdio for decades.
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
------------------------------
Date: Tue, 22 Aug 2000 19:00:52 GMT
From: Aitor Garcia <a58289@yahoo.com>
Subject: creating an enviroment variable
Message-Id: <8nuikn$4hf$1@nnrp1.deja.com>
Hello everybody;
I'm a Perl newbie and I've got a little
question.
I want to create a new enviroment variable
and set a value to it.
I have tried the following code but it does
not work.
#!/usr/bin/perl
$ENV{"USE_NC"} = "1";
Can anyone help me with this ?
Best Regards,
Aitor
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 22 Aug 2000 14:14:24 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: creating an enviroment variable
Message-Id: <87d7j1m7lb.fsf@limey.hpcc.uh.edu>
>> On Tue, 22 Aug 2000 19:00:52 GMT,
>> Aitor Garcia <a58289@yahoo.com> said:
> Hello everybody; I'm a Perl newbie and I've got a little
> question. I want to create a new enviroment variable
> and set a value to it. I have tried the following code
> but it does not work.
> $ENV{"USE_NC"} = "1";
Well, you don't need all those quotes:
$ENV{USE_NC} = 1;
However, that is correct for setting an environment
variable in perl. What do you mean by "does not work"?
t
--
"I'm not easily impressed. Wow! A blue car!"
Homer Simpson
------------------------------
Date: 22 Aug 2000 19:13:59 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: creating an enviroment variable
Message-Id: <8nujdn$6qa$1@internal-news.uu.net>
Aitor Garcia <a58289@yahoo.com> wrote:
> Hello everybody;
> I'm a Perl newbie and I've got a little
> question.
> I want to create a new enviroment variable
> and set a value to it.
> I have tried the following code but it does
> not work.
> #!/usr/bin/perl
> $ENV{"USE_NC"} = "1";
> Can anyone help me with this ?
perlfaq8:
I {changed directory, modified my environment} in a perl
script. How come the change disappeared when I exited the
script? How do I get my changes to be visible?
Erik
------------------------------
Date: Tue, 22 Aug 2000 23:55:15 +0200
From: "Christopher Thorjussen" <kernel@start.no>
Subject: Diablo II site -> Diablo II Exchange
Message-Id: <8nusje$o3s$1@snipp.uninett.no>
http://www.diablo2exchange.net
------------------------------
Date: 22 Aug 2000 21:59:06 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Direct screen access
Message-Id: <8nut3a$dc0$6@slb3.atl.mindspring.net>
Teodor Zlatanov (tzz@iglou.com) wrote:
: <8nu1im$1b22$1@news2.vas-net.net>:Chris Denman (chris@inta.net.uk):comp.lang.perl.misc:Tue, 22 Aug 2000 15:07:10 +0100:quote:
: : I have tried to set a variable as an address to hex 0a000 and wrote a
: : charater to that address, but perl came back with errors, saying that this
: : area of memory has forbiden access.
:
: The new CPAN (http://www.cpan.org) Inline module is supposed to work on
: Windows machines. You can try using it for direct memory access - I've
: never tried it, and the Inline module is very new and might have bugs, but
: it still might be useful to you and easier to learn than XS.
That won't help. Under Win32, ordinary programs can't read or write
screen memory directly (only drivers with special privileges can), and in
any case the screen memory isn't organized the way it was under DOS.
Win32 does provide a "DirectX" API for high-performance graphics
applications, and using Inline to access *that* might be a possibility.
------------------------------
Date: Tue, 22 Aug 2000 18:27:14 GMT
From: perlnewbie@my-deja.com
Subject: errno 22 1024 char limit writing to DB's
Message-Id: <8nugl8$1ul$1@nnrp1.deja.com>
I am encountering an error when I try and write to a DB file in WinNT
using Active Perl. Here is the error message I receive:
"Tue Aug 22 09:54:07 2000: sdbm store returned -1, errno 22,
key "92"..."
It seems that I am only allowed to write a maximum of 1024 characters.
I was wondering if there is any way to work around this limitation?
Below is a code snippet of the function which is writing to the DB
file. By the way I am not the original author of this code I am just
trying to migrate an existing site in Unix environment to WinNT. Don't
ask why. I didn't sell the customer on the idea I just got stuck with
the mess.
use Fcntl;
use AnyDBM_File;
use strict;
package DB;
sub createRecipe {
my($data)=@_;
my($recdata)=join($DB::delim,map {$data->{$_}} @DB::fields);
my($id)=$data->{'id'};
&::timeout_write_lock("DB::DBMFILE", $config::recipedbm);
dbmopen(%DB::RECIPEDBM, $config::recipedbm, 0644)
|| &Fatal("dbmopen of $config::recipedbm: $!\n");
$DB::RECIPEDBM{$id}= $recdata;
dbmclose(%DB::RECIPEDBM);
&::unlock("DB::DBMFILE");
close("DB::DBMFILE");
&Almond::Log("Created REC#$id: $data->{'name'} EOF =
$endofline");
}
Thanks in advance for any help I can get. I am stuck!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 22 Aug 2000 18:43:19 GMT
From: perlnewbie@my-deja.com
Subject: Re: errno 22 1024 char limit writing to DB's
Message-Id: <8nuhk2$39r$1@nnrp1.deja.com>
I just wanted to mention that the data is being collected from a multi-
part form and that it works fine in Unix.
In article <8nugl8$1ul$1@nnrp1.deja.com>,
perlnewbie@my-deja.com wrote:
> I am encountering an error when I try and write to a DB file in WinNT
> using Active Perl. Here is the error message I receive:
>
> "Tue Aug 22 09:54:07 2000: sdbm store returned -1, errno 22,
> key "92"..."
>
> It seems that I am only allowed to write a maximum of 1024 characters.
> I was wondering if there is any way to work around this limitation?
> Below is a code snippet of the function which is writing to the DB
> file. By the way I am not the original author of this code I am just
> trying to migrate an existing site in Unix environment to WinNT.
Don't
> ask why. I didn't sell the customer on the idea I just got stuck with
> the mess.
>
> use Fcntl;
> use AnyDBM_File;
> use strict;
>
> package DB;
>
> sub createRecipe {
> my($data)=@_;
> my($recdata)=join($DB::delim,map {$data->{$_}} @DB::fields);
> my($id)=$data->{'id'};
>
> &::timeout_write_lock("DB::DBMFILE", $config::recipedbm);
> dbmopen(%DB::RECIPEDBM, $config::recipedbm, 0644)
> || &Fatal("dbmopen of $config::recipedbm: $!\n");
> $DB::RECIPEDBM{$id}= $recdata;
>
> dbmclose(%DB::RECIPEDBM);
> &::unlock("DB::DBMFILE");
> close("DB::DBMFILE");
>
> &Almond::Log("Created REC#$id: $data->{'name'} EOF =
> $endofline");
> }
>
> Thanks in advance for any help I can get. I am stuck!
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 22 Aug 2000 19:50:56 GMT
From: andrewjasper@my-deja.com
Subject: Re: Fork & Waitpid
Message-Id: <8nulim$8d8$1@nnrp1.deja.com>
In article <8ngip1$ld1$1@lublin.zrz.tu-berlin.de>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote in comp.lang.perl.misc:
> >I was shocked! How could andrewjasper@my-deja.com <andrewjasper@my-
deja.com>
> >say such a terrible thing:
> >>I'm using fork and waitpid, but waitpid keeps returning an error
value
> >>of 256 after the process has already been forked.
> >>
> >>Does anyone have any ideas?
> >
> >Hmm I think you should read "perldoc perlvar" for an explanation of
what
> >$? actually is. You need to do something like "$? >> 8" to get the
exit
> >value. This will tell you that the exit() return value of your child
> >process was 1.
>
> Not to mention that what $? contains is not an indication that
> waitpid() failed. It's the return code of the (now terminated)
> process. See perldoc -f waitpid.
>
> Anno
>
I've spotted the folly of my ways. I can see where the script is
returning -1 to indicate an error. When it is unable to fork a process
or when the executable it is spawning, a y-modem transfer, fails.
Thank you for your help.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 22 Aug 2000 21:51:53 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Functions and reference notation.
Message-Id: <slrn8q5tea.tj3.abigail@alexandra.foad.org>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDXLVIII
September MCMXCIII in <URL:news:8nu3fg$1jp$1@lublin.zrz.tu-berlin.de>:
{} <nobull@mail.com> wrote in comp.lang.perl.misc:
{} >johnvert@my-deja.com writes:
{}
{} [...]
{}
{} >$arrayref->[0] is equivalent to $$arrayref[0]
{} >
{} >> %ENV->{SHELL}; instead of the more familiar (to me): $ENV{SHELL};
{} >>
{} >> AFAIK, 'ENV' isn't a reference (otherwise why would $ENV{SHELL} work?),
{} >> so I was hoping someone could explain this syntax (or refer me to the
{} >> right docs.)
{} >
{} >This syntax is permitted by a known bug in the compiler. There have
{} >been a number of threads about this in this newsgroup and more eurdite
{} >discussion on the Perl-porters mailing list.
{} >
{} >Do not use this syntax in your scripts as they will fail if and when
{} >the bug in the compiler is fixed. In fact enough people are now
{} >using this syntax that it is more likely that it'll be made a
{} >mandatory warning rather than a fatal error, at least initially.
{}
{} That's horrible. The arrow should be a sure sign that what's to
{} the left of it is a reference of some kind.
Well, that's not a very Perlish way of thinking, now is it? Most programming
languages make the programmer a slave of the language and/or compiler.
But there's an amazing score of people who like to be bossed around and
think they should be slaves of Perl as well.
The Perlish way of thinking is: "Hmm, there's a -> there. That means, I
someone got to interpret the left hand side as some kind of reference.
It's a hash, good, I can guess what the programmer means."
*That* is Perl. If you want Java or Python, you know where to get it.
{} the left of it is a reference of some kind. All documented uses
{} of "->" follow that rule, with the exception that you can call
{} a class method via Classname->method(), where Classname can be a
{} bareword or a string.
Or rather, where Classname is a string. It's just that if you use a
bareword, Perl guesses that you really wanted to use a string, so it
treats it like a string. And, conveniently, using a bareword only issues
a warning if the bareword doesn't start with a capital letter.
As for nobull saying that it should be a mandatory warning or error, I'd
like to know _why_? What's the point in making it an error or warning?
It isn't that's the programmer means to do something else. It doesn't
conflict with other syntax. There's no other proposed meaning for the
construct. Other than "some people find it ugly", what is the rationale?
Abigail
--
I can do this because Perl lays down like a wanton woman and lets me
have my way with her.
[Geoff Gerrietts in `nascent FMTEYWTK on OO Perl vs C++']
------------------------------
Date: Tue, 22 Aug 2000 13:13:44 -0700
From: Sarah Officer <OfficerS@aries.tucson.saic.com>
Subject: gdbm_open() NOT Found - Please help!
Message-Id: <39A2DEF8.B0F95637@aries.tucson.saic.com>
Please help! I built perl on 3 machines (2 different architectures)
with no trouble. Prior to building perl 5.6.0, I built & installed
gdbm 1.8.0, as we need the GDBM_File module. I use locincpth and
loclibpth arguments to Configure so that it can find gdbm. The
paths are in a script, and i have repeatedly verified that gdbm
exists, is the right version, the library is there, the include file
is there.
On my 4th machine, Configure finds the gdbm.h file, but tells me
that gdbm_open() is not found. I defined i_gdbm to try and force
it. Gdbm built, but it crashes when I try to run, saying that the
gdbm object is non existent.
What could cause this problem? I can't identify any differences on
this 4th box from the other 3. I built on this platform (silicon
graphics) on our other network with no problem. I actually made a
script to call Configure so I'd be using all the same arguments. It
works on 3 boxes, but not the 4th.
What could be happening? What is Configure doing when it tests for
gdbm_open? If I 'nm' the library, I do find the gdbm_open symbold
defined. Any suggestions would be appreciated.
Sarah
officers@aries.tucson.saic.com
------------------------------
Date: Tue, 22 Aug 2000 11:50:32 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Hash list comparing
Message-Id: <MPG.140c6b508df90c8e98acbd@nntp.hpl.hp.com>
[Crossposted to ...misc and follow-ups redirected.]
In article <Pine.BSF.3.96.1000822144119.4405A-
100000@localhost.wanadoo.fr> on Tue, 22 Aug 2000 14:56:25 +0200, Michel
Lavondes <fox@wanadoo.fr> says...
> On Mon, 21 Aug 2000, ScapS wrote:
...
> > I fill a hash with input from a User
> > But the User should fill at least the first 4 fields:
> > %hash=( "A" , "anton" , "B" , "ben" , "C","conrad", "D" , "donald" ,
> > "E", "");
> >
> > Or the first 4 fields must be empty
> > %hash=("A" , "" , "B" , "" , "C", "" , "D" , "" , "E",
> > "doesnt_matter");
A note to the Original Poster:
Talking about 'the first 4 fields' makes me wonder whether you are using
the appropriatedata structure. That kind of language usually applies to
an array, because the fields of a hash are not ordered. You have chosen
to pseudo-order them by using alphabetic keys, but that seems quite
artificial.
> > Anything in between should return an error page:
> >
> > What would B the code if I'D like to say:
> > If the key/pair values of Element A and B and C and D are filled or
> > the key/pair values of Element A and B and C and D are NOT filled then
> > go
> > else return an error page
>
> grep($_, @hash{'A'..'D'}) % 4 && display_error_page_and_exit();
That is a nice approach to the 'all or none' enumeration. But what
about the cases where some fields don't exist, or the values of some may
be '0'?
The following small modification may be more general and avoid warning
messages:
grep(defined && length, @hash{'A'..'D'}) % 4 &&
display_error_page_and_exit();
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 22 Aug 2000 13:37:20 -0500
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: help with simple regexp - does my head in
Message-Id: <39A2C860.6FB665C3@rac.ray.com>
Marcel Grunauer wrote:
>
> On Tue, 22 Aug 2000 11:20:48 -0500, Russ Jones <russ_jones@rac.ray.com> wrote:
>
> >
> >You don't need a regexp, you can use split:
> >
> > (undef $attrval) = split('=',$orig_field,2);
> >
>
> That should probably be a comma between the 'undef' and the '$attrval'.
Right you are, thanks. I knew that, honest.
>
> But in this case I'd rather use a slice:
>
> $attrval = (split("=", $orig_field, 2))[1]
>
I like this better, too. The [-1] in Mike Stok's post is even MORE
cute.
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Quae narravi, nullo modo negabo. - Catullus
------------------------------
Date: 22 Aug 2000 14:32:05 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: help with simple regexp - does my head in
Message-Id: <m3og2l853e.fsf@dhcp11-177.support.tivoli.com>
marcel@codewerk.com (Marcel Grunauer) writes:
> On Tue, 22 Aug 2000 16:55:42 +0100, john kelly <kellym36@drink.bt.co.uk> wrote:
>
> >im stuck trying to split off the beginning of a string at '='
> >
> >'attrval=monkey'
> > becomes
> >'monkey'
[snip]
> Or you could use a combination of index() and substr().
Since we now seem to be exploring the various ways to do it, I'd
thought I'd elaborate on the index() and substr() solution....
$str = 'attrval=monkey';
$str = substr $str, 1 + index $str, '=';
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4097
**************************************