[9910] in Perl-Users-Digest
Perl-Users Digest, Issue: 3503 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 21 18:07:43 1998
Date: Fri, 21 Aug 98 15:00:19 -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 Fri, 21 Aug 1998 Volume: 8 Number: 3503
Today's topics:
Re: After installing new Activestate version .. @INC er <david_delgreco@intuit.com>
Berkley DB files manipulation by Perl on Apache Server <hate.e-mail@spam.com>
Date Manipulation shawn_campbell@my-dejanews.com
Re: Hacking Schools Network <jdf@pobox.com>
have Felix Gallo and Penguin vanished? <mnh@pluto.njcc.com>
How do I read a file backwards. <saunder@kben.co.uk>
Re: logfile analysis <jdporter@min.net>
Re: logfile analysis (Gabor)
Re: Mistake (Was: Re: Help: Problem with Pattern-Matchi (Kevin Reid)
Re: NEWBIE Question: Perl Script in Unix vs. NT (Mr. Mirthful)
Re: Perl Bots! [Chatterbots, FAQbots, InfoBots] <jdf@pobox.com>
Perl debugger? <bchapman@best.com>
Re: Perl debugger? (Greg Bacon)
Re: Prime numbers [was Re: here's an implementation of <dgris@rand.dimensional.com>
Re: Prime numbers [was Re: here's an implementation of (Matt Knecht)
Re: Prime numbers [was Re: here's an implementation of (Sean McAfee)
Re: Problem using CGI.pm for the first time <rasan@horizonlive.com>
Re: Problem using CGI.pm for the first time <ffan@mail.arc.nasa.gov>
Re: Problem using CGI.pm for the first time <rasan@horizonlive.com>
Re: Quickie encapsulation question nick.bauman@imationstudio.com
Re: swap words in regexp (Craig Berry)
Re: swap words in regexp <dgris@rand.dimensional.com>
Turn Perl program into binary <lily@tigr.org>
Re: what is 'sub f () {555};' (Kevin Reid)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 21 Aug 1998 12:53:19 -0700
From: David DelGreco <david_delgreco@intuit.com>
To: ktenney@execpc.com
Subject: Re: After installing new Activestate version .. @INC errors
Message-Id: <35DDD02F.EE76DBCC@intuit.com>
This is a multi-part message in MIME format.
--------------34DB75C400ED5AA84E280B7F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Tye McQueen wrote:
>
> Kent Tenney <ktenney@execpc.com> writes:
> ) I installed the TK module using ppm.bat and it is in
> ) C:\perl\site\5.005\lib\MSWin32-x86-object\auto\Tk\
> )
> ) I now have installed v5.00502
> )
> ) when I try to use TK
> ) I get the error
> ) 'can't locate tk.pm in @INC (@INC contains
> ) C:\perl\site\5.00502\lib\MSWin32-x86-object ....)
>
I came to the newsgroups today for this exact same reason. To add
another
symptom to the problem, I'm used to having some utilities reside in the
/bin
directory, and I can run them from any DOS prompt when I need them.
I installed Perl from the Active State Win32 Perl Resource Kit,
installed
several modules, and then downloaded and installed Build502. When you
do
that, you get both a C:\Perl\5.005\bin and a C:\Perl\5.00502\bin
directory,
but only the latter is in your path.
I haven't determined how much of a pain that's going to be, but will be
testing it as I go along, nor whether this is a feature or a bug. The
docs
don't seem to contain any information on the subject.
David DelGreco
--------------34DB75C400ED5AA84E280B7F
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for DelGreco, David
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: David DelGreco
n: DelGreco;David
org: Intuit, Inc. -- Application Services
email;internet: david_delgreco@intuit.com
title: Intranet Engineer
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
--------------34DB75C400ED5AA84E280B7F--
------------------------------
Date: Fri, 21 Aug 1998 16:18:30 +0100
From: Mark Kotoff <hate.e-mail@spam.com>
Subject: Berkley DB files manipulation by Perl on Apache Server
Message-Id: <6rkkbu$4ou$1@news-2.news.gte.net>
Hi Everyone!
I am new to Perl and have that little problem.
When I am creating a bunch of DB files after my Order Form processed (on
the Internet) I have some strings from the previously created DB file
thrown into the next DB file.
Used on Linux 5.1 and Apache (no version available to me) Server, Perl 5
Is there any dump command or anything that will prevent it from
happening?
Sample:
first file
dbmopen (%datedbf,$datedb,0777);
$todate = "\n$mm$dd$yy$hh$mn$se\n";
$datedbf{$ordernumber} = $todate;
dbmclose(%datedbf);
$todate = '';
next file:
dbmopen (%agentordersdbf,$agentordersdb,0777);
$toagentorders = "\n$account\n";
$agentordersdbf{$ordernumber} = $toagentorders;
dbmclose(%agentordersdbf);
$toagentorders = '';
it gets \n$mm$dd$yy garbage in the first line. Even if it's not readable
when I am accessing this DB file it's just bugging
me.
Thanks in advance.
Mark Kotoff
Disclimer:
I had to disable many of my e-mail accounts because of the
E-Mail Spam and now I am forced use my e-mail form @:
E-Mail: http://www.lak-12.org/scripts/mail.cgi?markkotoff
Please accept my apology for any inconvenience.
------------------------------
Date: Fri, 21 Aug 1998 21:19:35 GMT
From: shawn_campbell@my-dejanews.com
Subject: Date Manipulation
Message-Id: <6rko96$eud$1@nnrp1.dejanews.com>
I am looking for a way to manipulate dates in Perl: ie. add/subtract various
date parts. Most ide's (VB, Access, Powerbuilder) and databases (Oracle
PL/SQL, Sybase Transact SQL) have functions for this purpose. However, I
have not found anything similar in Perl.
Any help would be appreciated.
Thanks,
Shawn Campbell
shawn.campbell@janus.com
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 21 Aug 1998 16:06:54 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: doomen@my-dejanews.com
Subject: Re: Hacking Schools Network
Message-Id: <lnoicadt.fsf@mailhost.panix.com>
doomen@my-dejanews.com writes:
> <>>>>>>)(>Do anyone know how hack my schools network?
Hoping to change that failing grade in your grammar class?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: 21 Aug 1998 21:06:44 GMT
From: Michael Huttner <mnh@pluto.njcc.com>
Subject: have Felix Gallo and Penguin vanished?
Message-Id: <6rknh4$mgi$1@mars.njcc.com>
Have been seeking patches needed to install/run Penguin modules but
coriolan.amicus.com (where these patches live) has not been enabling
either http or ftp services... does anyone know where I can get the
updated patch/modules I need?
When attempting to run the One_Penguin-pre2 penguind, after inputting a password
i get:
IO::Socket: Cannot configure a generic socket at /opt/perl5/lib/site_perl/Penguin/Channel/TCP/Server.pm line 20
Michael (mnh@njcc.com)
/ )
/ /
_( (_ _ ________________________________________________
(((\ \> /_> / \
(\\\\ \_/ / | This guy here. He's a troublemaker. |
\ / | Always making wisecracks, like "You can pick |
\ _/ | your friends and you can pick your nose but |
/ / | you can't pick your friends' nose..." |
/ / \___ ___________________________________________/
/ / |/
------------------------------
Date: Tue, 18 Aug 1998 10:06:13 +0100
From: Robert Saunders <saunder@kben.co.uk>
Subject: How do I read a file backwards.
Message-Id: <35D94405.74836B3D@kben.co.uk>
Hi
I want to look through some very large files for particular lines.
Since I want the last occurence of these lines, working from the end
of the file towards the start would be preferable. other than repeatedly
invoking `tail -n` with n increasing can anybody suggest a better way.
Thanks
Robert
------------------------------
Date: Fri, 21 Aug 1998 16:28:17 -0400
From: John Porter <jdporter@min.net>
Subject: Re: logfile analysis
Message-Id: <35DDD861.3B1B@min.net>
Ronan Collins wrote:
>
> I am an internet access provider and I am planning to identify, for each
> site, the top N (where N is a pre-set integer) host recipients of data, and
> the top N external sources of data.
> Has anyone done this before? If so, please advise me.
Have you looked at the Logfile module on CPAN?
It might do what you want, but since you didn't really say what you
want to do (like, what web server are you using?), it's hard to guess.
--
John Porter
------------------------------
Date: 21 Aug 1998 21:21:06 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: logfile analysis
Message-Id: <slrn6trpal.hm.gabor@guava.vmunix.com>
In comp.lang.perl.misc, Ronan Collins <ronan.collins@heanet.ie> wrote :
# I am an internet access provider and I am planning to identify, for each
# site, the top N (where N is a pre-set integer) host recipients of data, and
# the top N external sources of data.
# Has anyone done this before? If so, please advise me.
If you want to parse your apache log file hits and some stats I have
written a perl script to do that. Find it at
http://vnode.vmunix.com/~gabor/perl/logstats.pl
------------------------------
Date: Fri, 21 Aug 1998 16:07:37 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Mistake (Was: Re: Help: Problem with Pattern-Matching)
Message-Id: <1de4079.1ntagozsirtx2N@slip-32-100-246-30.ny.us.ibm.net>
Mooneer Salem <mooneer@earthlink.net> wrote:
> Mooneer Salem wrote:
> >
> >
> > Try something like this:
> >
> > $text = "Many greetings to Petra and Sebastian";
> > $text =~ tr/A-z/a-z/;
> > $text =~ s/\s*(.)(*)\s*/$1$2/g;
> > $text =~ s/ //g;
> >
> > Hope this helps.
> >
>
> Oops! I meant the following:
>
> $text = "Many greetings to Petra and Sebastian";
> $text =~ tr/A-Z/a-z/;
> $text =~ s/\s*(.)(.*)\s*/
> $1 =~ tr/a-z/A-Z/;
> $total = $1$2;
> $total;
> /ge;
> $text =~ s/ //g;
>
> Sorry for any trouble the original poster had with my code.
It's still not quite right.
$text = "Many greetings to Petra and Sebastian";
$text =~ s/\b(\w+)/\u$1/g;
$text =~ tr/ //d;
print "$text\n";
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: Fri, 21 Aug 1998 20:11:29 GMT
From: NOjcjSPAM@mail.med.upenn.edu (Mr. Mirthful)
Subject: Re: NEWBIE Question: Perl Script in Unix vs. NT
Message-Id: <35ddd442.95346951@uphs1>
On Thu, 20 Aug 1998 13:35:02 +0200, "Tom Adriaenssen" <tom@imagic.be>
decreed:
>Don't know what editor you are using, but we've expierenced the same
>problems.
>You'll have to check in what format your script is: MSDOS (CRLF at end of
>each line) or Unix (LF at end of each line), because it seems to matter.
>Running MSDOS saved scripts on Unix fails, but if we save em into Unix
>format, they work great.
>Get a descent editor (i recommand TextPad) that can do the conversion for
>you, or a utility to do the conversion.
TextPad is MAC, no? Anyone know a format to save in from Windows that
will avoid the ^M problem?
-Jerrold
--remove NOSPAM to reply
--
My Father Always Believed That | I want | The Acquisition
Laughter Was The Best Medicine, | to | of Information
I Guess That's Why Several Of | believe. | is an Advantageous
Us Died Of Tuberculosis! :^) | - X-Files | Expedition.
http://mail.med.upenn.edu/~jcj
------------------------------
Date: 21 Aug 1998 16:05:59 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Perl Bots! [Chatterbots, FAQbots, InfoBots]
Message-Id: <n28ycafc.fsf@mailhost.panix.com>
harry@dublin.net (Harry McGreggor) writes:
> Has anyone used the Eliza module to create anything useful?
[*boggle*]
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf/
------------------------------
Date: Fri, 21 Aug 1998 13:33:29 -0700
From: Bill Chapman <bchapman@best.com>
Subject: Perl debugger?
Message-Id: <35DDD999.13E63067@best.com>
Have you used a Perl debugger? If so, which one, and more importantly,
how good was it?
Can you compare the quality of your Perl debugger with that of say, dbx
or dbxtool or Visual C++ or Visual Cafe for Java?
Someone told me they had used a Perl debugger, but it was a bit limited
compared to other debuggers he had used. Do you agree with this?
Bill
------------------------------
Date: 21 Aug 1998 21:25:26 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Perl debugger?
Message-Id: <6rkok6$b74$1@info.uah.edu>
In article <35DDD999.13E63067@best.com>,
Bill Chapman <bchapman@best.com> writes:
: Have you used a Perl debugger? If so, which one, and more importantly,
: how good was it?
I've only used the standard debugger. I hear ptkdb is pretty cool.
: Can you compare the quality of your Perl debugger with that of say, dbx
: or dbxtool or Visual C++ or Visual Cafe for Java?
Smaller, cheaper, faster! :-) Quality is an adjective that doesn't
apply to MS products. dbx is nice, but gdb is nicer. For some
reason, I don't usually like applications whose name matches /tool$/.
: Someone told me they had used a Perl debugger, but it was a bit limited
: compared to other debuggers he had used. Do you agree with this?
Certainly not. If, by `limited', this someone meant it wouldn't
create pretty windows that inspire a deep sense of peace and
satisfaction, then, yes, it's limited. I've never been dissatisfied
with perl -d.
In addition to perl -d, print and Data::Dumper are your friends. :-)
Greg
--
Nothing defines humans better than their willingness to do irrational things
in the pursuit of phenominally unlikely payoffs.
-- Scott Adams
------------------------------
Date: Fri, 21 Aug 1998 20:17:34 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: Prime numbers [was Re: here's an implementation of diff in perl]
Message-Id: <6rkjsb$2lu$1@rand.dimensional.com>
[posted to comp.lang.perl.misc and mailed to the cited author]
In article <r8zpcyvrju.fsf_-_@asc.sps.mot.com>
Martin Gregory <mgregory@asc.sps.mot.com> wrote:
>
>abigail@fnx.com (Abigail) writes:
>> --
>> perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
>
>Is this some well known trick for detecing prime numbers?
Yup, division, the best known trick for detecting prime
numbers.
>How does it work?
The first time through it matches the regex against
`1', fails, and prints. Second time it matches
against `11', fails, and prints. Same thing for
the third time except that now it matches against `111'.
The fourth time the regex succeeds so it doesn't print.
dgris
--
Daniel Grisinger dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
Dave Clark
------------------------------
Date: Fri, 21 Aug 1998 20:47:36 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Prime numbers [was Re: here's an implementation of diff in perl]
Message-Id: <I1lD1.239$pY1.2030779@news2.voicenet.com>
Martin Gregory <mgregory@asc.sps.mot.com> wrote:
>
>abigail@fnx.com (Abigail) writes:
>> --
>> perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
>
>Is this some well known trick for detecing prime numbers?
>
>How does it work?
Abigail's sigs are great fun to decode.
Breaking this down to somthing much less elegant:
#!/usr/local/bin/perl -w
# One liner to script
# perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
$\ = $/; # mimic -l from command line
# $\ = "\n" may be a bit more clear
# Clearest of all would be to specify "\n" in print statements
# (1 x $_) - every loop, print loop counter 1's
# No match, so we get 1
1 !~ /^(11+)\1+$/ && print 1;
# No match, so we get 2
11 !~ /^(11+)\1+$/ && print 2;
# No match, so we get 3
111 !~ /^(11+)\1+$/ && print 3;
# Matches (11)11 -- Don't print
1111 !~ /^(11+)\1+$/ && print 4;
# No match, so we get 5
11111 !~ /^(11+)\1+$/ && print 5;
# Matches (111)111 -- Don't print
111111 !~ /^(11+)\1+$/ && print 6;
# No match, so we get 7
1111111 !~ /^(11+)\1+$/ && print 7;
# Matches (1111)1111 -- Don't print
11111111 !~ /^(11+)\1+$/ && print 8;
print "Peek: 8 matched $1 -- Not prime";
# Matches (111)111111 -- Don't print (Two groups of 111 match
# \1+)
111111111 !~ /^(11+)\1+$/ && print 9;
print "Peek: 9 matched $1 -- Not prime";
# Matches (11111)11111 -- Don't print
1111111111 !~ /^(11+)\1+$/ && print 10;
__END__
That's a breakdown of the first ten numbers. Unfortunately, my math
isn't as good as it could be but here's my take on what's going on here.
The while loop is counting in unary (meaning we have only one symbol to
count with (Having it be a 1 is misleading... I would've made it a 0)).
Apparently, when counting in base 1, prime numbers exhibit a pattern (I
can't come up with a clearer way of showing this pattern than the regex
/^(11+)\1+$/).
What I'd be interested to see is why this pattern works. And, does it
work with other bases? Or does the complexity rise too fast?
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Fri, 21 Aug 1998 21:41:38 GMT
From: mcafee@pacman.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Prime numbers [was Re: here's an implementation of diff in perl]
Message-Id: <mQlD1.1572$QT4.7378643@newbabylon.rs.itd.umich.edu>
In article <I1lD1.239$pY1.2030779@news2.voicenet.com>,
Matt Knecht <hex@voicenet.com> wrote:
>Martin Gregory <mgregory@asc.sps.mot.com> wrote:
>>abigail@fnx.com (Abigail) writes:
>>> perl -wle '(1 x $_) !~ /^(11+)\1+$/ && print while ++ $_'
>>Is this some well known trick for detecing prime numbers?
>>How does it work?
>The while loop is counting in unary (meaning we have only one symbol to
>count with (Having it be a 1 is misleading... I would've made it a 0)).
Well, obfuscation is the point, after all...
>Apparently, when counting in base 1, prime numbers exhibit a pattern (I
>can't come up with a clearer way of showing this pattern than the regex
>/^(11+)\1+$/).
>What I'd be interested to see is why this pattern works. And, does it
>work with other bases? Or does the complexity rise too fast?
It has nothing to do with the number base used.
Let $x and $y be strings such that $x = $c x $n and $y = $c x $m, for any
one-character string $c ('1' in our case) and some integers $n and $m.
Then
$x =~ /^($y)\1+$/
will be a true expression iff $x consists of an integral number >= 2 of
repetitions of $y (that is, if $n is evenly divisible by $m, $n/$m being at
least 2). Clear?
If $y is replaced with 11+, the + quantifier will first gobble up all of
$x, thereby testing if $n is divisible by $n, $n/$n being at least 2.
After this initial failure, the + quantifier will put back '1's one at a
time until either the patten is matched or it cannot put back any more
'1's. In other words, the RE engine successively tests whether $n is
divisible by $n-1, $n-2, ..., 2. If this test ever succeeds, $n is
composite and is not printed. If the match ultimately fails, then $n is
not divisble by any number from 2 to $n-1, so it is prime and is printed.
Neat, isn't it? I think this has to be one of the niftiest pieces of Perl
code I've ever seen.
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Fri, 21 Aug 1998 16:30:42 -0400
From: Rasan Rasch <rasan@horizonlive.com>
Subject: Re: Problem using CGI.pm for the first time
Message-Id: <35DDD8F2.BEBB4FF6@horizonlive.com>
>
> But when I run, it gave me this -
> torrey:~/public_html>t.cgi
> (offline mode: enter name=value pairs on standard input)
This is just a prompt to enter parameters for your script and is not an
error. This is very useful for command line debugging. For example,
torrey:~/public_html>t.cgi
(offline mode: enter name=value pairs on standard input)
name1=value1
name2=value2
etc ...
Ctrl-D
Typing Control D signals the end of this data input. Try using this
instead of Ctrl-C.
------------------------------
Date: Fri, 21 Aug 1998 13:54:46 -0700
From: Francis Fan <ffan@mail.arc.nasa.gov>
Subject: Re: Problem using CGI.pm for the first time
Message-Id: <35DDDE95.DB666D1E@mail.arc.nasa.gov>
Rasan Rasch wrote:
> >
> > But when I run, it gave me this -
> > torrey:~/public_html>t.cgi
> > (offline mode: enter name=value pairs on standard input
> This is just a prompt to enter parameters for your script and is not an
> error. This is very useful for command line debugging. For example,
> torrey:~/public_html>t.cgi
> (offline mode: enter name=value pairs on standard input)
> name1=value1
> name2=value2
> etc ...
> Ctrl-D
>
> Typing Control D signals the end of this data input. Try using this
> instead of Ctrl-C.
I tried Ctrl-D, it gave me this -
~/public_html>t.cgi
(offline mode: enter name=value pairs on standard input)
Can't call method "rearrange" without a package or object reference at
(eval 6) line 5.
CGI=HASH(0x100b9250)Vegetables
And I will use CGI.pm in my cgi scripts, so I couldn't wait for user to
enter Ctrl-d.
--Francis
------------------------------
Date: Fri, 21 Aug 1998 17:59:20 -0400
From: Rasan Rasch <rasan@horizonlive.com>
Subject: Re: Problem using CGI.pm for the first time
Message-Id: <35DDEDB8.8DF93BE7@horizonlive.com>
>
> >
> > Typing Control D signals the end of this data input. Try using this
> > instead of Ctrl-C.
>
> I tried Ctrl-D, it gave me this -
>
> ~/public_html>t.cgi
> (offline mode: enter name=value pairs on standard input)
> Can't call method "rearrange" without a package or object reference at
> (eval 6) line 5.
> CGI=HASH(0x100b9250)Vegetables
>
> And I will use CGI.pm in my cgi scripts, so I couldn't wait for user to
> enter Ctrl-d.
>
> --Francis
Ctrl-D is used to execute your script at the command line. Users will be
using your cgi through http and ctrl-d will be irrelevant. Try using the
following to get rid of your error:
use CGI qw(:standard);
print header;
print start_html(-title=>'Vegetables'); #this may fix your hash error
Then use ctrl-d after seeing that offline mode message.
------------------------------
Date: Fri, 21 Aug 1998 20:32:03 GMT
From: nick.bauman@imationstudio.com
Subject: Re: Quickie encapsulation question
Message-Id: <6rklg4$bg5$1@nnrp1.dejanews.com>
In article <35D84773.16CC@min.net>,
jdporter@min.net wrote:
> nick@imationstudio.com wrote:
> >
> > Let's say I have a package:
> > package JobOrder;
> > In that package, I have several other classes "used" and instantiated.
> > The one in question is my own class, called Validate. I go and do:
> > $val = new Validate;
> > I can assume this object now exists fully scoped as $main::JobOrder::val.
>
> That's assuming that $val is a "global" variable in package JobOrder,
> rather than a lexical ("my") variable in some subroutine or other block.
> But I assume that's what you want.
>
> And you really don't need the 'main::' part, it just adds clutter.
>
> > I've got it working now so that if any method in my $val object needs to
> > access a method in the JobOrder class, I can call it explicitly. But I don't
> > want to do that. (no reuse payoff) What I want to do is have the caller pass
> > name of the package it's in and have the method buried inside the class know
> > how to call methods in the calling class at invocation time, which can
change
> > from invocation to invocation. i.e.:
> > $val->whatever("JobOrder", $whatnot, $foobar);
> > and having the method in $val calling a method in JobOrder by having this:
> > whatever(@) {
> > my( $package, $param1, $param2 ) = @_; # (I rewrote this.)
> > # call a method in the upstream class
> > $$package::upstream_class_obj->upstream_class_meth();
> > }
>
> You have a blessed object, $val, of package Validate.
> And you call $val->whatever(). That means the first argument to
> whatever() is going to be the object reference; but your code
> ignores it. The fact that you also left out the 'sub' keyword makes
> me think you should have posted your actual code (with irrelevant
> lines deleted).
>
> Now you should remember that you can call "package methods" just
> like object methods, but passing the name of the package as the
> first argument. You can use the arrow syntax if you want.
>
> sub whatever {
> my( $self, $package, $param1, $param2 ) = @_;
> $package->upstream_package_method(); # PACKAGE method
> }
>
> Part of your confusion is the distinction between methods of
> objects -- which (big surprise) require an object reference --
> and methods of packages, which require a package name.
> If you only pass the name of a package, where do you expect to
> get a reference to an object in that package from, let alone
> call a method on that object?
>
> Judging by the little bit of code you gave, you seem to have
> implemented JobOrder as a non-object package, i.e. providing
> only package methods, not object methods. You will probably
> be better off making it use objects. If you do, then you will
> pass an object reference to whatever(), rather than a package
> name:
>
> sub whatever {
> my( $self, $joborder, $param1, $param2 ) = @_;
> $joborder->upstream_object_method(); # OBJECT method
> }
>
> Next question?
>
Hey, this helps a ton. Previously, I hacked my way around the problem by
using explicit package names or some $:: hacks and commenting out the package
decs in the parent package. This really sucks, as it won't even pass 'use
strict',
I've tried a couple of things similar to what you have suggested only to have
it fail because the subclass method's can't "see" objects branching from the
parent class. I believe I'll try it once more and see if I can get it to work.
The problem is that I am accessing object methods in the parent class through
these methods :| I somehow think that I may be wrongheadded in this approach.
So it may be really a design problem more than a Perl problem.
Anyway, thanks.
-Nick
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 21 Aug 1998 20:32:13 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: swap words in regexp
Message-Id: <6rklgd$g17$1@marina.cinenet.net>
Daniel Grisinger (dgris@rand.dimensional.com) wrote:
: In article <35DD87D5.41C6@mashie.ece.jhu.edu>,
: Chenyang Xu <NOSPAMchenyangNOSPAM@mashie.ece.jhu.edu> wrote:
: > I would like to perform the following swap in PERL using regexp.
: >
: > UpperCaseWord -> CaseUpperWord
: > AnotherUpperCaseWord -> UpperAnotherCaseWord
:
: $string = 'UpperCaseWord';
: $string =~ s/\b([A-Z][a-z]+?)([A-Z][a-z]+?)/$2$1/;
Nope.
print "$string\n";
yields 'CaUpperseWord'. The problem is your use of non-greedy
quantifiers; the first one is meaningless (you need an uppercase following
the string of lowercases, so the match must include all the lowercases in
between), and the second is harmful (the match stops at 'Ca' for the
second capturing parens). Eliminate both ? non-greedy quantifiers and
it'll work as advertised.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: Fri, 21 Aug 1998 21:08:53 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: swap words in regexp
Message-Id: <6rkms6$2oq$1@rand.dimensional.com>
[posted to comp.lang.perl.misc and mailed to the cited author]
In article <6rklgd$g17$1@marina.cinenet.net>
cberry@cinenet.net (Craig Berry) wrote:
>: $string = 'UpperCaseWord';
>: $string =~ s/\b([A-Z][a-z]+?)([A-Z][a-z]+?)/$2$1/;
>
>Nope.
>
> print "$string\n";
Ack! That'll teach me to pay attention when cutting and
pasting :-).
Thanks, Craig.
dgris
--
Daniel Grisinger dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
Dave Clark
------------------------------
Date: Fri, 21 Aug 1998 17:46:46 -0400
From: "Lily Y. Fu" <lily@tigr.org>
Subject: Turn Perl program into binary
Message-Id: <35DDEAC6.347B@tigr.org>
Hi,
I have a perl program having password information in clear text.
I want people to run the program but don't want them to
know the password. If I make the program not readable by
the user, it won't run.
Is there a way to "compile" the program into binary
so that the password is not in clear text at least?
Thanks,
--
Lily Fu
The Institute for Genomic Research
Voice Mail: (301) 838-3557
Email: lily@tigr.org
------------------------------
Date: Fri, 21 Aug 1998 16:07:39 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: what is 'sub f () {555};'
Message-Id: <1de4494.x70tsm1jbvbrcN@slip-32-100-246-30.ny.us.ibm.net>
Josh Kortbein <kortbein@iastate.edu> wrote:
> Abigail (abigail@fnx.com) wrote:
> : Josh Kortbein (kortbein@iastate.edu) wrote on MDCCCXV September MCMXCIII
> : in <URL: news:6rhvkr$bvv$6@news.iastate.edu>:
> : ++ Steven Smith (steves@wco.com) wrote:
> : ++ : I'm trying to understand a lib we pulled off of the net. I've never
> : ++ : seen this before.
> : ++ : what would a sub declaration like this do??
> : ++
> : ++ : sub f () {555};
> : ++
> : ++ Have you tried it?
> : ++
> : ++ It looks to me like it returns 555, regardless of the argument
> : ++ provided - which leads me to believe that it's either (a) useless,
> : ++ or (b) capable of doing something else that I don't see. AFAIK,
> : ++ though, it just returns 555.
> : I guess you find
> : # define f 555
> : in C code useless as well?
>
> No, but since I don't need to use C I prefer
>
> const int f = 555;
>
> in C++.
>
> Despite the fact that constant subs have a use, I still don't
> find them very useful - it's better IMO for code to just use
> plain old scalars, as opposed to something that borders on
> obfuscation.
If the constant is defined before it is used, then it is optimized so
that
if ($x == f) {
is identical to
if ($x == 555) {
, and therefore is faster than a scalar variable.
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3503
**************************************