[15529] in Perl-Users-Digest
Perl-Users Digest, Issue: 2939 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 3 21:05:34 2000
Date: Wed, 3 May 2000 18:05:22 -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: <957402322-v9-i2939@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 3 May 2000 Volume: 9 Number: 2939
Today's topics:
Re: $form{'email'} =~ s/([\0-\37\177])/ /g; <lr@hpl.hp.com>
Re: [RegExp] Matching UPPERCASE words ... <jeff@vpservices.com>
Re: [RegExp] Matching UPPERCASE words ... <lr@hpl.hp.com>
Re: [RegExp] Matching UPPERCASE words ... <adams1015@worldnet.att.net>
Re: [RegExp] Matching UPPERCASE words ... (Ilya Zakharevich)
Re: [RegExp] Matching UPPERCASE words ... <lr@hpl.hp.com>
Re: [RegExp] Matching UPPERCASE words ... <lr@hpl.hp.com>
Can't send mail from html form niceguyz@home.com
can't send mail from html form niceguyz@home.com
Re: Can't send mail from html form <tfm@sei.cmu.edu>
Re: can't send mail from html form <rootbeer@redcat.com>
Re: CHOOSE PROFILE Keeps Popping Up, MAPI bayers@my-deja.com
Re: Clear and then Reuse a package name space <rootbeer@redcat.com>
comparison operator help <cobyw@yahoo.com>
Re: comparison operator help (Craig Berry)
Re: comparison operator help <iltzu@sci.invalid>
Re: Creating IIS V4 virtual directory using Perl... <smckee@umich.edu>
Error: Next 2 tokens. <sid@eurekanet.com>
Re: Error: Next 2 tokens. <lr@hpl.hp.com>
Re: Error: Next 2 tokens. <rootbeer@redcat.com>
extending nested package <canfieldsteve@hotmail.com>
Re: extending nested package (Damian Conway)
Re: HELP : Script works on Command Line but not as CGI <tye@metronet.com>
Help counting things with Perl <ew@epl.org>
Re: Help counting things with Perl <lr@hpl.hp.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 3 May 2000 13:30:40 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: $form{'email'} =~ s/([\0-\37\177])/ /g;
Message-Id: <MPG.137a2c4c475e55d98a9e1@nntp.hpl.hp.com>
In article <cxcaei7cvyt.fsf@dioscuri.uio.no> on 03 May 2000 20:47:06
+0200, Peter J. Acklam <jacklam@math.uio.no> says...
> Todd Anderson <todd@mrnoitall.com> writes:
>
> > Anyone know what this does?
> >
> > $form{'email'} =~ s/([\0-\37\177])/ /g;
>
> It replaces every occurrence of any character in the range \000-\037
> including \177 with a blank character (space).
>
> Unless $1 is used after this replacement, you could write it as
>
> $form{'email'} =~ s/[\0-\37\177]/ /g;
I would write it as:
$form{email} =~ tr/\0-\37\177/ /;
Though I doubt that I would write it at all. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 03 May 2000 12:41:59 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: [RegExp] Matching UPPERCASE words ...
Message-Id: <39108107.7B61E19B@vpservices.com>
Charles Henry wrote:
>
> Which regexp shall I use to match UPPERCASE words?
>
> Thanks in advance
This one might work for you:
my $help = 'BEG-IN-NEWSGROUP';
$help =~ s/beg-in-newsgroup/read-documentation/i;
print $help;
Notice that it matched the original even though the case in the regex
was different.
--
Jeff
P.S. sorry if someone saw the earlier typo version, now canceled,
version of this posting.
------------------------------
Date: Wed, 3 May 2000 15:01:27 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: [RegExp] Matching UPPERCASE words ...
Message-Id: <MPG.137a4191dadb8e898a9e5@nntp.hpl.hp.com>
In article <8eq3b3$3v9$1@charm.magnus.acs.ohio-state.edu> on 3 May 2000
20:48:35 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
...
> and hope that "]" and "-" are not uppercase chars in the given locale. ;-]
I see the winkie. Nevertheless, I posit that the character-class
semantics of the 128 ASCII characters are identical in any locale.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 03 May 2000 20:11:53 GMT
From: "Veronica Adams" <adams1015@worldnet.att.net>
Subject: Re: [RegExp] Matching UPPERCASE words ...
Message-Id: <dK%P4.47639$WF.2520332@bgtnsc04-news.ops.worldnet.att.net>
Charles Henry <charles.henry@engineer2k.com> wrote in message
news:8epui5$n23$1@news3.isdnet.net...
> Which regexp shall I use to match UPPERCASE words?
>
> Thanks in advance
>
DO you want to match any word? A word boundry? A particluar word? Be a
little more specific and you're more likely to get some help.
------------------------------
Date: 3 May 2000 22:49:36 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: [RegExp] Matching UPPERCASE words ...
Message-Id: <8eqae0$6e7$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.137a4191dadb8e898a9e5@nntp.hpl.hp.com>:
> > and hope that "]" and "-" are not uppercase chars in the given locale. ;-]
and '\\' !
> I see the winkie. Nevertheless, I posit that the character-class
> semantics of the 128 ASCII characters are identical in any locale.
Are you sure there are not 7-bit locales around these days?
Ilya
------------------------------
Date: Wed, 3 May 2000 15:44:13 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: [RegExp] Matching UPPERCASE words ...
Message-Id: <MPG.137a4b9c1d26f72d98a9e8@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed, though the post wasn't courteous at
all.]
In article <8eq590$8br$1@news2.isdnet.net> on Wed, 3 May 2000 23:15:50
+0200, Charles Henry <charles.henry@engineer2k.com> says...
> > > Which regexp shall I use to match UPPERCASE words?
> > >
> > > Thanks in advance
> >
> > This one might work for you:
> >
> > my $help = 'BEG-IN-NEWSGROUP';
> > $help =~ s/beg-in-newsgroup/read-documentation/i;
> > print $help;
> >
> > Notice that it matched the original even though the case in the regex
> > was different.
>
> Forget it I found the answer :
>
> /\b([A-Z]+)\b/
>
> It's cool to see how helpful people are on clpm :¨|
Naively taking that comment at face value: Yes, indeed, considering how
much we get paid to help.
Realistically taking that coomment for sarcasm (as I presume you
intended by :"|): I feel entitled to an apology. Ilya Zakharevich and
I provided answers that were more thorough than you found on your own.
You oughtn't go off half-cocked because no answer you liked appeared
until a couple of hours after your post. That way lies the killfile for
any future requests.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 3 May 2000 17:10:00 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: [RegExp] Matching UPPERCASE words ...
Message-Id: <MPG.137a5fb65581e6b098a9ed@nntp.hpl.hp.com>
In article <8eqae0$6e7$1@charm.magnus.acs.ohio-state.edu> on 3 May 2000
22:49:36 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
> [A complimentary Cc of this posting was sent to Larry Rosler
> <lr@hpl.hp.com>],
> who wrote in article <MPG.137a4191dadb8e898a9e5@nntp.hpl.hp.com>:
...
> > ... Nevertheless, I posit that the character-class
> > semantics of the 128 ASCII characters are identical in any locale.
>
> Are you sure there are not 7-bit locales around these days?
I *think* ASCII is a mandatory subset of all current character sets
(except EBCDIC, of course).
Nevertheless, it would be hard to envision writing a Perl program in
such a locale. Perl defines semantics for all but a few characters:
[^\a\b\e\f\n\r -~]
There are thus 27 characters with ASCII but not Perl semantics. Maybe
something could be done...
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 03 May 2000 22:12:24 GMT
From: niceguyz@home.com
Subject: Can't send mail from html form
Message-Id: <3910A385.5B359BBA@home.com>
I'm having trouble writing a simple perl script for a Win32 system that
will email the contents of an HTML form to the specified user. I've
tried all kinds of modules and variations on code, but to no avail.
Anyone have any ideas?
Thanks,
Dave
niceguyz@home.com
------------------------------
Date: Wed, 03 May 2000 22:59:55 GMT
From: niceguyz@home.com
Subject: can't send mail from html form
Message-Id: <3910AEA6.512FFDE4@home.com>
I can't send an email from an html form. Here's my code and the error
message I keep getting.
I've installed the module several times over in different places. Any
ideas?
use Mail::Sendmail;
$body = "thankyou";
$subj = "whatever";
%mailer = Mail::Mailer->new('sendmail');
%mailer->open({From => $emailfrom,
To => $form->param("email"),
Subject => $subj,
Message => $body,
}) or die "Can't open: $!\n";
sendmail %mailer $body;
sendmail(%mail) or die $Mail::Sendmail::error;
print "OK. Log says:\n", $Mail::Sendmail::log;
%mailer->close();
####
This is my error message:
Can't locate object method "new" via package "Mail::Mailer"
------------------------------
Date: Wed, 03 May 2000 18:38:44 -0400
From: Ted Marz <tfm@sei.cmu.edu>
Subject: Re: Can't send mail from html form
Message-Id: <3910AA74.C148B9BA@sei.cmu.edu>
Win32 is a bit strange when it comes to mail.
You see, it doesn't (usually) have a sendmail, so things get
interesting.
There are some sendmail replacements... look on http://www.perl.org
Microsoft has a sendmail port that is supposed to work on windoze
There is another application called Blat that can be used to do the
job. It apparently has perl access packages as well
Or, you can use Graham Barr's Net:SMTP package to contact a SMTP server
directly.
Good luck
Ted
niceguyz@home.com wrote:
>
> I'm having trouble writing a simple perl script for a Win32 system that
> will email the contents of an HTML form to the specified user. I've
> tried all kinds of modules and variations on code, but to no avail.
> Anyone have any ideas?
> Thanks,
> Dave
> niceguyz@home.com
------------------------------
Date: Wed, 3 May 2000 16:18:40 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: can't send mail from html form
Message-Id: <Pine.GSO.4.10.10005031616300.6766-100000@user2.teleport.com>
On Wed, 3 May 2000 niceguyz@home.com wrote:
> use Mail::Sendmail;
> %mailer = Mail::Mailer->new('sendmail');
Are you using Mail::Mailer or Mail::Sendmail? D'Oh!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 03 May 2000 20:16:28 GMT
From: bayers@my-deja.com
Subject: Re: CHOOSE PROFILE Keeps Popping Up, MAPI
Message-Id: <8eq1eb$psj$1@nnrp1.deja.com>
Got that fixed. It was a matter of how I was logged in as. If I
logged on as myself and selected the profile with my username, the
CHOOSE PROFILE didn't appear. Likewise, if I logged in as
Administrator and selected the Administrator profile, no CHOOSE PROFILE.
Now, I'm trying to get it run with CGI. I've got an exchange profile
set up with IUSER as the owner. It won't log in.
In article <8eppe0$geo$1@nnrp1.deja.com>,
bayers@my-deja.com wrote:
> I'm conecting to Exchange 5.5, installed on NT4 sp6, with a MAPI
client
> and everything works. The problem is, I get the CHOOSE PROFILE dialog
> which makes using it from a script impossible. The only profile on
the
> machine is MAIL and it is the default profile.
>
> When the script is ran, the CHOOSE PROFILE box pops up, I click OK and
> the mail is sent.
>
> Anyway to disable, or get around the CHOOSE PROFILE dialog?
>
> Here is my perl code:
>
> ================================================
>
> # !perl -w
>
> use Win32::MAPI qw(Yes No);
>
> my($obj)=new Win32::MAPI(UseDefProfile=>Yes);
>
> print "\n Using Win32::MAPI version ", $Win32::MAPI::VERSION, "\n";
> print " By Amine Moulay Ramdane <aminer\@generation.net>\n";
> if($obj->IsMAPI){print "\n MAPI is available...\n"}
> else{die "\n MAPI is not available!\n"}
>
> print "\n Please hit <Enter> to start the demo...: ";
> <STDIN>;
>
> $obj->Logon() || die "Can't logon!";
>
> $data{Text}="Perl is great!";
> $data{Subject}="Win32::MAPI";
> $data{To}=['bayers@my-deja.com'];
> $data{ShowDialog}=No;
> $obj->Send(\%data);
> $obj->LastError;
>
> undef $obj;
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 3 May 2000 13:01:29 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Clear and then Reuse a package name space
Message-Id: <Pine.GSO.4.10.10005031254090.13677-100000@user2.teleport.com>
On Wed, 3 May 2000 richard_chen@my-deja.com wrote:
> How the problem arise is not important.
> Debating about what should be done in modifying the legacy
> cgi scripts to make them work under modperl is beside the point.
Well, if you say it's beside the point, my arguing otherwise would be
beside the point.
> Keep in mind that the major reason to use Apache::Registry
> is to minimize modifications of the cgi scripts. Otherwise,
> I would start from scratch and write my own perl handlers,
> bypassing Apache::Registry altogether.
Okay, but that doesn't mean that every existing CGI script will work under
Apache::Registry without modification. It seems that ones which assume
that globals will always be empty upon each new invocation may have
troubles.
> I have tried very hard to distill the essence of the problem
> before I posted it to this discussion group. Let me
> state it again here:
>
> =======================================================
> Is it possible to clear and then reuse the same package
> name space in one perl process?
> =======================================================
As I said before, and you quoted:
> > Well, clearing the symbol table _is_ possible.
...but I don't think it'll help you here. You don't have to believe me,
though. :-)
> I am very surprised that there is an easy way to make alias in perl
> but apparently there is no way to clear/remove the alias and then bind
> the alias to another variable/reference.
I think that's a different problem. But since I don't claim to completely
understand that one, I'll leave it alone. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 03 May 2000 19:31:07 GMT
From: Coby West <cobyw@yahoo.com>
Subject: comparison operator help
Message-Id: <8epupr$muh$1@nnrp1.deja.com>
Is there a perl comparison operator(s) that work for both
numeric/char? I am trying to compare users in a database..some users
have numbers in the name and others do not. I know that != is for
comparing numbers and ne is for chars. Can someone help me with
comparing both...Here is the code:
if ($form{'pass'} eq "ok")
{$passwd="Y";}
else
{
open (PEOPLE, "$Users");
while (<PEOPLE>)
{
$row=$_;
@User = split(/ /,$row);
if ($form{'User'} eq $User[0])
{
$password = crypt($form{'password'}, "MM");
if ($password eq "$User[1]" )
{
$passwd="Y";
}
}
}
close (PEOPLE);
if ($form{'User'} ne $User[0]) <----this is it!
{
print "<p> </p><center><b>You are not in the user
list.</b></center><br>\n";
print "<center><b><a href=\"javascript:history.back()\"> Go
Back</a><center><b>\n";
exit;
}
}
Thanks for the help in advance.
Coby
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 03 May 2000 22:31:27 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: comparison operator help
Message-Id: <sh1a5v8oa4n135@corp.supernews.com>
Coby West (cobyw@yahoo.com) wrote:
: Is there a perl comparison operator(s) that work for both
: numeric/char? I am trying to compare users in a database..some users
: have numbers in the name and others do not. I know that != is for
: comparing numbers and ne is for chars. Can someone help me with
: comparing both...Here is the code:
[snip]
Numerals which appear in strings which are operated on using string
operators and functions act just like any other characters; there's
nothing special about them, they're just characters 0x30-0x39 in ASCII.
So e.g.
'foobar1' ne 'foobar2'
'12a34' eq '12a34'
'321a' lt '321b'
are all true.
I'm not entirely sure that I have answered your question, though. If not,
please rephrase and try again.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "The road of Excess leads to the Palace
of Wisdom" - William Blake
------------------------------
Date: 3 May 2000 20:37:21 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: comparison operator help
Message-Id: <957386012.22760@itz.pp.sci.fi>
In article <8epupr$muh$1@nnrp1.deja.com>, Coby West wrote:
>Is there a perl comparison operator(s) that work for both
>numeric/char? I am trying to compare users in a database..some users
>have numbers in the name and others do not. I know that != is for
>comparing numbers and ne is for chars. Can someone help me with
>comparing both...Here is the code:
[snip]
> if ($form{'User'} ne $User[0]) <----this is it!
So what happened when you tried it?
If this isn't what you want, please define your requirements more
precisely, preferably showing one or more examples where the above
approach doesn't produce the desired result.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Wed, 3 May 2000 15:42:33 -0400
From: "Shawn McKee" <smckee@umich.edu>
Subject: Re: Creating IIS V4 virtual directory using Perl...
Message-Id: <Ji%P4.338$R12.7242@news.itd.umich.edu>
Hi John,
Thank-you...this works. For others who may be interested this code stub
below
can get you started as well. Thanks again,
Shawn
use Win32::OLE;
use CGI::Carp;
use Sys::Hostname;
sub IISMakeVdir {
my ($vdir,$dir) = @_;
my $hname = hostname();
$GetIIS = "IIS://$hname/W3svc/1/Root/$vdir";
print "Trying to GetObject $GetIIS...\n";
$IISObj = Win32::OLE->GetObject($GetIIS);
if ($err = Win32::OLE->LastError()) {
print " Error on GetObject: $err\n";
return 0;
}
$name = $IISObj->{Name};
print " Found IISObj $name...\n";
return 1;
}
# Test
&IISMakeVdir("test","c:\inetpub\wwwroot\test");
exit;
John Alderson - LTS <john.alderson@fmr.com> wrote in message
news:g6WP4.11$s65.50@news-srv1.fmr.com...
>
> "Shawn McKee" <smckee@umich.edu> wrote in message
> news:TxVP4.304$R12.5829@news.itd.umich.edu...
> > I am trying to create a set of virtual directories in IIS V4 under WinNT
> V4.
> > The only examples of doing this that I have found involve either C++
code
> or
> > VBScript's GetObject function.
> >
> > I haven't been able to find a way to get Perl (or PerlScript) to
> > do the equivalent of GetObject (CreateObject works fine though).
> >
> > Does anyone out there know a way, using Perl, to connect to the
> > IIS metabase and add virtual directories and applications?
> >
> > I am using ActiveState build 522 and NT is SP6.
> >
>
> Shawn,
>
> The best way to go about this task is to use ADSI via Win32::OLE. Your
IIS
> installation should have quite a few sample files installed. Search in
> %SYSTEMROOT%\System32\Inetsrv\Adminsamples for files with a VBS extension.
> These are written in VBScript, which can easily be translated into Perl.
> You can also search msdn.microsoft.com for the IIS: namespace and ADSI.
>
> John Alderson
>
>
------------------------------
Date: Wed, 3 May 2000 20:05:03 GMT
From: Sid Malhotra <sid@eurekanet.com>
Subject: Error: Next 2 tokens.
Message-Id: <3910866F.C6A82839@eurekanet.com>
Could someone tell me what this error means:
Sid {28} std.pl
syntax error in file std.pl at line 8, next 2 tokens "isLoggedIn("
Execution of std.pl aborted due to compilation errors.
Sid {29}
Here's my code:
#!/usr/bin/perl
sub printtable {
print "<table border=5 rows=1 cols=2 align=right>\n";
print "<tr><td></td><td align=right>\n";
print $ENV{'REMOTE_HOST'};
if (isLoggedIn($ENV{'REMOTE_HOST'})) {
print "<a href=user.cgi?ac=lo>Logout</a>\n";
} else {
print "<a href=user.cgi?ac=li>User Login</a>\n";
}
print "</td></tr></table>\n";
}
sub isLoggedIn {
print "Entered isLoggedIn";
local ($ip) = @_;
return 0;
}
1;
------------------------------
Date: Wed, 3 May 2000 15:11:08 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Error: Next 2 tokens.
Message-Id: <MPG.137a43dc2132c62998a9e6@nntp.hpl.hp.com>
In article <u5kaei72wg0.fsf@davis.DEMOG.Berkeley.EDU> on 03 May 2000
13:46:55 -0700, Andrew Perrin - Demography
<aperrin@davis.DEMOG.Berkeley.EDU> says...
> Sid Malhotra <sid@eurekanet.com> writes:
>
> > Could someone tell me what this error means:
>
> Sure - your own computer can tell you that when you type:
>
> perldoc perldiag
> or
> man perldiag
It can't if you are running Perl 5. There are no syntax errors in the
posted code.
I didn't respond earlier because I couldn't find any suntax errors using
Perl 4 either, but I don't know that very well. I assume there were
hashes\Wassociative arrays, and that $ENV{'REMOTE_HOST'} would be valid
syntax. Maybe TomP will clarify why it fails there.
...
> > if (isLoggedIn($ENV{'REMOTE_HOST'})) {
>
> Hint: does perl know what isLoggedIn means?
Not much of a hint. It knows that isLoggedIn is a subroutine, because
this is the syntax for a subroutine invocation. So there is no syntax
error here.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 3 May 2000 15:39:43 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Error: Next 2 tokens.
Message-Id: <Pine.GSO.4.10.10005031530560.13677-100000@user2.teleport.com>
On Wed, 3 May 2000, Larry Rosler wrote:
> Maybe TomP will clarify why it fails there.
> > > if (isLoggedIn($ENV{'REMOTE_HOST'})) {
Okay. :-)
Back in the bad-old-days of perl4, the & wasn't optional on subroutine
calls, that's all. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 03 May 2000 21:55:58 GMT
From: Steve Canfield <canfieldsteve@hotmail.com>
Subject: extending nested package
Message-Id: <8eq796$oq$1@nnrp1.deja.com>
I just KNOW this is a really simple question but I can't find an answer
anywhere. Honest, I've looked through the Faq's and that sorta thing.
OK, here's the deal. I have a nested package which I want to extend
and I can't figure out how. I have a package called Cup::Coffee and I
want the package Mug to extend it. Now, if the base package weren't
nested I could just extend it with something like this:
@Mugs::ISA=('CoffeeCup');
but it IS extended and this doesn't work:
@Mugs::ISA=('Cup::Coffee');
Help!
STEVE
--
Actually, I can't field worth a hoot.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 3 May 2000 22:54:48 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: extending nested package
Message-Id: <8eqano$2mt$1@towncrier.cc.monash.edu.au>
Steve Canfield <canfieldsteve@hotmail.com> writes:
>OK, here's the deal. I have a nested package which I want to extend
>and I can't figure out how. I have a package called Cup::Coffee and I
>want the package Mug to extend it. Now, if the base package weren't
>nested I could just extend it with something like this:
> @Mugs::ISA=('CoffeeCup');
>but it IS extended and this doesn't work:
> @Mugs::ISA=('Cup::Coffee');
Did you mean @Mug::ISA?
And in what sense doesn't it work? This does:
use strict;
package Cup::Coffee;
sub print { print "Caffeine!\n"; }
package Mug;
@Mug::ISA = ('Cup::Coffee');
package main;
my $mug = bless {}, 'Mug';
$mug->print();
Damian
------------------------------
Date: 3 May 2000 17:54:30 -0500
From: Tye McQueen <tye@metronet.com>
Subject: Re: HELP : Script works on Command Line but not as CGI when using
Message-Id: <8eqan6$bd4@beanix.metronet.com>
cberry@cinenet.net (Craig Berry) writes:
)
) It's a (too-)little-known quirk of the DOS-derived OSs that forward
) slashes work as directory separators everywhere except in the command
) shell itself. So you can replace the \\s above with /s.
Actually, they work in, for example, NT's cmd.exe. But many
commands won't accept "/" as a directory separator in their
arguments. Perl, for example, doesn't have this problem and so
you can use "/" with abandon for invoking perl via the command
shell.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Wed, 03 May 2000 17:23:58 -0500
From: Edward Wigg <ew@epl.org>
Subject: Help counting things with Perl
Message-Id: <3910A6FE.4D5BB94B@epl.org>
[Sorry if this is a bit long, but better to explain myself fully than
have you misunderstand me or ask what I mean.]
OK, given that I am not much of a programer (in fact nothing of a
programer), and I don't want anything too complex or too clever (or of
course I wouldn't understand it) I'm trying to find a nice perlish way
of compiling some statistics about the state of a bibliographic item
database; the database itself is not readily available to work with and
the native reporting tools are cumbersome and slow in the extreme, but I
do have a report with the necessary information in it generated from the
database.
This report is a text file with about half a million entries of the
form: call_number::location::type::title_code::pub_year::inventory_date
The call number is alpha numeric (dewey decimal if that helps), there
are about fifty locations, and forty or so types, and a couple of
hundred thousand unique title_codes (each eight digits), pub_year is the
year of publication, inventory date in yyyymmdd format. There are a few
more fields, but I think this is enough to give an idea of the
structure.
I want to count these things by various groups: for each location, or
group of locations, I want counts by a bunch, maybe 30, of sub
categories (items may fall into more than one category), and an overall
count for that location. There maybe other things too, like average year
of publication, number of items added calculated from the inventory
date.
It might make more sense if I just show you what the output might look
something like:
Location1
type1: 1000 items, 2 added since 4/1/00, average pub year 1973, 800
titles
type2: 200 items, 0 added since 4/1/00, avg yr 1984, 150 titles
callno 100-200: 5000 items, 5 added since 4/1/00, avg yr 1952, 3500
titles
callno 200-300: 3230 items, 1 added since 4/1/00, avg yr 1978, 2987
titles
(...and so on...)
total Location1: 35000 items, 120 added since 4/1/00, avg yr 1971,
25000 titles
Location2 and Location3
type1: 700 items, 1 added since 4/1/00, avg yr 1974, 600 titles
type2: 300 items, 2 added since 4/1/00, avg yr 1983, 250 titles
callno 100-200: 4000 items, 3 added since 4/1/00, avg yr 1962, 2700
titles
callno 200-300: 2480 items, 4 added since 4/1/00, avg yr 1975, 2200
titles
(...and so on...)
total Location2 & 3: 21000 items, 78 added since 4/1/00, avg yr
1972, 16000 titles
(...more locations...)
Grand total 453000 items, 3500 added since 4/1/00, avg yr 1978, 221000
titles
For a smaller number of categories and a smaller input file I would
probably just
brute force it (because I'm a feeble programmer) by testing each record
against a set of tests:
if ($location eq "location1" && $callno gt "100" && $callno lt "200") {
$location1{c100}++ } or something along those lines (maybe the
occasional regex thrown in for spice).
Counts of titles could be kept by using them as the key to a hash and
counting the number of keys at the end. Of course there would need to be
a hash for each category for each location.
It feels like there must be a better way to approach a problem like this
that are escaping me. There are almost certainly complicated ways of
dealing with it (importing the data into a database and running a set of
queries against it?) but that seems like overkill and would require me
to set up and learn one more tool; I'm looking for something better than
brute force that uses the native power of perl, but is not _so_ clever
that it's beyond me :-)
What perls of wisdom can you cast before my swine-like brain?
Thanks in advance for your consideration.
Edward
------------------------------
Date: Wed, 3 May 2000 17:33:13 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Help counting things with Perl
Message-Id: <MPG.137a652260a2867b98a9ee@nntp.hpl.hp.com>
In article <3910A6FE.4D5BB94B@epl.org> on Wed, 03 May 2000 17:23:58 -
0500, Edward Wigg <ew@epl.org> says...
> [Sorry if this is a bit long, but better to explain myself fully than
> have you misunderstand me or ask what I mean.]
It is rather clear!
> OK, given that I am not much of a programer (in fact nothing of a
> programer), and I don't want anything too complex or too clever (or of
> course I wouldn't understand it) I'm trying to find a nice perlish way
> of compiling some statistics about the state of a bibliographic item
> database; the database itself is not readily available to work with and
> the native reporting tools are cumbersome and slow in the extreme, but I
> do have a report with the necessary information in it generated from the
> database.
>
> This report is a text file with about half a million entries of the
> form: call_number::location::type::title_code::pub_year::inventory_date
> The call number is alpha numeric (dewey decimal if that helps), there
> are about fifty locations, and forty or so types, and a couple of
> hundred thousand unique title_codes (each eight digits), pub_year is the
> year of publication, inventory date in yyyymmdd format. There are a few
> more fields, but I think this is enough to give an idea of the
> structure.
...
> if ($location eq "location1" && $callno gt "100" && $callno lt "200") {
> $location1{c100}++ } or something along those lines (maybe the
> occasional regex thrown in for spice).
The use of hashes such as %location1 is almost certainly wrong. You
would be better off with a two-dimensional data structure, as described
below.
> Counts of titles could be kept by using them as the key to a hash and
> counting the number of keys at the end. Of course there would need to be
> a hash for each category for each location.
>
> It feels like there must be a better way to approach a problem like this
> that are escaping me. There are almost certainly complicated ways of
> dealing with it (importing the data into a database and running a set of
> queries against it?) but that seems like overkill and would require me
> to set up and learn one more tool; I'm looking for something better than
> brute force that uses the native power of perl, but is not _so_ clever
> that it's beyond me :-)
>
> What perls of wisdom can you cast before my swine-like brain?
This is the kind of program one deals with every day (every day that
isn't wasted doing CGI stuff or responding to c.l.p.m. :-). Remember
that the 'RL' in Perl is often construed as Rubbish Lister (oops, make
that Report Language).
Read the file and split each line into an array of hash(referenc)es or
(slightly more efficiently but less readably), an array of
array(referenc)es. Then loop and gather statistics over the fields you
are interested in. If the whole thing doesn't fit into memory, buy more
memory.
This is the minimal set of documents you must master:
perldoc perldsc
perldoc perllol
Start small (small data set, simple accumulations), then build up. You
will either need to become a better programmer or to hire one.
Have the appropriate amount of fun! (The Larry)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.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 2939
**************************************