[16385] in Perl-Users-Digest
Perl-Users Digest, Issue: 3797 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 25 11:10:27 2000
Date: Tue, 25 Jul 2000 08:10:16 -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: <964537816-v9-i3797@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 25 Jul 2000 Volume: 9 Number: 3797
Today's topics:
predefined var for invoked sub? <dejanewdummy@my-deja.com>
Re: predefined var for invoked sub? <tony_curtis32@yahoo.com>
Re: question on lists of lists... of lists! (Abigail)
Re: question on lists of lists... of lists! (Abigail)
Search and delete <six4eight@NOSPAMhotmail.com>
Re: Search and delete <six4eight@NOSPAMhotmail.com>
Simple Question? <g-preston1@ti.com>
Re: Simple Question? <tony_curtis32@yahoo.com>
Re: Simple Question? (Tad McClellan)
Re: Simple Question? undergronk@yahoo.com
Re: USEing a perl module (Tad McClellan)
Re: Why use anonymous? (Nobody)
Re: Why use anonymous? (Nobody)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 25 Jul 2000 14:26:02 GMT
From: Andreas <dejanewdummy@my-deja.com>
Subject: predefined var for invoked sub?
Message-Id: <8lk81j$l56$1@nnrp1.deja.com>
Does anybody know whether there is a predefined variable, which I can
get the name of the actual invoked sub from? Just like $0 or
__PACKAGE__, that supply the script- or package-name. I can't find
anything like this in manpages.
Thanks 4 a clue
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 25 Jul 2000 09:42:54 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: predefined var for invoked sub?
Message-Id: <877laamftd.fsf@limey.hpcc.uh.edu>
>> On Tue, 25 Jul 2000 14:26:02 GMT,
>> Andreas <dejanewdummy@my-deja.com> said:
> Does anybody know whether there is a predefined
> variable, which I can get the name of the actual invoked
> sub from? Just like $0 or __PACKAGE__, that supply the
> script- or package-name. I can't find anything like this
> in manpages.
perldoc -f caller
the argumentified form.
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: 25 Jul 2000 09:36:39 EDT
From: abigail@foad.org (Abigail)
Subject: Re: question on lists of lists... of lists!
Message-Id: <slrn8nr5v1.vcg.abigail@alexandra.foad.org>
Rusty Williamson (rwilliamson@uno.gers.com) wrote on MMDXX September
MCMXCIII in <URL:news:o59f5.318$wn.11510@typhoon.san.rr.com>:
[] Hello,
[]
[] The following is working well for me...
[]
[] $netTot{"$date"} = {
[] "average" => $data1,
[] "med" => $data2,
[] "max" => $data3,
[] "min" => $data4
[] };
[]
[] ... but, now I need to put this structure with a list. I've been looking
[] but the above is as far as my books take it. How could I take this one
[] level further? In other words, now structure above must be repeated for
[] each $month. The following syntax doesn't seem to work but will illustrate
[] the point:
[]
[] $netTot{"$month"}{"$date"}={
[] "average" => $data1,
[] "med" => $data2,
[] "max" => $data3,
[] "min" => $data4
[] };
[]
[] The above looks right to me but doesn't seem to work (I wish I knew PERL
[] better!). Does anyone know the proper syntax for what I'm trying to do (and
[] if you want to same me an addition post... how would I reference it :-) )?
That surprises me as it works for me. Perhaps you should be a bit more
specific than "doesn't work".
#!/opt/perl/bin/perl -w
use strict;
use Data::Dumper;
my ($month,$date, %netTot) = ("foo", "bar");
my ($data1, $data2, $data3, $data4) = qw /aap noot mies wim/;
$netTot{"$month"}{"$date"}={
"average" => $data1,
"med" => $data2,
"max" => $data3,
"min" => $data4
};
print Dumper \%netTot;
__END__
$VAR1 = {
'foo' => {
'bar' => {
'average' => 'aap',
'min' => 'wim',
'max' => 'mies',
'med' => 'noot'
}
}
};
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
------------------------------
Date: 25 Jul 2000 09:39:19 EDT
From: abigail@foad.org (Abigail)
Subject: Re: question on lists of lists... of lists!
Message-Id: <slrn8nr641.vcg.abigail@alexandra.foad.org>
Uri Guttman (uri@sysarch.com) wrote on MMDXX September MCMXCIII in
<URL:news:x7puo2924a.fsf@home.sysarch.com>:
{} >>>>> "RW" == Rusty Williamson <rwilliamson@uno.gers.com> writes:
{}
{} RW> Hello,
{} RW> The following is working well for me...
{}
{} RW> $netTot{"$date"} = {
{}
{} lose the quotes there, they are not needed.
{} RW> "average" => $data1,
{} RW> "med" => $data2,
{} RW> "max" => $data3,
{} RW> "min" => $data4
{}
{} add a trailing comma there. it is not required but it maked it easier to
{} add more lines of data.
{}
{} RW> };
{}
{} that is not a list of lists. it is a hash of a hash (singular since the
{} only top level key is $date. your subject is wrong.
{}
{} RW> $netTot{"$month"}{"$date"}={
{} RW> "average" => $data1,
{} RW> "med" => $data2,
{} RW> "max" => $data3,
{} RW> "min" => $data4
{} RW> };
{}
{}
{} $netTot{ $month } = {
{} $date => {
{} "average" => $data1,
{} "med" => $data2,
{} "max" => $data3,
{} "min" => $data4,
{} },
{} } ;
{}
{} there are many other ways to do that.
This is a misleading answer, suggesting that the Rusty's way is incorrect.
Furthermore, your solution allows only for one date a month. If there's
already data for another day of that month in %netTot, that data will
be wiped out.
Abigail
--
$_ = "\x3C\x3C\x45\x4F\x54";
print if s/<<EOT/<<EOT/e;
Just another Perl Hacker
EOT
------------------------------
Date: Tue, 25 Jul 2000 14:32:07 GMT
From: "Eelke Kleijn" <six4eight@NOSPAMhotmail.com>
Subject: Search and delete
Message-Id: <Hxhf5.2373$Gd1.28147@Typhoon.bART.nl>
Hi all,
I want people to submit their email address so they can remove themselves
from my email database. The only problem is I get my output in the new
email_database like this:
info@example.com
info@example2.com
info@example3.com
So all email adresses beyond the first get spaced to the right. What can I
do to prevent this?
This is what I came up with:
# Get all form input
foreach $key (param()) {
if ($key =~ /Email/) {
$user_email = param($key);
}
}
open (FILE, "$email_database_path") or die "Can't open $email_database_path:
$!\n";
@file = <FILE>;
close (FILE);
@newfile = grep { $_ !~ /$user_email/ } @file;
foreach $elem (@newfile) {
$email = $elem;
push @email, $email;
}
open (FILE, ">>$email_database_path") or die "Can't open file: $!\n";
print FILE "@email";
close (FILE);
------------------------------
Date: Tue, 25 Jul 2000 14:34:00 GMT
From: "Eelke Kleijn" <six4eight@NOSPAMhotmail.com>
Subject: Re: Search and delete
Message-Id: <szhf5.2374$Gd1.28186@Typhoon.bART.nl>
Never mind stoopid question I found it out already
<SNIP>
------------------------------
Date: Tue, 25 Jul 2000 08:39:21 -0500
From: Jerry Preston <g-preston1@ti.com>
Subject: Simple Question?
Message-Id: <397D9889.3EE767AF@ti.com>
Hi,
I am trying the to use 'chmod' to change the permissions on an
directory.
$j = chmod 0777 "/ki/"; The directory in question is 0775
Where $j is always '0'; It had worked, but no luck now! I have read the
doc ..
What am I missing! This seems so simple. I can go to the server and
do it by hand. Is there something that I need to do with group id's or
user id's?
Thanks for your help,
Jerry
------------------------------
Date: 25 Jul 2000 09:09:23 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Simple Question?
Message-Id: <87aef6mhd8.fsf@limey.hpcc.uh.edu>
>> On Tue, 25 Jul 2000 08:39:21 -0500,
>> Jerry Preston <g-preston1@ti.com> said:
> Hi, I am trying the to use 'chmod' to change the
> permissions on an directory.
> $j = chmod 0777 "/ki/"; The directory in question is
> 0775
> Where $j is always '0'; It had worked, but no luck now!
> I have read the doc ..
> What am I missing! This seems so simple. I can go to
> the server and do it by hand. Is there something that I
> need to do with group id's or user id's?
If you're trying to chmod a file in the root filesystem, I
presume you are also root yourself? If not, I suspect you
may not be wanting to chmod a file called "/ki/".
Either that, or this is a CGI question in disguise and
there's more to it that you're not telling us (e.g. your
process is running as "nobody" not as "you").
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Tue, 25 Jul 2000 09:14:38 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Simple Question?
Message-Id: <slrn8nr4lu.d7d.tadmc@magna.metronet.com>
On Tue, 25 Jul 2000 08:39:21 -0500, Jerry Preston <g-preston1@ti.com> wrote:
> Subject: Simple Question?
Please help out the people who might read your articles by
putting the subject of your article in the Subject of your article.
Nearly *every* post here has a simple question, so saying that
doesn't add anything of value.
If you have a question about chmod(), then say so:
Subject: question about chmod()
>I am trying the to use 'chmod' to change the permissions on an
>directory.
>
>$j = chmod 0777 "/ki/"; The directory in question is 0775
>
>Where $j is always '0'; It had worked, but no luck now! I have read the
>doc ..
>
>What am I missing! This seems so simple.
You are missing a check of the return value, and the consequent
output of the $! variable:
chmod 0777 '/ki/' or die "could not chmod '/ki/' $!";
>I can go to the server and
^^^^^^
>do it by hand.
What server?
Perl does not have a server!
Sounds like there is something about the application that
you are programming that you have not shared with us.
If your Perl program is being run by some sort of server, we
would be able to help more if we knew what sort of server it is...
Or, better yet, if there is a newsgroup for that sort of
server, then maybe you should ask in that newsgroup instead.
>Is there something that I need to do with group id's or
>user id's?
I dunno. You have not given enough information.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 Jul 2000 14:31:42 GMT
From: undergronk@yahoo.com
Subject: Re: Simple Question?
Message-Id: <8lk8ce$lae$1@nnrp1.deja.com>
In article <397D9889.3EE767AF@ti.com>,
Jerry Preston <g-preston1@ti.com> wrote:
> I am trying the to use 'chmod' to change the permissions on an
> directory.
>
> $j = chmod 0777 "/ki/"; The directory in question is 0775
>
> What am I missing!
Looks like a syntax error. You might be gettin mixed up with the Unix
command line. Try..
$j = chmod 0777, '/ki/';
and have a look at perldoc -f chmod
Cheers
Scott Kirk
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 25 Jul 2000 07:38:07 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: USEing a perl module
Message-Id: <slrn8nqv0v.chu.tadmc@magna.metronet.com>
On Mon, 24 Jul 2000 22:26:46 -0700, Glen Heide <jheide@sprint.ca> wrote:
>ok, ok... so I need to be more specific.
You also need to stop quoting in backwards time order.
Please put your comments *following* the quoted text that
you are commenting on.
Please do not quote an _entire_ article. Quote just enough
to establish the context for your comments.
Please never quote .sigs
Please visit news.announce.newusers
Thanks.
>What I meant to say was that the server does not have the module
>"installed", and I want to "use" this module. It's got all the
>functionality I need, but from what you say, I *have* to get them to
^^^^
>"install" it before I can "use" it?
No.
It does *have* to be installed before you can use it.
It does *NOT* have to be _them_ that installs it (if you have
telnet access to the server).
If your sysadmin won't install them, you can install them
yourself, as described in the two FAQ answers I mentioned
in my other followup.
Have you tried what is suggested there yet?
[ snip Jeopardy quoted text ]
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Jul 2000 13:59:03 GMT
From: nobody@contract.East.Sun.COM (Nobody)
Subject: Re: Why use anonymous?
Message-Id: <8lk6f7$m8r$1@eastnews1.east.sun.com>
In article <397CA69B.A9495E2D@west.net>, John Callender <jbc@west.net> wrote:
>awilcox@contract.East.Sun.COM wrote:
>>
>> So, to recap, why would you use an anonymous hash or
>> subroutine, as opposed to their named counterparts?
>
>To build multilevel data structures? Anonymous hashes, at least,
>tend to show up there a lot.
>
Hmmm. I've built these kinds of structures before, but never thought of them
as 'anonymous', since they were simply part of a larger structure that did
have a name. The example that the interview twit used was a single unnamed
hash...
Anita
------------------------------
Date: 25 Jul 2000 14:08:57 GMT
From: nobody@contract.East.Sun.COM (Nobody)
Subject: Re: Why use anonymous?
Message-Id: <8lk71p$mgn$1@eastnews1.east.sun.com>
In article <397CB5CC.15841010@home.com>,
Michael Carman <mjcarman@home.com> wrote:
>awilcox@contract.East.Sun.COM wrote:
>>
>> I have been doing Perl for a long time (since ~1995)
>
>Some here would argue that you're still a Perl pup. :)
>
Compared to the gurus here, definitely.
>An anonymous list/hash/sub is just one that doesn't have a name. It
>exists because it has a non-zero reference count. (I.e. no name, but
>somebody out there knows about it.)
>
>You may well have used this stuff without knowing the term for it. Have
>you ever used data structures more complicated than scalars, arrays, and
>hashes? e.g. a list-of-lists (LoL) or a hash-of-hashes (HoH)? A LoL is
How about a LoHoL? :-) I like to use structures like that for handling
database data, since combinations of hashes and lists can do a pretty good
job of representing the data. Complex data structures in Perl are fun, though
I always add a big block of comments next to dereferencing statements to
be kind to the next person who has to look at it. Since I'm a consultant,
and they usually bring me in because they don't have enough Perl expertise
in-house, I essentially comment the hell out of everything and pretend that
a newbie will be the one reading it, just in case. Saves the followup calls
six months later when they say, "What the hell is this?" :-)
>Anonymous subroutines are useful if you need to create a sub on the fly
>-- build it up and call it through its reference. You can use them to
>create 'localized' subroutines. I usually use them when creating
>callbacks for Tk widgets -- I don't want to write a named sub for every
>little thing, so I just make an anonymous one. (Tk widgets take coderefs
>as args.)
>
>So, anonymous arrays/hashes/subs are quite useful, even if you don't
>absolutely need them much of the time.
I haven't needed then yet....
>
>> He couldn't give me an answer as to why one would use these,
>
>Heh. Then he shouldn't have been asking the question. How would he know
>how to interpret your response?
>
'zactly. The main reason I decided not to work there. That, and the
fact that the place was too quiet. I think the employees were chained
to their terminals :-)
Anita
------------------------------
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 3797
**************************************