[17375] in Perl-Users-Digest
Perl-Users Digest, Issue: 4797 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 2 18:10:46 2000
Date: Thu, 2 Nov 2000 15:10:19 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973206619-v9-i4797@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 2 Nov 2000 Volume: 9 Number: 4797
Today's topics:
Format Arrays ? Please assist msalerno@my-deja.com
Re: Format Arrays ? Please assist (Clay Irving)
Re: Format Arrays ? Please assist msalerno@my-deja.com
Re: Format Arrays ? Please assist (Tad McClellan)
Re: Format Arrays ? Please assist (Tad McClellan)
Getting NT Domain Full Names with Win32::NetAdmin <rckjr@yahoo.com>
Re: giving , another name, like "and" for && (was: rena (Joe Smith)
Re: Hardwood Website <elaine@chaos.wustl.edu>
Re: Hardwood Website (Tad McClellan)
Re: Hardwood Website (Clay Irving)
Re: indirect sub call with strict (Mark-Jason Dominus)
Re: Is there a way to get all PID's within Perl ? (Tom Christiansen)
Re: killfiles (was Re: Perl style and module searches) (Tom Christiansen)
LOOP TIMEOUT <felix.gourdeau@videotron.ca>
Re: LOOP TIMEOUT <jeffp@crusoe.net>
My brain hurts: another regex Q. <dpc3k@virginia.edu>
Re: My brain hurts: another regex Q. (Colin Watson)
Re: My brain hurts: another regex Q. (Tad McClellan)
Re: My brain hurts: another regex Q. <jeffp@crusoe.net>
Re: Need suggestions on optimization (brian d foy)
Re: Need suggestions on optimization <ren.maddox@tivoli.com>
Re: Newbie: How to COMPARE DATES in Perl??? <jeff@yoak.com>
Re: Newbie: How to COMPARE DATES in Perl??? <clarityassoc@earthlink.net>
Re: Newbie: How to COMPARE DATES in Perl??? <clarityassoc@earthlink.net>
Re: Newbie: How to COMPARE DATES in Perl??? <adamf@box43.gnet.pl>
Re: OOP and information hiding (Tom Christiansen)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 02 Nov 2000 20:48:52 GMT
From: msalerno@my-deja.com
Subject: Format Arrays ? Please assist
Message-Id: <8tsjvh$ohf$1@nnrp1.deja.com>
I am working on a script and I would like to search through the PID's
of a system (for another purpose). The only problem that I am having
is that the output has some extra spaces. The first line of the output
starts with no spaces, but after the first line everything is indented.
I looked at the perldoc -q space but it doesn't do a thing. Please let
me know what I am missing.
Thanks,
Matt
#!/usr/bin/perl -w
use strict;
{
my @pids = `/usr/bin/ps -ef -o user -o pid -o args`;
print "Who's processes do you want to see? ";
chomp(my$name = <STDIN>);
my @fin=grep(/$name/,@pids);
print "\n@fin";
}
The script returns:
msalerno 12613 -bash
msalerno 18501 -bash
msalerno 18484 -bash
msalerno 18498 telnet localhost
msalerno 11897 -bash
msalerno 18510 -bash
msalerno 18512 ftp localhost
msalerno 18507 telnet localhost
msalerno 11973 -bash
msalerno 18513 in.ftpd
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 2 Nov 2000 22:03:23 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Format Arrays ? Please assist
Message-Id: <slrn903p5b.sv3.clay@panix3.panix.com>
On Thu, 02 Nov 2000 20:48:52 GMT, msalerno@my-deja.com
<msalerno@my-deja.com> wrote:
>I am working on a script and I would like to search through the PID's
>of a system (for another purpose). The only problem that I am having
>is that the output has some extra spaces. The first line of the output
>starts with no spaces, but after the first line everything is indented.
>I looked at the perldoc -q space but it doesn't do a thing. Please let
>me know what I am missing.
>
>Thanks,
>
>Matt
>
>#!/usr/bin/perl -w
>use strict;
>{
> my @pids = `/usr/bin/ps -ef -o user -o pid -o args`;
> print "Who's processes do you want to see? ";
> chomp(my$name = <STDIN>);
> my @fin=grep(/$name/,@pids);
> print "\n@fin";
>}
>
>The script returns:
>
>msalerno 12613 -bash
> msalerno 18501 -bash
> msalerno 18484 -bash
> msalerno 18498 telnet localhost
> msalerno 11897 -bash
> msalerno 18510 -bash
> msalerno 18512 ftp localhost
> msalerno 18507 telnet localhost
> msalerno 11973 -bash
> msalerno 18513 in.ftpd
Check the FAQ -- In perlfaq5:
Why do I get weird spaces when I print an array of lines?
--
Clay Irving <clay@panix.com>
Some people are born mediocre, some people achieve mediocrity, and some
people have mediocrity thrust upon them.
- Joseph Heller
------------------------------
Date: Thu, 02 Nov 2000 22:05:16 GMT
From: msalerno@my-deja.com
Subject: Re: Format Arrays ? Please assist
Message-Id: <8tsoel$ssr$1@nnrp1.deja.com>
In article <8tsjvh$ohf$1@nnrp1.deja.com>,
msalerno@my-deja.com wrote:
> I am working on a script and I would like to search through the PID's
> of a system (for another purpose). The only problem that I am having
> is that the output has some extra spaces. The first line of the
output
> starts with no spaces, but after the first line everything is
indented.
> I looked at the perldoc -q space but it doesn't do a thing. Please
let
> me know what I am missing.
>
> Thanks,
>
> Matt
>
That part of the previous message that reads, the script returns: is
incorrect, there really is an extra space placed on the left of all
lines except the first. I found out that adding
my $test = join '' => @fin;
and then printing @test works fine !
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 2 Nov 2000 16:19:32 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Format Arrays ? Please assist
Message-Id: <slrn903mj4.fus.tadmc@magna.metronet.com>
On Thu, 02 Nov 2000 20:48:52 GMT, msalerno@my-deja.com
<msalerno@my-deja.com> wrote:
>The first line of the output
>starts with no spaces, but after the first line everything is indented.
>I looked at the perldoc -q space but it doesn't do a thing. Please let
>me know what I am missing.
It is not what you are missing, it is what you have included :-)
perldoc perlvar
See the $" special variable, which is what is providing the space characters.
You have asked for spaces to be inserted between the array elements,
so that is what perl is doing. (interpolating an array is asking
for that behavior).
Ask for something else if you want perl to do something else, heh heh.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 2 Nov 2000 16:38:35 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Format Arrays ? Please assist
Message-Id: <slrn903nmr.g2m.tadmc@magna.metronet.com>
On Thu, 02 Nov 2000 22:05:16 GMT, msalerno@my-deja.com
<msalerno@my-deja.com> wrote:
>In article <8tsjvh$ohf$1@nnrp1.deja.com>,
> msalerno@my-deja.com wrote:
>> The first line of the
>output
>> starts with no spaces, but after the first line everything is
>indented.
>I found out that adding
>my $test = join '' => @fin;
>and then printing @test works fine !
^^^^^
Eh? Must mean $test there.
No need for such convolutions. If you don't like what you get
from interpolating an array, just don't interpolate it:
print @fin, "\n";
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 02 Nov 2000 21:38:33 GMT
From: Dr. Strangepork <rckjr@yahoo.com>
Subject: Getting NT Domain Full Names with Win32::NetAdmin
Message-Id: <8tsmso$r94$1@nnrp1.deja.com>
I can get users' full names with Win32::NetAdmin::GetUsers($PDC,
FILTER_NORMAL_ACCOUNT , \%Users), but considering I have almost 8,000
user accounts in my domain, I'd rather not get the entire user database
just to match one user's fullname. Is there an easier way to get the
fullname of a user account?
--
Rick Kasten, MCSE SysAdmin Consultant
Collective Technologies http://www.colltech.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 2 Nov 2000 19:52:50 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: giving , another name, like "and" for && (was: renaming local())
Message-Id: <8tsgmi$1kr6$1@nntp1.ba.best.com>
In article <8tjmck$ejj$1@lublin.zrz.tu-berlin.de>,
Anno Siegel <anno4000@lublin.zrz.TU-Berlin.DE> wrote:
>I have sometimes thought it might be handy to
>be able to use multiple commas in a row for a series of undef's:
>func( $w, undef, undef, $z) would become func( $w,,, $z). Now some-
>one will point out the horrible ramifications of this naive suggestion.
That change would break existing code.
func($w,,,$z) works as func($w,$z) today.
-Joe
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.
------------------------------
Date: Thu, 02 Nov 2000 20:16:00 GMT
From: "Elaine Ashton" <elaine@chaos.wustl.edu>
Subject: Re: Hardwood Website
Message-Id: <4YjM5.13322$AM5.250505@news1.nokia.com>
"Markus Humm" <mhumm@ba-mosbach.de> wrote in message
news:3A01173A.2C12D2BB@ba-mosbach.de...
> > Hardwood floors and more! See the natural beauty of hardwood flooring
and hardwood designs at
> why do you post that here?
> NO ONE HERE IS INTERESTED IN THAT!!!
Actually, I was kinda disappointed it wasn't about Viagra.
e.
------------------------------
Date: Thu, 2 Nov 2000 15:44:26 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Hardwood Website
Message-Id: <slrn903kha.fon.tadmc@magna.metronet.com>
[ Newsgroups radically trimmed ]
On Thu, 02 Nov 2000 20:16:00 GMT, Elaine Ashton <elaine@chaos.wustl.edu> wrote:
>"Markus Humm" <mhumm@ba-mosbach.de> wrote in message
>news:3A01173A.2C12D2BB@ba-mosbach.de...
>> > Hardwood floors and more! See the natural beauty of hardwood flooring
>and hardwood designs at
>> why do you post that here?
>> NO ONE HERE IS INTERESTED IN THAT!!!
>
>Actually, I was kinda disappointed it wasn't about Viagra.
Women.
Always only one thing on their mind...
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 2 Nov 2000 22:05:55 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Hardwood Website
Message-Id: <slrn903pa3.sv3.clay@panix3.panix.com>
On Thu, 2 Nov 2000 15:44:26 -0500, Tad McClellan <tadmc@metronet.com> wrote:
>[ Newsgroups radically trimmed ]
>
>
>On Thu, 02 Nov 2000 20:16:00 GMT, Elaine Ashton <elaine@chaos.wustl.edu> wrote:
>>"Markus Humm" <mhumm@ba-mosbach.de> wrote in message
>>news:3A01173A.2C12D2BB@ba-mosbach.de...
>>> > Hardwood floors and more! See the natural beauty of hardwood flooring
>>and hardwood designs at
>>> why do you post that here?
>>> NO ONE HERE IS INTERESTED IN THAT!!!
>>
>>Actually, I was kinda disappointed it wasn't about Viagra.
>
>
>Women.
>
>Always only one thing on their mind...
Well, it does mention the beauty of hard wood...
--
Clay Irving <clay@panix.com>
Ideally, you should be your own hero, just as I am mine.
- Bargepole
------------------------------
Date: Thu, 02 Nov 2000 19:56:17 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: indirect sub call with strict
Message-Id: <3a01c6e1.1b8$292@news.op.net>
In article <slrn8vqp2v.ac5.mgjv@martien.heliotrope.home>,
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>> Thanks for the tip, Nick. But with your code I still get:
>> syntax error at ./test_subcall.pl line 9, near "->("
>
>it runs fine.
Perhaps the original poster is running Perl 5.003 and you are not.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f|ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: 2 Nov 2000 16:04:30 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Is there a way to get all PID's within Perl ?
Message-Id: <3a01f2fe@cs.colorado.edu>
In article <8tsd4a$i3q$1@nnrp1.deja.com>, <msalerno@my-deja.com> wrote:
>pretty much what the title asks. I would like to be able to get a list
>of all running proccesses.
>
>I could use:
>@pids = `/usr/bin/ps -ef -o user -o pid -o args`;
Congratulations, that's not portable.
% /usr/bin/ps -ef -o user -o pid -o args
/usr/bin/ps: Command not found.
Moral of that story: don't use full paths. But it's worse.
% /bin/ps -ef -o user -o pid -o args
ps: illegal option -- f
usage: ps [-aChjlmrSTuvwx] [-O|o fmt] [-p pid] [-t tty] [-U user]
[-M core] [-N system] [-W swap]
ps [-L]
Moral of that story: you cannot count on exact details of
a command's arguments or its output format.
>But I would rather not have to call any external programs.
Give up. You basically have no choice, and this "call no other
program" sentiment is very anti-laziness, anti-Unix, anti-encapsulation,
anti-software-reuse, and just plain anti-smart.
The best you could hope for is a system-specific grunge through
/dev/kmem at your peril, and who wants to run setgid kmem to do
that even so? Do you remember how to call nlist(3)? How about
implementing it in perl? It's just a bunch of ugly C-looking code
anyway. Blech.
You should just call ps(1) and be done with it.
--tom
------------------------------
Date: 2 Nov 2000 15:48:33 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: killfiles (was Re: Perl style and module searches)
Message-Id: <3a01ef41$1@cs.colorado.edu>
In article <slrn9039bs.evs.tadmc@magna.metronet.com>,
Tad McClellan <tadmc@metronet.com> wrote:
>I find that more often than not, if I open up a "newbie"
>article, I will find someone wanting me to read the docs to them.
>
>So I just don't open them.
Er, "open"???
--tom
------------------------------
Date: Thu, 02 Nov 2000 15:15:28 -0500
From: =?iso-8859-1?Q?F=E9lix?= Gourdeau <felix.gourdeau@videotron.ca>
Subject: LOOP TIMEOUT
Message-Id: <3A01CB60.A83A9EEF@videotron.ca>
Hi,
If my loop continue after 10 seconds, i want it to stop. I tried this :
$n =3D 0;
eval {
local $SIG{ALRM} =3D sub { die "Timeout"; };
alarm 10;
while (1) { print "$n\n"; $n +=3D 1; }
alarm 0;
};
if ($@ and $@ =3D~ /Timeout/) { print "Timeout\n"; }
but it didn't work, the loop is not executed. And if i put the line at
the end of the script :
if ($@) { print "$@\n"; }
it return an error: The Unsupported function alarm function is
unimplemented at ... line 7.
I am using ActivePerl/v5.6.0 under win98. I dont think that alarm is a
module.
So if someone know whats wrong, help me! Thanx in advance.
F=E9lix Gourdeau -- felix.gourdeau@videotron.ca
------------------------------
Date: Thu, 2 Nov 2000 17:10:32 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: LOOP TIMEOUT
Message-Id: <Pine.GSO.4.21.0011021709490.25313-100000@crusoe.crusoe.net>
[posted & mailed]
On Nov 2, F=E9lix Gourdeau said:
>it return an error: The Unsupported function alarm function is
>unimplemented at ... line 7.
>I am using ActivePerl/v5.6.0 under win98. I dont think that alarm is a
>module.
>So if someone know whats wrong, help me! Thanx in advance.
Does the error not make it plain enough? ActivePerl 5.6.0 on Win98 does
not support the alarm() function. Read: IT WON'T WORK.
--=20
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Thu, 2 Nov 2000 17:00:06 -0500
From: "Doug Coppage" <dpc3k@virginia.edu>
Subject: My brain hurts: another regex Q.
Message-Id: <8tso5g$ds$1@murdoch.acc.Virginia.EDU>
Dearest Colleagues:
Preliminaries:
1. Yes, I have read the standard articles on regular expressions.
2. Yes, I have searched perldoc -q "[pick a relevant keyword]".
3. No, regular expressions are not "intuitive"; they are terser than terse
and worse than Hungarian. My brain hurts.
4. If I really knew what I was doing, this would be easy. Please have pity.
This should be cake for old Perl hands.
[Ahem.]
I would like to truncate a string at the first character that is NOT in
[0-9a-zA-Z_]. For example...
Before: $exStr1 eq "asd_98uy 8vn34j_f"
<Magic happens here.>
After: $exStr1 eq "asd_98uy"
Before: $exStr2 eq "asd_9+8uy 8vn34j_f"
<Ditto.>
After: $exStr2 eq "asd_9"
Before: $exStr3 eq " asd_9+8uy 8vn34j_f" # note initial space
<This is wonderful!>
After: $exStr3 eq ""
Many thanks,
---Doug Coppage
===========================================
Douglas P. Coppage, dpc3k@virginia.edu
Microcomputer Support Specialist
ITC - Academic Computing for the Health Sciences
University of Virginia, Charlottesville, VA
http://www.med.virginia.edu/achs
===========================================
------------------------------
Date: 2 Nov 2000 22:40:27 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: My brain hurts: another regex Q.
Message-Id: <8tsqgr$3h5$1@riva.ucam.org>
Doug Coppage <dpc3k@virginia.edu> wrote:
>I would like to truncate a string at the first character that is NOT in
>[0-9a-zA-Z_]. For example...
OK, so negate the character class as described (somewhere) in
perlre(1p). A regular expression that matches any single character not
in that class is /[^0-9a-zA-Z_]/, or, more briefly, /\W/. /./ matches
any character (excluding newlines), and /.*/ matches any sequence of
characters (excluding newlines). Thus, a regular expression matching the
first such character and everything afterwards on the same line is
/\W.*/. (The \W will match the first non-word character it encounters
unless something later causes the whole regex not to be able to match if
it does that.)
Hence, using the s/// operator, you can do the truncation using the
following statement:
s/\W.*//;
Or, if you really want to write it out in longhand:
s/[^0-9a-zA-Z_].*//;
HTH,
--
Colin Watson [cjw44@flatline.org.uk]
"... and by God I *KNOW* what this network is for, and you can't have
it." - Russ Allbery (http://www.eyrie.org/~eagle/writing/rant.html)
------------------------------
Date: Thu, 2 Nov 2000 16:44:56 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: My brain hurts: another regex Q.
Message-Id: <slrn903o2o.g2m.tadmc@magna.metronet.com>
On Thu, 2 Nov 2000 17:00:06 -0500, Doug Coppage <dpc3k@virginia.edu> wrote:
>Dearest Colleagues:
>
>Preliminaries:
>1. Yes, I have read the standard articles on regular expressions.
>2. Yes, I have searched perldoc -q "[pick a relevant keyword]".
>3. No, regular expressions are not "intuitive"; they are terser than terse
>and worse than Hungarian. My brain hurts.
Wimp!
>4. If I really knew what I was doing, this would be easy. Please have pity.
Oh, ... alright.
>This should be cake for old Perl hands.
Yes. I added one character. Feeling silly yet? :-)
Masterful pleading up above there though. Very nice.
>I would like to truncate a string at the first character that is NOT in
>[0-9a-zA-Z_]. For example...
>Before: $exStr1 eq "asd_98uy 8vn34j_f"
$exStr1 =~ s/[^0-9a-zA-Z_].*//;
or the equivalent:
$exStr1 =~ s/\W.*//;
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 2 Nov 2000 17:45:07 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: My brain hurts: another regex Q.
Message-Id: <Pine.GSO.4.21.0011021740580.25313-100000@crusoe.crusoe.net>
[posted & mailed]
On Nov 2, Doug Coppage said:
>I would like to truncate a string at the first character that is NOT in
>[0-9a-zA-Z_]. For example...
>Before: $exStr1 eq "asd_98uy 8vn34j_f"
><Magic happens here.>
>After: $exStr1 eq "asd_98uy"
>
>Before: $exStr2 eq "asd_9+8uy 8vn34j_f"
><Ditto.>
>After: $exStr2 eq "asd_9"
>
>Before: $exStr3 eq " asd_9+8uy 8vn34j_f" # note initial space
><This is wonderful!>
>After: $exStr3 eq ""
$truncpos = $string =~ /\W/g ? (pos($string) - 1) : -1;
$string = substr($string, 0, $truncpos) if $truncpos != -1;
Does that make sense to you?
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Thu, 02 Nov 2000 15:21:10 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Need suggestions on optimization
Message-Id: <brian-ya02408000R0211001521100001@news.panix.com>
In article <Pine.GSO.4.21.0011021304400.24601-100000@mamba.cs.Virginia.EDU>, David Coppit <newspost@coppit.org> posted:
> On Thu, 2 Nov 2000, brian d foy wrote:
>
> > > I was wondering if anyone had some suggestions for me on optimizing
> > > some code.
> >
> > profile the code and think about the slow bits first. :)
>
> Thanks for the suggestion. As I noted in my original post, I did
> profile the code and the results suggest that there are no obvious
> slow parts.
oh sorry - indeed you did. i didn't see the bottom of the message. :(
> For example, here are the lines of code that use more than a few
> percent of the time:
>
> count wall tm cpu time
> 4021 14.48674 14.30000 $matchesBody = ($body_buffer =~
if that is taking up the most time, you might delve into
Mastering Regular Expressions to see if you can optimize
the regular expression. :)
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: 02 Nov 2000 14:35:20 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Need suggestions on optimization
Message-Id: <m3d7ge2juf.fsf@dhcp11-177.support.tivoli.com>
brian@smithrenaud.com (brian d foy) writes:
> In article <Pine.GSO.4.21.0011021304400.24601-100000@mamba.cs.Virginia.EDU>, David Coppit <newspost@coppit.org> posted:
> >
> > count wall tm cpu time
> > 4021 14.48674 14.30000 $matchesBody = ($body_buffer =~
>
> if that is taking up the most time, you might delve into
> Mastering Regular Expressions to see if you can optimize
> the regular expression. :)
I had a similar problem one time, and I eventually found that since
the file was large the fastest solution was simply to `grep ...`. Of
course, the file I was parsing was line based, but the principal still
holds. (The principal being that C-implemented grep is really much
faster when the file is large enough to offset the overhead of the
exec -- and that probably doesn't require it to be all that large.)
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Thu, 02 Nov 2000 10:43:51 +0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: Newbie: How to COMPARE DATES in Perl???
Message-Id: <8tscms026h6@news2.newsguy.com>
[posted and emailed]
In article <HRgM5.10331$rl.882352@newsread2.prod.itd.earthlink.net>, "Alan
Mailer" <clarityassoc@earthlink.net> wrote:
> I'm very new to Perl and need to know how I would begin to go about
> coding for the following needs:
>
> 1) Does DateA occur before DateB?
>
> 2) What is the difference in days/weeks/months/years between DateA and
> DateB?
>
Try examining the Date::Calc module. You'll often find that general
problems of this sort have been addressed with modules available either
in the standard distribution or on CPAN.
Cheers,
Jeff
------------------------------
Date: Thu, 02 Nov 2000 20:31:30 GMT
From: "Alan Mailer" <clarityassoc@earthlink.net>
Subject: Re: Newbie: How to COMPARE DATES in Perl???
Message-Id: <CakM5.10991$rl.923945@newsread2.prod.itd.earthlink.net>
Thanks to both Clay and Jeff for your suggestions. Unfortunately, I'm
enough of a newbie to not know what you mean when you say "Check out the
Perl modules Date::Calc and Date::Manip."
What steps do I take to check out these things? Sorry to sound so naive...
but there's a first time for everything!
Thanks again.
Clay Irving <clay@panix.com> wrote in message
news:slrn903826.c05.clay@panix3.panix.com...
> On Thu, 02 Nov 2000 16:44:23 GMT, Alan Mailer <clarityassoc@earthlink.net>
> wrote:
>
> >I'm very new to Perl and need to know how I would begin to go about
coding
> >for the following needs:
> >
> >1) Does DateA occur before DateB?
> >
> >2) What is the difference in days/weeks/months/years between DateA and
> >DateB?
> >
> >How would I begin to go about coding for these types of things in Perl?
> >Thanks in advance.
>
> Check out the Perl modules, Date::Calc and Date::Manip.
>
> --
> Clay Irving <clay@panix.com>
> Socialism is the equal distribution of poverty.
>
------------------------------
Date: Thu, 02 Nov 2000 20:37:14 GMT
From: "Alan Mailer" <clarityassoc@earthlink.net>
Subject: Re: Newbie: How to COMPARE DATES in Perl???
Message-Id: <_fkM5.10998$rl.925152@newsread2.prod.itd.earthlink.net>
Sorry Jeff and Clay... as so happens right after I've posted a question, I
solve it. I think I've found on my system what you both referred to as
Date::Manip. I think/hope I can take it from here. Thanks again.
Clay Irving <clay@panix.com> wrote in message
news:slrn903826.c05.clay@panix3.panix.com...
> On Thu, 02 Nov 2000 16:44:23 GMT, Alan Mailer <clarityassoc@earthlink.net>
> wrote:
>
> >I'm very new to Perl and need to know how I would begin to go about
coding
> >for the following needs:
> >
> >1) Does DateA occur before DateB?
> >
> >2) What is the difference in days/weeks/months/years between DateA and
> >DateB?
> >
> >How would I begin to go about coding for these types of things in Perl?
> >Thanks in advance.
>
> Check out the Perl modules, Date::Calc and Date::Manip.
>
> --
> Clay Irving <clay@panix.com>
> Socialism is the equal distribution of poverty.
>
------------------------------
Date: Thu, 02 Nov 2000 21:42:30 +0100
From: Adam <adamf@box43.gnet.pl>
Subject: Re: Newbie: How to COMPARE DATES in Perl???
Message-Id: <3A01D1B6.305D@box43.gnet.pl>
Alan Mailer wrote:
>
> I'm very new to Perl and need to know how I would begin to go about coding
> for the following needs:
>
> 1) Does DateA occur before DateB?
it is trivial if you use dates formated like this: "ccyy-mm-dd".
then you can use simply:
if ( $DateA op $DateB ) { ... };
where 'op' can be any string comparision operator.
> 2) What is the difference in days/weeks/months/years between DateA and
> DateB?
deal with this using Date::Calc.
--
HTH,
Adam.
------------------------------
Date: 2 Nov 2000 11:52:57 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: OOP and information hiding
Message-Id: <3a01b809@cs.colorado.edu>
In article <8tqkhf$1bf$1@bob.news.rcn.net>,
David Allen <s2mdalle@titan.vcu.edu> wrote:
>But
>what I'm interested in is *why* perl does it that
>way, in other words the language 'philosophy'
>behind that decision. I've been trying to find
>information on this, and all I've come up with is
>a bunch of ways to cheat and get around this limit
>and actually come to some sort of enforcement on
>variable access.
>From the Camel:
Perl lets you peer inside the object from outside the class
when you need to. But doing so breaks its I<encapsulation>,
the principle that all access to an object should be through
methods alone. Encapsulation decouples the published interface
(how an object should be used) from the implementation (how it
actually works). Perl does not have an explicit interface
facility apart from this unwritten contract between designer
and user. Both parties are expected to exercise common sense
and common decency: the user by relying only upon the documented
interface, the designer by not breaking that interface.
Perl doesn't force a particular style of programming on you,
and it doesn't have the obsession with privacy that some other
object-oriented languages do. Perl does have an obsession with
freedom, however, and one of the freedoms you have as a Perl
programmer is the right to select as much or as little privacy
as you like. In fact, Perl can have stronger privacy in its
classes and objects than C++. That is, Perl does not restrict
you from anything, and in particular it doesn't restrict you
from restricting yourself, if you're into that kind of thing.
The sections on "Private Methods" and "Closures as Objects"
later in this chapter demonstrate how you can increase your
dosage of discipline.
....
Note that we will be varying the implementation, not the
interface. If users of your class respect the encapsulation,
you'll be able to transparently swap out one implementation for
another without them noticing. (Family members in your inheritance
tree using your class for a subclass or superclass might not
be so forgiving, since they know you far better than strangers
do.) If your users have been peeking and poking into the private
affairs of your class, the inevitable disaster is their own
fault and none of your concern. All you can do is live up to
your end of the contract by maintaining the interface. Trying
to stop everyone else in the world from ever doing something
slightly wicked will take up all your time and energy--and in
the end, fail anyway.
....
So far, the techniques for managing instance data have offered
no mechanism for "protection" from external access. Anyone
outside the class can open up the object's black box and poke
about inside, if they don't mind voiding the warranty. Enforced
privacy tends to get in the way of people trying to get their
jobs done. Perl's philosophy is that it's better to encapsulate
one's data with a sign that says:
IN CASE OF FIRE
BREAK GLASS
You should respect such encapsulation when possible, but still
have easy access to the contents in an emergency situation,
like for debugging.
But if you want to enforce privacy, Perl isn't about to get in
your way. Perl offers low-level building-blocks you can use
to surround your class and its objects with an impenetrable
privacy shield--one stronger, in fact, than that found in many
popular object-oriented languages. Lexical scopes and the
lexical variables inside them are the key components here, and
closures play a pivotal role.
In the section on "Private Methods" we saw how a class can use
closures to implement methods that are invisible outside the
module file. Later we'll look at accessor methods that regulate
class data so private that not even the rest of the class has
unrestricted access. Those are still fairly traditional uses
of closures. The truly interesting approach is to use a closure
as the very object itself. The object's instance variables are
locked up inside a scope to which the object alone--that is,
the closure--has free access. This is a very strong form of
encapsulation; not only is it proof against external tampering,
even other methods in the same class must use the proper access
methods to get at the object's instance data.
--tom
------------------------------
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 4797
**************************************