[10399] in Perl-Users-Digest
Perl-Users Digest, Issue: 3992 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 16 13:01:37 1998
Date: Fri, 16 Oct 98 10:00:23 -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, 16 Oct 1998 Volume: 8 Number: 3992
Today's topics:
[ANNOUNCE] Perl modules Solaris::MapDev and Solaris::Ks <Alan.Burlison@uk.Sun.COM>
ANNOUNCE: Watchdog-0.05 paul@miraclefish.com
Announce: Win32-Const 0.011, values for all Win32 const (Brian D.)
ARGV inconsistent on subsequent runs <frank.brown@ci.seattle.wa.us>
Re: Batch-changing URL case in HTML pages with perl droby@copyright.com
Re: Camel Pub (was Re: Raleigh.pm has registered) <eashton@bbnplanet.com>
Counting URLs (bill davidsen)
Re: Counting URLs (Larry Rosler)
Re: ftp.pl perl ftp library droby@copyright.com
Re: getting all matches (Emmanuel Michon)
Re: grrrrr, why not while(<blah>) (Honza Pazdziora)
Re: grrrrr, why not while(<blah>) <merlyn@stonehenge.com>
Re: grrrrr, why not while(<blah>) <tchrist@mox.perl.com>
HELP!!!!cgi mystery problem <kammiek@mail.internetdirect.net>
Julian - Module to manipulate Calendar data using the J (Bert Tijhuis)
Re: MacPerl windows (Kevin Reid)
MHonArc v2.3.0 (Earl Hood)
Need help with this script w.wilson@mailexcite.com
Re: newbie: getting the wrong month out of localtime() scott@softbase.com
Re: newbie: getting the wrong month out of localtime() scott@softbase.com
Re: Perl FAQ - error found in "#How_do_I_get_a_file_s_t (Craig Berry)
Re: Reference to a sort function <aqumsieh@matrox.com>
Re: Reference to a sort function (Richard S. Holmes)
Re: Replacement for 'at'? scott@softbase.com
Slow Sort? (Steve Monson)
Re: Slow Sort? <eashton@bbnplanet.com>
Re: The space deletion woes... <eashton@bbnplanet.com>
Re: Trouble scheduling Perl scripts with WinNT AT comma scott@softbase.com
Using a variable in a grep search (The Cheeze Whiz)
Re: Using a variable in a grep search (David Alan Black)
Re: What are these? (Kevin Reid)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Oct 1998 16:24:01 GMT
From: Alan Burlison <Alan.Burlison@uk.Sun.COM>
Subject: [ANNOUNCE] Perl modules Solaris::MapDev and Solaris::Kstat]
Message-Id: <707rv1$j8s$1@news.neta.com>
What are they?
--------------
Solaris::Mapdev is a perl module that converts between instance names
and device names, e.g. sd0 to c0t0d0 and vice-versa.
Solaris::Kstat provides easy access to the Solaris Kstats interface,
representing the statistics as a set of nested hashes.
The following simple example shows how Solaris::Mapdev and
Solaris::Kstat might be used:
#!/usr/local/bin/perl -w
use strict;
use Solaris::MapDev qw(inst_to_dev);
use Solaris::Kstat;
my $ks = Solaris::Kstat->new();
my $ctd = inst_to_dev("sd0");
my $then = $ks->{sd}{0}{sd0}{crtime};
my $r_then = 0;
my $w_then = 0;
while(1)
{
my $now = $ks->{sd}{0}{sd0}{snaptime};
my $r_now = $ks->{sd}{0}{sd0}{reads};
my $w_now = $ks->{sd}{0}{sd0}{writes};
my $howlong = $now - $then;
printf("%s %.1f reads/sec %.1f writes/sec\n",
$ctd, ($r_now - $r_then) / $howlong,
($w_now - $w_then) / $howlong);
$r_then = $r_now;
$w_then = $w_now;
$then = $now;
sleep(5);
$ks->update();
}
Also included are the following example scripts:
dump_kstat
Dump the entire kstats structure to stdout.
mapdev
This will display the full list of mappings, and can be used as a filter
to commands such as sar.
iost+
An enhanced version of iostat, modelled closely on the SE toolkit script
'siostat.se'
What do I need to use them?
---------------------------
* Solaris 2.5.1 or above
* Perl 5.004_04 or above
* A C compiler
Where can I find them?
----------------------
$CPAN/authors/Alan_Burlison/Solaris-0_01_tar.gz
Alan Burlison
------------------------------
Date: 16 Oct 1998 16:23:03 GMT
From: paul@miraclefish.com
Subject: ANNOUNCE: Watchdog-0.05
Message-Id: <707rt7$j8e$1@news.neta.com>
Watchdog::Process, Watchdog::HTTP and Watchdog::Mysql are classes for
monitoring whether a process, http server or mysql server respectively
is functioning.
The module also includes a number of 'monitor' scripts
which can be used with the system monitoring package 'Mon'
(http://consult.ml.org/~trockij/mon). These scripts make use of the
Watchdog classes and SNMP.
bin/mysql.monitor (Watchdog::Mysql)
bin/partition.monitor (SNMP)
bin/swap.monitor (SNMP)
Paul Sharpe <paul@miraclefish.com>
Release 0.05
- Added OSF1 support to swap.ext
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 16 Oct 1998 16:23:27 GMT
From: bi8fra@my-dejanews.com (Brian D.)
Subject: Announce: Win32-Const 0.011, values for all Win32 constants
Message-Id: <707rtv$j8l$1@news.neta.com>
Win32::Const module
contains all the Win32 constants, such as WM_CLOSE, SW_SHOWMAXIMIZED, etc
Available at:
CPAN/modules/by-module/Win32API/
SYNOPSIS:
#
# Access value of WM_CLOSE without importing it
#
use Win32API::Const;
print "WM_CLOSE = ", Win32API::Const::WM_CLOSE(), "\n";
#
# Import and access values of WM_CLOSE and HELP_CONTENTS
#
use Win32API::Const qw(WM_CLOSE HELP_CONTENTS);
print "WM_CLOSE = ", WM_CLOSE(), "\n";
print "HELP_CONTENTS = ", HELP_CONTENTS(), "\n";
#
# Import WM_CLOSE, along with all constants whose names start
# with WS_ or SE_
#
use Win32API::Const qw(:WS_ WM_CLOSE :SE_);
print "WM_CLOSE = ", WM_CLOSE(), "\n";
print "WS_MAXIMIZE = ", WS_MAXIMIZE(), "\n";
print "WS_MINIMIZE = ", WS_MINIMIZE(), "\n";
print "WS_OVERLAPPED = ", WS_OVERLAPPED(), "\n";
print "SE_SHUTDOWN_NAME = ", SE_SHUTDOWN_NAME(), "\n";
I appreciate any feedback, suggestions, etc.
thanks,
brian
------------------------------
Date: Fri, 16 Oct 1998 16:23:23 GMT
From: "frank brown" <frank.brown@ci.seattle.wa.us>
Subject: ARGV inconsistent on subsequent runs
Message-Id: <%pKV1.331$Sp1.3548@news.eli.net>
Please excuse this novice question, if it's in the docs just point me at the
right one...
I'm experiencing inconsistent behavior in the value of $ARGV when there are
no command-line args. The first time it's run $ARGV == -1 which seems
correct. However on all subsequent runs AFTER running the same program WITH
command-line arg(s), running the program with no command-line args sets
$ARGV to 0, and $ARGV[0] is set to the .pl file which the perl interpreter
is running!
For instance the following program (testargs.pl):
print "ARGV == $#ARGV\n";
foreach $i (0..$#ARGV) {
print "$i: $ARGV[$i]\n";
}
Subsequent runs produce the following output:
D:\reg>testargs.pl
ARGV == -1 # correct
D:\reg>testargs.pl
ARGV == -1 # still correct
D:\reg>testargs.pl foo
ARGV == 0 # correct
0: foo
D:\reg>testargs.pl
ARGV == 0 # what's this?
0: D:\reg\testargs.pl
Is there some global perl variable which controls this strange behavior?
What's going on here? I'm running perl 5.005 built for MSWin32-x86-object
(the ActiveState build from Win32 Resource Kit) on NT 4.0/SP3.
-Frank Brown
frog at halcyon dot com
------------------------------
Date: Fri, 16 Oct 1998 16:00:03 GMT
From: droby@copyright.com
Subject: Re: Batch-changing URL case in HTML pages with perl
Message-Id: <707qi3$s6l$1@nnrp1.dejanews.com>
In article <362539B7.44514B92@uninetwork.com>,
Mark Cain <mark@uninetwork.com> wrote:
> case sensitive?
>
> following this link:
>
> HttP://Www.NEtscAPe.coM/
>
> Not trying to pick on you. Just wondering what you meant by "URLs are case
sensitive" as the
> above link is a URL and it is not case sensitive on my browser of Netscape.
Communicator 4.06
HttP://loCALhost/~uSerNaME might be... Certainly is on my machine. This too
is a URL.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 16 Oct 1998 16:19:14 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Camel Pub (was Re: Raleigh.pm has registered)
Message-Id: <36276F7E.899D4785@bbnplanet.com>
Leon Brocard wrote:
> Mmmm. Camel burgers. If anyone *does* start up this bar and start
> experimenting, please report how the following tastes...
A geek pub around these parts would be a good thing (tm). I'm going to
forward this recipe to Martha and see if she can test and scale it. :)
e.
After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia. - U. Eco -
------------------------------
Date: 16 Oct 1998 15:27:49 GMT
From: davidsen@tmr.com (bill davidsen)
Subject: Counting URLs
Message-Id: <707oll$12qu$1@newssvr03-int.news.prodigy.com>
I want to count URLs in a (long) string. I thought that the easy way
would be to use the split() function and look at the return count, but
that doesn't quite do what I want. I'm doing:
$N_URL = split(m#\W(http|news|mail|ftp)://\S*#o);
However, the () pair in the match string generates an item in the @_
array, and a count. I'm currently correcting for this by:
$N_URL = int($N_URL / 2);
But the whole process is slow and ugly. Is there a better way? And since
someone else will maintain this later, a better way which is not totally
obscure? Perl is nice, but it does lend itself to write-only code ;-)
--
bill davidsen <davidsen@tmr.com> CTO, TMR Associates, Inc
Never underestimate the power of stupid people in large groups
------------------------------
Date: Fri, 16 Oct 1998 09:11:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Counting URLs
Message-Id: <MPG.1091101ec1d36928989819@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <707oll$12qu$1@newssvr03-int.news.prodigy.com> on 16 Oct 1998
15:27:49 GMT, bill davidsen <davidsen@tmr.com> says...
> I want to count URLs in a (long) string. I thought that the easy way
> would be to use the split() function and look at the return count, but
> that doesn't quite do what I want. I'm doing:
> $N_URL = split(m#\W(http|news|mail|ftp)://\S*#o);
>
> However, the () pair in the match string generates an item in the @_
> array, and a count. I'm currently correcting for this by:
> $N_URL = int($N_URL / 2);
This is because the parentheses in your 'split' are capturing the match
and incorporating it into the list of results. Change it to:
$N_URL = split(m#\W(?:http|news|mail|ftp)://\S*#o);
> But the whole process is slow and ugly. Is there a better way? And since
> someone else will maintain this later, a better way which is not totally
> obscure? Perl is nice, but it does lend itself to write-only code ;-)
Instead of splitting into a list and returning the number of elements,
you could simply return the number of matches directly. This will
surely be faster (but I haven't benchmarked it). Also, the '\S*' at the
end doesn't do anything, and the 'o' is superfluous because there are no
interpolations into the regex.
$N_URL = m#\W(?:http|news|mail|ftp)://#g;
You might try using HTML::Parser, but I have no experience with it and
don't see why it should be faster than your naive approach (naive
because it might find all kind of false matches in HTML comments and
ALT= string, but I doubt that you care).
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 16 Oct 1998 15:52:28 GMT
From: droby@copyright.com
Subject: Re: ftp.pl perl ftp library
Message-Id: <707q3t$rff$1@nnrp1.dejanews.com>
In article <Pine.GSO.4.02A.9810141612030.1979-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
> On Thu, 15 Oct 1998, Arran Price wrote:
>
> > I cant find any docs on how to use it, the script itself dosent say
> > howto...
>
> Software without docs is useless. Throw it out and get a
> properly-documented module from CPAN. Hope this helps!
>
I wonder why this particular useless software is still distributed with Perl?
Certainly getting and using the CPAN module is a better idea. This ftp.pl
thing was written before Perl4, I think.
It's not well-documented internally, and doesn't work on my system, as I
haven't run h2ph on something it wants (or rather something that chat2.pl
wants). It isn't too hard to guess an appropriate sequence of function calls
based on the function names in ftp.pl, but seeing those ftp'close style names
must be confusing to someone who wasn't doing Perl yet before the current
standard notation.
And perl -w yields lots of interesting stuff...
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 16 Oct 1998 15:35:08 GMT
From: michon@news.enst.fr (Emmanuel Michon)
Subject: Re: getting all matches
Message-Id: <707p3c$qi1$1@enst.enst.fr>
Jonathan Feinberg (jdf@pobox.com) wrote:
: > regexp and when the regexp engine finds one match, it stops.
: This is a weird oversimplification. Have you read the documentation
: for Perl's regex support? You'll find it in perlre and perlop, not to
: mention perlfaq6.
I found indeed this kind of thing:
$_ = "ABCBD";
while (/(B.*)/g) {
print("$1\n");
}
which returns one match: BCBD, and I would like to get
B, BC, BCB, BCBD, B, BD, not just the first-then-longest rule.
: That depends on what you mean.
yes, the question wasn't very clear.
any idea then?
--
Manu (http://www.enst.fr/~michon)
------------------------------
Date: Fri, 16 Oct 1998 15:13:19 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: grrrrr, why not while(<blah>)
Message-Id: <slrn72eokf.enn.adelton@aisa.fi.muni.cz>
On Fri, 16 Oct 1998 15:59:47 +0100, Daniel Vesma <daniel.vesma@thewebtree.com> wrote:
> As far as I can tell, the following code should work. It doesn't. The
> while() doesn't start.
[...]
The code shouldn't work. It's not written properly.
> #!/usr/bin/perl
-w
use strict;
> use CGI qw(param);
>
> print "Content-type: text/html\n\n";
[...]
> open(INDB, "<$file");
or die "Error reading $file: $!\n";
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Fri, 16 Oct 1998 16:15:18 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: grrrrr, why not while(<blah>)
Message-Id: <8chfx45vqn.fsf@gadget.cscaper.com>
>>>>> "Daniel" == Daniel Vesma <daniel.vesma@thewebtree.com> writes:
Daniel> ($tempONE, $tempTWO, $tempTHREE) = split(/^/, $_);
Hmm. What do you expect this to do? There's only one beginning of
string, so splitting there won't ever really return many elements.
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 16 Oct 1998 16:36:41 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: grrrrr, why not while(<blah>)
Message-Id: <707smp$ohv$1@csnews.cs.colorado.edu>
In comp.lang.perl.misc, Randal Schwartz <merlyn@stonehenge.com> writes:
:>>>>> "Daniel" == Daniel Vesma <daniel.vesma@thewebtree.com> writes:
:
:Daniel> ($tempONE, $tempTWO, $tempTHREE) = split(/^/, $_);
:
:Hmm. What do you expect this to do? There's only one beginning of
:string, so splitting there won't ever really return many elements.
Strike two. Next time, please take the time to check the facts
before posting misplaced opinions about correctness. It scares
people away to be told they're wrong when they're not.
$_ = "line1\nline2\nline3\n";
($t1, $t2, $t3) = split(/^/, $_);
print "one is $t1\n";
print "two is $t2\n";
print "three is $t3\n";
produces:
one is line1
two is line2
three is line3
Strike two.
--tom
--
I could take this home, Marilyn. This is something teenage boys might
find of interest. --Vice President Dan Quayle, when purchasing a South
African Indian Doll that, when lifted, displays an erection.
------------------------------
Date: Fri, 16 Oct 1998 09:25:24 -0700
From: Kammie Kayl <kammiek@mail.internetdirect.net>
Subject: HELP!!!!cgi mystery problem
Message-Id: <36277373.31DDD382@mail.internetdirect.net>
Hi Folks,
I am having a cgi problem I have never encountered before.
There is no output of the answers on the email. The email gets sent, and
the labels appear, but none of the text I write in, or radio buttons I
choose are showing up.
The permissions are fine, no errors are even being reported when I tail
the errors log
Maybe it's a small small thing I am overlooking, but I am at my wits end
now.
Please advise.
K
------------------------------
Date: 16 Oct 1998 16:25:32 GMT
From: B.Tijhuis@inter.nl.net (Bert Tijhuis)
Subject: Julian - Module to manipulate Calendar data using the Julian Date
Message-Id: <707s1s$jbb$1@news.neta.com>
This is first release of
Julian.pm
This module based on the Calendar FAQ, v. 1.7. from Claus Tondering. It
provides all kind of date manipulations including an overload of a subtraction
between two dates.
http://www.inter.nl.net/users/B.Tijhuis/perl/julian.pm 22k
Documentation:
http://www.inter.nl.net/users/B.Tijhuis/perl/julian.html (created by the
pod2html tool)
------------------------------
Date: Fri, 16 Oct 1998 12:29:38 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: MacPerl windows
Message-Id: <1dgxola.kag0kssj8jd8N@slip-32-100-246-237.ny.us.ibm.net>
K. Finstad <kfinstad@unm.edu> wrote:
> Does anyone know how to clear a window (e.g., STDOUT) of text?
> I have a very text-intensive project that fills up the window, and on
> slower machines (Classic IIs), the output starts jumping and flickering. I
> can't find any documentation anywhere (books or pods) that describe how to
> do this. One thing I tried is redirecting STDOUT to a new window, which
> works, but then the getc() command I'm using doesn't seem to work with any
> STDIN other than Dev:Console (the MacPerl window), even after a redirect.
MacPerl::DoAppleScript 'close window "MacPerl"';
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: 16 Oct 1998 16:25:54 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: MHonArc v2.3.0
Message-Id: <707s2i$jbk$1@news.neta.com>
MHonArc v2.3.0 is now available for download. MHonArc is a Perl
mail-to-HTML converter. MHonArc provides HTML mail archiving with
index, mail thread linking, etc; plus other capabilities including
support for MIME and powerful user customization features. MHonArc
should work on practically any system with Perl 5 installed. MHonArc
is written in "pure" Perl, so no compilation is needed to use it.
Complete information about MHonArc can be obtained at
<URL:http://www.oac.uci.edu/indiv/ehood/mhonarc.html>, including
mailing list and downloading information. A copy the v2.3.0
distribution has been uploaded to CPAN under
<URL:http://www.perl.com/CPAN/authors/id/EHOOD/> and should be mirrored
soon to a CPAN site near you.
Change list from v2.2 can be obtained at
<URL:http://www.oac.uci.edu/indiv/ehood/MHonArc/CHANGES>.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Fri, 16 Oct 1998 16:08:34 GMT
From: w.wilson@mailexcite.com
Subject: Need help with this script
Message-Id: <707r22$svo$1@nnrp1.dejanews.com>
I'm writing this fairly simple script to get some input, open and lock a file
and write the input to the file. The major question I have is, is this a
decent way to do this (see script below)? Any guidance as to the best way to
accomplish this would be appreciated. Also, what am I doing wrong with my
array that it won't print to the file, and how do I know if the file is
locking? My flock implementation is stolen from the man pages, I really
couldn't find a decent example of how to use it...so I'm a little lost.
Thanks for the help.
P.S. sorry if this is _really_ hosed, I'm very new to this
Script;#!/usr/local/bin/perl -w
$LOCK_EX = 2;
$LOCK_UN = 8;
print "Please enter your login name: ";
chomp($name = <STDIN>);
print "\nPlease enter some info about the change\n";
print "End input by typing ^D: ";
while(<STDIN>) {
until(\cD) {
@comment_array = <STDIN>;
}
}
open(LOG, ">>/tmp/blah") or die "Couldn't open file: $!";
&lock_file;
print LOG ('$' x 80), "\n";
print LOG "$name ", `date`;
print LOG ('$' x 80), "\n";
print LOG @comment_array;
&unlock_file;
close(LOG) or die "Can't close the file: $!";
# Subs
sub lock_file {
flock LOG, $LOCK_EX;
seek LOG, 0, 2;
}
sub unlock_file {
flock LOG, $LOCK_UN;
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 16 Oct 1998 16:22:04 GMT
From: scott@softbase.com
Subject: Re: newbie: getting the wrong month out of localtime()
Message-Id: <362772ac.0@news.new-era.net>
Marcel Duivesteijn (M.Duivesteijn@cao-horeca.nl) wrote:
> To my surprise I got the wrong month. I got month 9 instead of 10.
SURPRISE! Welcome to be brain-damaged world of UNIX and C time
functions. The month is 0..11 instead of 1..12, which has to be one of
the all-time boneheaded decisions in the history of computing. It
started in UNIX, and the UNIX time libraries got codified as-is to
become the ANSI C libraries. Perl uses these as-is. The brain damage
is here to stay!
Scott
------------------------------
Date: 16 Oct 1998 16:25:08 GMT
From: scott@softbase.com
Subject: Re: newbie: getting the wrong month out of localtime()
Message-Id: <36277364.0@news.new-era.net>
Tony Curtis (Tony.Curtis+usenet@vcpc.univie.ac.at) wrote:
> The month field goes from 0 .. 11 (presumably for the
> historic reason that C subscripts start at 0).
I wonder if this is the reason. The struct tm is not consistent
if it is -- days of the month is 1..31, not 0..30. Day of the
week is utterly, hopelessly confused. It goes from 0..7 on
most of the UNIX systems I have access to, and no two seem to
agree on it. So we have an 8 day week.
Scott
------------------------------
Date: 16 Oct 1998 16:39:23 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl FAQ - error found in "#How_do_I_get_a_file_s_timestamp_"
Message-Id: <707srr$855$1@marina.cinenet.net>
Daniel Grisinger (dgris@perrin.dimensional.com) wrote:
: James Ludlow <ludlow@us.ibm.com> writes:
: > Locally, I'm using version 5.004_02, and the error is in my copy of the
: > FAQ also.
:
: So create a patch and send it to Tom. You obviously know the
: solution, fix it.
:
: dgris
: - Amazed at the fact that so many people use free software
: but still don't get it.
Not everyone knows how to do that. A pointer to doc on the topic would be
more helpful than this unwarranted slam. (I'd provide said pointer, were
I not among those who don't know.)
---------------------------------------------------------------------
| 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, 16 Oct 1998 11:21:11 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Reference to a sort function
Message-Id: <Pine.SUN.3.96.981016111326.28952A-100000@tigre.matrox.com>
On 16 Oct 1998, Richard S. Holmes wrote:
> How come this doesn't work:
>
> $sorttype = \&backwards;
>
> print sort &$sorttype ( Camel, Aardvark, Gnu, Zebra ), "\n";
>
> sub backwards {
> $b cmp $a;
> }
>
> but this does:
>
> $sorttype = \&backwards;
>
> print sort somehow ( Camel, Aardvark, Gnu, Zebra ), "\n";
>
> sub somehow {
> &$sorttype;
> }
>
> sub backwards {
> $b cmp $a;
> }
>
> ... ?
This is simply the way sort works. If a sorting sub is specified it has to
be either a subroutine name (as in your second example above), or a scalar
variable that provides the name of the subroutine to use, or an anonymous
in-line subroutine.
If you read the Perl documentation that is bundled with your copy of Perl,
you would've found:
=item sort SUBNAME LIST
=item sort BLOCK LIST
=item sort LIST
Sorts the LIST and returns the sorted list value. If SUBNAME or BLOCK
is omitted, sorts in standard string comparison order. If SUBNAME is
specified, it gives the name of a subroutine that returns an integer
less than, equal to, or greater than 0, depending on how the elements
of the array are to be ordered. (The C<E<lt>=E<gt>> and C<cmp>
operators are extremely useful in such routines.) SUBNAME may be a
scalar variable name, in which case the value provides the name of the
subroutine to use. In place of a SUBNAME, you can provide a BLOCK as
an anonymous, in-line sort subroutine.
Hope this helps,
--
Ala Qumsieh email: aqumsieh@matrox.com
ASIC Design Engineer phone: (514) 822-6000 x7581
Matrox Graphics Inc. (old) webpage :
Montreal, Quebec http://www.cim.mcgill.ca/~qumsieh
------------------------------
Date: 16 Oct 1998 12:58:15 -0400
From: rsholmes@rodan.syr.edu (Richard S. Holmes)
Subject: Re: Reference to a sort function
Message-Id: <xzc3e8obg0o.fsf@rodan.syr.edu>
In article <362768C6.FB0D27BE@vbe.com> Mark Kahn <mkahn@vbe.com> writes:
>Try this:
>
>print sort {&$sorttype} ( Camel, Aardvark, Gnu, Zebra ), "\n";
That works -- thanks! But...
In article <83d87sshh6.fsf@vcpc.univie.ac.at> Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> writes:
> $sorttype = 'backwards';
> print sort $sorttype qw( Camel Aardvark Gnu Zebra ), "\n";
... that, by my benchmark, works almost twice as fast, and only
slightly slower than 'sort backwards ...'..
--
- Rich Holmes
Syracuse, NY / We have more important things to do...
Newport News, VA Censure and move on! Sign the petition at
rsholmes@earthling.net <http://www.moveon.org>
------------------------------
Date: 16 Oct 1998 16:18:46 GMT
From: scott@softbase.com
Subject: Re: Replacement for 'at'?
Message-Id: <362771e6.0@news.new-era.net>
Art Cohen (upsetter@shore.net) wrote:
> The obvious alternative, I guess, would be to fork off a process that
> just waits until a certain time and then does what I want (sleeping in
> 30-minute chunks or some such), but I don't know if there are any
> unforseen pitfalls to this approach.
> Any suggestions? TIA.
I have written a cron clone in Perl. www.skwc.com/essent -- scroll down
until you get to the free software section. What you could do is modify
this code to reread all the crontab files in a directory every X
seconds, and then create crontab files based on your PID or the time or
something. Leave cron running in the background.
Scott
------------------------------
Date: 16 Oct 1998 10:44:38 -0500
From: monson@tri.sbc.com (Steve Monson)
Subject: Slow Sort?
Message-Id: <707pl6$s40@euphony.tri.sbc.com>
In the course of doing a little statistical analysis, I found a need
to sort a list I'd built up. Just a straight numeric sort, in
descending order, which I did as
@sl = sort {$b <=> $a} @sl;
All well and good. As it happened, the array contained about 102,000
elements. The execution time was 40, that's right, 40 *minutes*, that's
right, minutes, not seconds.
Now, the program was running on a SparcStation 20, with 64MB of RAM,
and when I watched the program using "top" it indicated that about
28 MB of ram was being used, with 22MB resident. So, I expect that the
sort was done in memory.
In fact, by checkpointing with time() before and after the sort, I
got the stats (in seconds):
64 Compute average sentence length (one pass over the data)
2841 Sort sentence lengths
102,000 elements is not trivial, but it's not such a huge number, either.
Now, when I changed my code to use Unix's system sort on a file:
open(OUT,">/tmp/sl"); foreach (@sl) {print OUT $_,"\n";} close(OUT);
open(IN,"sort -rn /tmp/sl|"); @sl = <IN>; close(IN); chop @sl;
I got the following statistics, which seem more expected:
64 Compute average sentence length
5 Sort sentence lengths
That is, Unix sorted in 5 seconds what took perl 40 minutes or more
to sort. I've been happy with perl till now. Did I hit some kind of
performance threshold?
Flash: I just wrote a small 3-line perl program to fill a 102,000-
element list with random numbers, and then sort it. It did it in 15
seconds. So, I guess there's some memory-management problem with
perl/unix interaction at work here.
Anyone else run into such a symptom?
Steve Monson
--
I am a demolitions expert. If you see me running, try and keep up.
------------------------------
Date: Fri, 16 Oct 1998 16:33:12 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Slow Sort?
Message-Id: <362772C5.75D35172@bbnplanet.com>
Steve Monson wrote:
> All well and good. As it happened, the array contained about 102,000
> elements. The execution time was 40, that's right, 40 *minutes*, that's
> right, minutes, not seconds.
40 MINUTES?! What else is going on in the program? Maybe you have a loop
of some sort. I can't believe that a straight numeric sort takes that
long without some sort of error in the code.
> Now, the program was running on a SparcStation 20, with 64MB of RAM,
> and when I watched the program using "top" it indicated that about
> 28 MB of ram was being used, with 22MB resident. So, I expect that the
> sort was done in memory.
Slowlaris by any other name. :)
> Flash: I just wrote a small 3-line perl program to fill a 102,000-
> element list with random numbers, and then sort it. It did it in 15
> seconds. So, I guess there's some memory-management problem with
> perl/unix interaction at work here.
Hmm....post the original script...I'll bet there is a problem in there
somewhere that makes the difference between 5 seconds and 40 minutes.
Yes, there are memory issues with Perl but not that drastic that I've
seen without there being user error.
e.
After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia. - U. Eco -
------------------------------
Date: Fri, 16 Oct 1998 16:14:04 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: The space deletion woes...
Message-Id: <36276E47.5F8F6D8E@bbnplanet.com>
Russ Allbery wrote:
> It's not a question of it not working. It's a question of it being
> completely and absolutely equivalent to =~ s/\s+//g except that it's
> slower.
Right, and the other Larry and Uri and I had great fun with that should
you read the entire thread. :)
e.
After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia. - U. Eco -
------------------------------
Date: 16 Oct 1998 16:19:56 GMT
From: scott@softbase.com
Subject: Re: Trouble scheduling Perl scripts with WinNT AT command
Message-Id: <3627722c.0@news.new-era.net>
Georg Buehler (gbuehler@NOSPAMmed.unc.edu) wrote:
> I've read in the FAQs that folks use the "at" command in WinNT to schedule
> events.
UGH! Don't use that piece of junk. I've written a cron clone in perl
that works great on Windows systems. Go to www.skwc.com/essent
and scroll down until you get to the free software part.
Scott
------------------------------
Date: Fri, 16 Oct 1998 09:38:01 -0700
From: cheeze-whiz@usa.net (The Cheeze Whiz)
Subject: Using a variable in a grep search
Message-Id: <cheeze-whiz-1610980938010001@grovey.usc.edu>
I'm trying to write a script that performs a grep search of a file and
allows users to specify the search term. The problem I'm facing is that
'$' is a regular expression pattern and escaping the $ looks for '$'
(rather than parsing the perl variable).
For example:
print "Enter the search term:";
$input = <STDIN>;
open(MYFILE,"myfile");
@myfile = <MYFILE>;
close MYFILE;
-> @results = grep (/$input/, @myfile);
print "$results[0]\n";
What's the trick?
Thanks,
Michael
------------------------------
Date: 16 Oct 1998 12:54:16 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: Using a variable in a grep search
Message-Id: <707tno$s0t$1@pilot.njin.net>
Hello -
cheeze-whiz@usa.net (The Cheeze Whiz) writes:
>I'm trying to write a script that performs a grep search of a file and
>allows users to specify the search term. The problem I'm facing is that
>'$' is a regular expression pattern and escaping the $ looks for '$'
>(rather than parsing the perl variable).
>For example:
> print "Enter the search term:";
> $input = <STDIN>;
> open(MYFILE,"myfile");
> @myfile = <MYFILE>;
> close MYFILE;
>-> @results = grep (/$input/, @myfile);
> print "$results[0]\n";
I think the problem you're actually facing is that you don't chomp()
$input.
$input will be correctly expanded in /$input/ - the $ is not ambiguous
(because in that position, it couldn't be an end-of-string assertion).
David Black
dblack@pilot.njin.net
------------------------------
Date: Fri, 16 Oct 1998 12:29:40 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: What are these?
Message-Id: <1dgzqqw.eljl0d19wuy4gN@slip-32-100-246-237.ny.us.ibm.net>
<dave@mag-sol.com> wrote:
> shift - returns the first item of a list and removes it from the list.
> e.g. (following on from the last example)
> my $thing = shift $list;
> puts 'This' in $thing and leaves @list with ('is', 'a', 'list').
s/\$list/\@list/;
--
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 3992
**************************************