[10801] in Perl-Users-Digest
Perl-Users Digest, Issue: 4402 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 11 01:07:21 1998
Date: Thu, 10 Dec 98 22:00:18 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 10 Dec 1998 Volume: 8 Number: 4402
Today's topics:
Re: Authentification program? <peterw@clark.net>
Re: Can you use multiple formats? <rick.delaney@home.com>
Re: Creating super-simple DBM files <rick.delaney@home.com>
Diagnostic Scrolls by gemhound@gemhound.com
Re: help on error message (Larry Rosler)
Re: how to make directory tree?? (Tad McClellan)
Re: How to read a binary file in Perl? How to install m (Ronald J Kimball)
Re: How to use prune in File::Find <rmlynch@best.com>
Re: Info source for Perl for Win32 (Martin Vorlaender)
Learning Perl, 2nd edition, exercise 7.1b <nospam@nospam.com>
Re: Left and right halves of s/// parsed differently? (Ronald J Kimball)
Re: Pattern matching and name parsing (Ronald J Kimball)
Re: Perl tip needed: High CPU Usage (Larry Rosler)
Re: Perl tip needed: High CPU Usage wyndo@cxo.com
Precision(?) of Perl <kou@ssa-de.sel.sony.com>
Re: Regular Expression help (Ronald J Kimball)
Re: Sorting problem: Is there a better way? (Larry Rosler)
Re: Sorting problem: Is there a better way? (Andre L.)
Re: Sorting problem: Is there a better way? (Tad McClellan)
specify password in a ftp URL? <kin@symmetrycomm.com>
Re: specify password in a ftp URL? <tupshin@tupshin.com>
Re: unlinking files from Perl CGI under Apache (Tad McClellan)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 10 Dec 1998 23:52:04 -0500
From: Peter W <peterw@clark.net>
Subject: Re: Authentification program?
Message-Id: <3670A4F4.FE8E7F52@clark.net>
Kerry J. Cox wrote:
> For example, Persons A, B and C wanted to come to my page where I was
> placing information about their respective companies. Since I don't
> want anyone else except for A, B and C to see the info, I have created a
> a login box using apache. But I also don't want A to go to B's site or
> C to see A's site. So when A logs in, he sees
> http://this.domain.com/testsite.html and when B logs in he sees
> http://this.domain.com/anothersite.html
> Each of these sites will also be drawing information from a database and
> posting it dynamically also, but that's another story.
> What I am asking therefore, is there a Perl program out there that will
> run on Linux or Solaris that will create dynamic links to separate pages
> based upon who is logging in?
(1) If the content is dynamically created, build the security into the application?
(2) Redirects are nice, but since URL's can be shared/guessed, I think you need to come up with something like a naming convention, e.g. this.domain.com/secure/a/foo.html and make sure only group A members can access such URL's. Given the way Apache deals with redirects internally, you might be able to hide the "real" URL, e.g. when user in group A logs in, check the URI and if necessary, change or add the /secure/a path info. The end user would not see the new URL, and could give it to a group C member who would be given a /secure/c page instead. Possibly.
Anyway, option two means working with custom Apache modules, which maybe you could do with whatever that write-modules-in-Perl feature is, though you're better off in the long run converting to C.
-Peter
Followups to comp.infosystems.www.servers.unix, please.
------------------------------
Date: Fri, 11 Dec 1998 03:36:49 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Can you use multiple formats?
Message-Id: <3670950F.FB27E7F9@home.com>
[posted & mailed]
Forrest Reynolds wrote:
>
> Here's the code I have so far:
> select(LOGREPORT);
> $~ = "SUBTOTAL";
> write SUBTOTAL;
^^^^^^^^
write LOGREPORT;
or just
write;
since you selected it. I'm assuming there's an open file attached to
LOGREPORT.
When you set $~, you set it for the currently selected filehandle. In
this case, your writes will be to LOGREPORT, but they will be formatted
like SUBTOTAL.
perldoc perlform
perldoc perlvar
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Fri, 11 Dec 1998 04:05:15 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Creating super-simple DBM files
Message-Id: <36709BB9.6A97E291@home.com>
[posted & mailed]
"Rev. Waldo of Flatbush" wrote:
>
> Hi, a newbie here, and what I want to do sounds easy enough to me but
> apparently isn't.
>
> I want to create a simple flat database with a numeric index, and all
> the lookups will be based on that index, much like this:
>
> Index Name Pet Car
> 1 Bob Cat Ford <--(The real list is a lot bigger
> 2 Chad Dog Lexus than this - 1500+ records)
> 3 Kim Bird Pontiac
> 4 Susan Cat Honda
> etc.
>
> What's the easiest way to create a DBM file based on this? If I had a
> list like this in a comma- or tab-delimited text file, is there a fast
> way to convert it?
>
#!/usr/bin/perl -w
use strict;
use AnyDBM_File;
use Fcntl;
my %hash;
tie %hash, 'AnyDBM_File', 'testdbm', O_RDWR|O_CREAT, 0644
or die "Can't tie hash to testdbm: $!\n";
while (<DATA>) {
chomp;
my ($index, $data) = split ' ', $_, 2;
$hash{$index} = $data;
}
untie %hash;
__END__
1 Bob Cat Ford
2 Chad Dog Lexus
3 Kim Bird Pontiac
4 Susan Cat Honda
You can easily modify this for tab delimited data.
perldoc -f split
You will also want to use split to separate the dbm record into fields
(name, pet, car) when you retrieve it.
> Also I'd be grateful for any pointers to resources explaining DBM
> files in better detail.
You might try 'man dbm'.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Fri, 11 Dec 1998 03:37:41 GMT
From: gemhound@gemhound.com
Subject: Diagnostic Scrolls by
Message-Id: <74q425$leh$1@nnrp1.dejanews.com>
I decided to use the statement "use diagnostics;" but now long diagostic
messages scroll right by in the DOS screen (I'm using win32 perl by
Activestate), so that I only see the bottom part of the message. I tried
redirecting by using "perl myprogram.pl > diagfile" but for some reason
redirection doesn't work -- they still scroll by on the screen too quickly to
see.
Is there any way I can see the whole message?
And yes, I know I should get away from evercrashing Windows and DOS, if only
because Msoft keeps breaking the Java and Javascripts standards on purpose,
making webmastering much harder; but I'm already learning webmastering, Perl,
CGI and Photoshop and running a major site to boot. Maybe I'll have time to
get Bill off my back next year, by which time Linux should have a lot of my
favorite apps.
Jim Mooney
And if anyone wants to see a consumer site that is incredibly content-rich but
graphically awful, you can stop by http://www.gemhound.com (I'm "Learning"
photoshop and Design Principles -- but the site grew of its own accord and is
hellish to retrofit. That's one big reason for learning Perl -- to automate
everything, and also have a consistent look while staying away from Style
Sheets, which are something else Msoft and Netscape refuse to standardize)
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 10 Dec 1998 19:10:46 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: help on error message
Message-Id: <MPG.10da2d0fddd8a41198994e@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <Pine.HPP.3.96.981210141339.4380B-100000@amy1.Stanford.EDU>
on Thu, 10 Dec 1998 14:18:17 -0800, Guoying Liu
<wqi@leland.Stanford.EDU> says...
> Could anyone please give me some tips on why sometimes I got error message
> saying "use of uninitialized value"? We don't have to define any variable
> in Perl, right?
Unless you use 'use strict;' (and you *should* use it for any but the
most trivial programs), you don't need to *declare* any variable.
But the warning you report (caused by the '-w' flag that you *are* using
-- good going!) means that you are trying to do some sort of computation
using a variable that has not been *defined* -- i.e., that has not been
given a value. This is probably not a good idea.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 10 Dec 1998 22:42:16 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how to make directory tree??
Message-Id: <8r7q47.tc3.ln@magna.metronet.com>
Clay Irving (clay@panix.com) wrote:
: In <366f2350.0@nemo.idirect.com> "Gorbatchev Dmitri" <dimag@idirect.com> writes:
: >i'm trying to make a directory tree, but i can't. Next code show each
: >directory, but don't show path to directoryes :( how to make a directory
: >tree??? plz, tell me somebody!!
: This is a program I ran across awhile back (I don't know the author of
: the program):
: #!/usr/local/bin/perl
no -w ?
;-)
: # skip files until directory found
: $skip_entry = 1;
: while ($skip_entry) {
: $current_entry = readdir($dirh);
: if (! defined ($current_entry)) {$skip_entry = 0} # End Of Dir
: elsif ( ($current_entry ne '.') && ($current_entry ne '..') && (-d $tree
There's something missing right around here somewhere? (syntax error)
: }
Here's one I saw on the newsgroups once.
Doesn't use perl though...
find . -print | sed -e 's,[^/]*/\([^/]*\)$,`--\1,' -e 's,[^/]*/,| ,g'
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 10 Dec 1998 23:58:59 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: How to read a binary file in Perl? How to install mod_perl?
Message-Id: <1djuhii.bf6pwq1s1uaz4N@bay1-511.quincy.ziplink.net>
Bart Lateur <bart.lateur@skynet.be> wrote:
> I think it was intended as "unambiguusly".
I'm not sure what you mean by that...
;-)
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 10 Dec 1998 19:09:24 -0800
From: Robert Lynch <rmlynch@best.com>
Subject: Re: How to use prune in File::Find
Message-Id: <36708CE4.5AC01AE@best.com>
r_ramirez@my-dejanews.com wrote:
>
> I am having trouble understanding the subtlety of using
> prune with File::Find. I've read what I could find in
> PerlFAQ, perldoc, the camel and llama books, and
> http://www.stonehenge.com/merlyn/UnixReview/col16.html
>
> File::File looks like a useful tool but I don't
> understand how to use it enough to turn on File::Find::prune.
>
> This is the last iteration of my script...
>
> #!/usr/local/bin/perl -w
>
> use File::Find;
>
> sub wanted {
> -T &&
> -s > 5120 &&
> push(@files, $File::Find::name) &&
> ($File::Find::prune = 1);
> }
>
> find (\&wanted, '.');
>
> foreach (sort @files) { print "$_\n"; }
>
> exit;
>
> It runs but it also lists files passing the tests that
> are in the subdirectories. I would appreciate anyone to try
> to explain what I am doing wrong or point me to more
> information. (BTW, I'm running this on a unix box.)
>
> TIA, rr
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Pretty crudy whacking away at your script on my part but (note for
testing I dropped the size 5120 -> 512 because I have only small files
in this directory):
--------
use File::Find;
my @files;
sub wanted {
(-T $File::Find::name) &&
(-s $File::Find::name > 512) &&
(push @files, $File::Find::name) &&
($File::Find::prune = 1);
}
find (\&wanted, '.');
foreach (sort @files) { print "$_\n"; }
exit;
---------
[user@ravel perl]$ perl -w finder.pl
./serv.pl
./sock_err.pl
----
[user@ravel perl]$ l serv.pl sock_err.pl
-rwxrw-r-- 1 user user 617 Dec 7 19:57 serv.pl
-rw-rw-r-- 1 user user 2749 Dec 7 21:38 sock_err.pl
----
[user@ravel perl]$ ls -F
2hash.pl client.pl* equiv.pl hh.pl randi.pl
sock_err.pl
CookBookA/ cmc.dll* finder.pl name.pl ref.pl ver.pl
CookBookB/ del.pl foobie pls.pl serv.pl*
----
Should be a better way to write it, but I'm rushing off to dinner...
(Good excuse, no? ;-)
Bob L.
--
Robert Lynch-Berkeley CA USA-rmlynch@best.com
http://www.best.com/~rmlynch/
------------------------------
Date: Fri, 11 Dec 1998 05:10:58 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Info source for Perl for Win32
Message-Id: <36709b52.524144494f47414741@radiogaga.harz.de>
Paul Chapin (pdchapin@unix.amherst.edu) wrote:
: According the the documentation that came with my copy of Perl for Win32,
: the FAQ is at www.perl.hip.com and the mailing list is at mail.hip.com.
: However, I'm not showing either of these to be valid addresses. Has this
: material moved? Does it mean that my copy of Perl is out of date?
Certainly. Or should there really be a piece of software that isn't
obsolete on delivery? :-)
The website is at www.activestate.com .
The company changed name _twice_ (in between the name was ActiveWare).
Or have a look at the "standard" Win32 port at www.perl.com. By the
latest versions, it should be the same thing, but from some posts
I'reading I get the impression it's not (yet).
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
VMS is today what | work: mv@pdv-systeme.de
Microsoft wants | http://www.pdv-systeme.de/users/martinv/
Windows NT 8.0 to be! | home: martin@radiogaga.harz.de
------------------------------
Date: Thu, 10 Dec 1998 21:42:21 -0800
From: "David Christensen" <nospam@nospam.com>
Subject: Learning Perl, 2nd edition, exercise 7.1b
Message-Id: <74qbjb$dqo$1@pollux.dnai.com>
Hello, World!
I'm working my way through the above book, and everything was rosy
until I met exercise 7.1b. My attempt at a solution is as
follows:
#!/usr/bin/perl -w
while (<>) {
if ( /\\*\**/ ) {
print $& . "\n";
}
}
Looking at the solution given in the back of the book, my regular
expression appears to be correct. But, the program doesn't give
the expected output. For example, running it on my Linux box:
/home/david/perl$ex07_1b
howdy!
\* howdy doody!
\*
\\\*
\\\*
\**********\****\***
\**********
howdy \* doody!
\* howdy!
Note the space preceding the backslash in the last example.
I was expecting the output to be "\*" for the last two lines...
Running it under GNU for DOS gives similar results the first time
through, but perl is unresponsive on the second and subsequent
invokations (gives back command prompt and doesn't do anything).
Killing and restarting the bash box seems to restore perl (at
least, until I run ex07_1b once again).
Any comments or ideas?
TIA
David
PS The above "from" address is bogus to avoid spam.
My username is dchrist, and my domain is dnai.com.
------------------------------
Date: Thu, 10 Dec 1998 23:59:01 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Left and right halves of s/// parsed differently?
Message-Id: <1djuhnz.1n55fl72y62gvN@bay1-511.quincy.ziplink.net>
<eodjm01@my-dejanews.com> wrote:
> But I'm still not sure why \Q and quotemeta have been designed to work in this
> way. For example:
>
> #!/usr/local/bin/perl -w
>
> $\ = "\n";
> $string = "\t";
>
> print "this is a tab\taaaa";
> print "\Qthis is a tab\taaaa";
> print quotemeta("this is a tab\taaaa");
> print "this is a tab\\taaaa";
> print "this is a tab${string}aaaa";
> print "\Qthis is a tab${string}aaaa";
> print quotemeta("this is a tab${string}aaaa");
> print "this is a tab".quotemeta($string)."aaaa";
>
>
> I get the following output:
>
> this is a tab aaaa
> this\ is\ a\ tab\ aaaa
> this\ is\ a\ tab\ aaaa
> this is a tab\taaaa
> this is a tab aaaa
> this\ is\ a\ tab\ aaaa
> this\ is\ a\ tab\ aaaa
> this is a tab\ aaaa
>
> So neither \Q nor quotemeta lets me see the two characters \t in the output.
What two characters \t???
$string = "\t";
That's a *single* character: the tab, Control-I, ASCII character 9,
whatever you want to call it. $string contains one character, not two.
Same thing in all of these. In a double-quotish string, \t is a single
character. Using quotemeta on a tab character gives you a backslash
followed by a tab character.
print "this is a tab\taaaa";
print "\Qthis is a tab\taaaa";
print quotemeta("this is a tab\taaaa");
print "this is a tab\\taaaa";
print "this is a tab${string}aaaa";
print "\Qthis is a tab${string}aaaa";
print quotemeta("this is a tab${string}aaaa");
print "this is a tab".quotemeta($string)."aaaa";
> They do seem to be behaving as described in the book: "This function returns
> the value of EXPR ... with all regular-expression metacharacters backslashed"
> in that they are putting backslashes in front of the tab metacharacters, but
> I thought the point of backslashing something was that its behaviour would
> then change - ie. it would no longer appear as some whitespace, but as \t -
> which does seem to be the way it works on the left hand side of s///.
The left hand side of s/// is a double-quotish string too. \t is the
tab character, \n is the newline character, etc. These two regexes will
match the same thing:
s/\t//; # \t is converted to a tab
s/ //; # skip the middle man; literal tab
\\ is a single backslash character. Use quotemeta on that, and you will
get two backslash characters.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 10 Dec 1998 23:59:05 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Pattern matching and name parsing
Message-Id: <1djui41.y0m3it1tgnft4N@bay1-511.quincy.ziplink.net>
Yogish Baliga <baliga@synopsys.com> wrote:
> @array2 = map { m/^(.)/; $1; } @array;
^^
m/^(.)/s
In case the first character in any of the elements is a newline.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 10 Dec 1998 19:03:34 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl tip needed: High CPU Usage
Message-Id: <MPG.10da2b621c46880198994d@nntp.hpl.hp.com>
In article <74pegb$fgp$3@marina.cinenet.net> on 10 Dec 1998 21:29:47
GMT, Craig Berry <cberry@cinenet.net> says...
> wyndo@cxo.com wrote:
...
> : >> system calls, mainly to system("chmod 666 $filename");
>
> This is a double baddy. First, why not just juse Perl's built-in chmod()
> function? Second, this version of the system call spawns a whole separate
> shell for the command, eating time and other resources. See the doc on
> system() for alternatives.
Actually, this version of the system call *doesn't* spawn a whole
separate shell for the command. See the doc on system():
If there is only one scalar argument, the argument is checked for shell
metacharacters, and if there are any, the entire argument is passed to
the system's command shell for parsing (this is /bin/sh -c on Unix
platforms, but varies on other platforms). If there are no shell
metacharacters in the argument, it is split into words and passed
directly to execvp(), which is more efficient.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 11 Dec 1998 04:31:05 GMT
From: wyndo@cxo.com
Subject: Re: Perl tip needed: High CPU Usage
Message-Id: <74q76a$nsc$1@nnrp1.dejanews.com>
> : >> system calls, mainly to system("chmod 666 $filename");
>
> This is a double baddy. First, why not just juse Perl's built-in chmod()
> function? Second, this version of the system call spawns a whole separate
> shell for the command, eating time and other resources. See the doc on
> system() for alternatives.
> : >> $retval = do "$filename";
> : >> sleep(1); ... also select(undef, undef, undef, 0.10); and so forth...
> : >> 4 "require" statements at the top (one brings in a 54k perl file of
common
> : routines).
> : >> File OPEN/PRINT/CLOSE commands, some >$filename, others append
>>$filename;
> :
> : I appreciate any suggestions on what might cause a program to spike up to
> : 99.9% CPU usage. Thank you.
>
> Well, perhaps it's running (under the server) at too high a priority? If
> this is the case, you should see tiny CPU-seconds consumed for each
> invocation. If it's spinning that hard on a single invocation for more
> than a few seconds, odds are you have a bug in the app itself that's
> eating CPU cycles to no good end -- unless you're (say) sorting a
> multi-megabyte text file or something during each invocation.
After spending all night running tests, creating programs of different
complexity, implementing and removing various "questionable" things, I
finally realized that it doesn't matter what code is running. It is ALWAYS
happening. For instance, I created an 1800-line Perl program consisting only
of a series of "for" loops inside a function I don't even call. When I run
this program, It still spikes CPU usage up to 99.9%:
#!/usr/bin/perl
#############################################################################
## LISTALL.CGI is used to display a list of all the PLAYERS in the game! ##
#############################################################################
print "Done...\n";
sub FooRoutine {
#---------------------------------------------------------------------------
my $result = "";
for ($x=0; $x<10; $x++) {
$c .= "x";
}
$result="";
#In my testing program, the above code is repeated dozens of times so that
#the total size of this test program is 1800 lines long...
return $result;
}
#---------------------------------------------------------------------------
The interesting thing is that the program is huge, but it's fairly simple and
the FooRoutine is never even called. The same program, with only 1 loop in
the routine (making a much smaller program) doesn't seem to exhibit the
problem. This leads me to believe that the Perl interpret itself... not my
program... is what's spiking CPU usage up so high. It's churning away
compiling an 1800-line program, all the while hogging CPU time. :(
Mike.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 10 Dec 1998 19:15:29 -0800
From: Johnson Kou <kou@ssa-de.sel.sony.com>
Subject: Precision(?) of Perl
Message-Id: <36708E51.EC08CC22@ssa-de.sel.sony.com>
This is a multi-part message in MIME format.
--------------68017F6A4CE7246F6087D177
Content-Type: text/plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Hi,
It seems that the PERL in my environment (Solaris) is set to 32-bit max.
Everything above that is cut.
I wonder if there are simple ways to tell Perl that I need, let's say, 72-bit
bin/hex number for specific variables.
What I am trying to do is aligning/cascading a 72-bit hardware data bus.
I don't care much about mem space and CPU running time since I am dealing with
small amount of data.
Johnson Kou, Sony
--------------68017F6A4CE7246F6087D177
Content-Type: text/x-vcard; charset=iso-2022-jp;
name="kou.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Johnson Kou
Content-Disposition: attachment;
filename="kou.vcf"
begin:vcard
n:Kou;Johnson
x-mozilla-html:FALSE
org:Sony Semiconductor Company of America
version:2.1
email;internet:kou@ssa-de.sel.sony.com
title:Staff Engineer
tel;fax:+1-408-955-6262
tel;work:+1-408-955-5154
adr;quoted-printable:;;3300 Zanker Road=0D=0AM/S SJ3C3;San Jose;CA;95134;USA
x-mozilla-cpt:;0
fn:Johnson Kou
end:vcard
--------------68017F6A4CE7246F6087D177--
------------------------------
Date: Thu, 10 Dec 1998 23:59:06 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Regular Expression help
Message-Id: <1djui7b.tey90rjd7amtN@bay1-511.quincy.ziplink.net>
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> > > /<a href="(.*?)"/
> >
> > Actually, you might want the more efficient
> >
> > /<a href="([^"]*)"/
>
> It is already several days today since the moment the first expression
> is *much* quickier than the second one, as it should be (especially if
> you through in //s).
Dang... Now what am I going to bitch about?
Would you mind posting an explanation of the changes made so that the
former is now faster? i.e., how does the new regex engine apply the
former regular expression?
(I assume this only applies to perl5.005, though. :-)
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Thu, 10 Dec 1998 19:21:21 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting problem: Is there a better way?
Message-Id: <MPG.10da2f8954cb61398994f@nntp.hpl.hp.com>
In article <slrn770t1u.k64.sholden@pgrad.cs.usyd.edu.au> on 11 Dec 1998
01:24:14 GMT, Sam Holden <sholden@pgrad.cs.usyd.edu.au> says...
...
> @sorted = map {$_->[2]}
> sort { ($a->[0] cmp $b->[0]) || ($a->[1] <=> $b->[1]) }
> map {[ (/^([A-Z]*)([0-9]*)$/g), $_ ] } @list;
^
Just a tiny nit -- the '/g' is superfluous, because with the start and
end anchors the regex can match once only. The parens around the regex
and in the sort are superfluous also, and also harmless.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 10 Dec 1998 22:56:00 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Sorting problem: Is there a better way?
Message-Id: <alecler-1012982256000001@dialup-191.hip.cam.org>
Yes, there is a better way. Here's one I can think of (assuming values are
mixed-cased):
@list = qw/R51 X22 r6 X190 R33 a2/;
@sorted = map { $_->[0] }
sort { lc($a->[1]) cmp lc($b->[1]) || $a->[2] <=> $b->[2] }
map { [ $_, /^([A-Za-z]+)([0-9]+)$/ ] } @list;
map { print "$_\n" } @sorted;
Result:
a2
r6
R33
R51
X22
X190
If the values are all in uppercase, you can remove the lc()'s and the a-z.
HTH,
Andre
=========================
In article <36706C40.2AA1@see.sig>, Erik de Castro Lopo <please@see.sig> wrote:
> Hi all,
>
> I've got a list of items which are all of the form
> of one or more alpahbetic charaters followed by
> one or more digits and I need to sort them. The
> sorting should be done on the alphabetic part
> first. If there are two list items with the same
> alphabetic part they should be ordered on the basis
> of the size of the numeric part.
------------------------------
Date: Thu, 10 Dec 1998 22:21:14 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Sorting problem: Is there a better way?
Message-Id: <qj6q47.pt2.ln@magna.metronet.com>
Erik de Castro Lopo (please@see.sig) wrote:
: I've got a list of items which are all of the form
: of one or more alpahbetic charaters followed by
: one or more digits and I need to sort them. The
: sorting should be done on the alphabetic part
: first. If there are two list items with the same
: alphabetic part they should be ordered on the basis
: of the size of the numeric part.
: Fortunately I have read the documentation and come
: up with a working solution but I've been using Perl
: long enough to know there is a least one more way
: of doing this and probably even a better way.
: My solution is included after my .sig. Any takers
: for improvements/other solutions?
Here are some solutions.
I'll leave it to you to decide if any are an "improvement" ;-)
-------------------------
sub designator_order ()
{ my ($aa, $ba); # alpha parts
my ($an, $bn); # numeric parts
die "'$a' is not a legal value" unless $a =~ /^([a-zA-Z]+)(\d+)$/;
$aa = uc($1);
$an = $2;
die "'$b' is not a legal value" unless $b =~ /^([a-zA-Z]+)(\d+)$/;
$ba = uc($1);
$bn = $2;
return $aa cmp $ba unless $aa eq $ba;
return $an <=> $bn;
}
-------------------------
sub designator_order ()
{ my ($aa, $an) = split /(\d+)/, $a;
my ($ba, $bn) = split /(\d+)/, $b;
$aa = uc($aa);
$ba = uc($ba);
return $aa cmp $ba unless $aa eq $ba;
return $an <=> $bn;
}
-------------------------
# Schwartzian Transform
@sorted =
map { $_->[0] }
sort { "\U$a->[1]" cmp "\U$b->[1]" || $a->[2] <=> $b->[2]}
map { [$_, (split /(\d+)/)] }
@list;
-------------------------
# Schwartzian Transform with comments, read from bottom to top
@sorted =
map { $_->[0] } # return the first of the three elements (orig string)
sort {
"\U$a->[1]" cmp "\U$b->[1]" # ignore case alpha compare
|| # else
$a->[2] <=> $b->[2] # numeric compare
}
map { [$_, (split /(\d+)/)] } # three elements in anon array
# orig string, alpha part, numeric part
@list;
-------------------------
LarryR says he's tired, so we probably won't find out
which is faster... ;-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Dec 1998 19:18:32 +0000
From: Kin Cho <kin@symmetrycomm.com>
Subject: specify password in a ftp URL?
Message-Id: <un24vx0tz.fsf@server3.symmetrycomm.com>
I'm trying to use mirror in LWP::Simple to
access a ftp site that requires password access.
What does the URL look like?
I tried:
ftp://me@foo.com:password/bar.html
without success.
I'm aware of Net::FTP but I'm trying to keep things simple.
Thanks.
-kin
------------------------------
Date: 10 Dec 1998 21:03:30 PST
From: Tupshin Harper <tupshin@tupshin.com>
Subject: Re: specify password in a ftp URL?
Message-Id: <3670A77B.6AC60EA@tupshin.com>
Kin Cho wrote:
>
> I'm trying to use mirror in LWP::Simple to
> access a ftp site that requires password access.
> What does the URL look like?
> I tried:
>
> ftp://me@foo.com:password/bar.html
>
> without success.
>
> I'm aware of Net::FTP but I'm trying to keep things simple.
>
> Thanks.
>
> -kin
Standard way to express a password in a URL(both http and ftp) is
protocol://name:password@host.domain/path
-Tupshin Harper
------------------------------
Date: Thu, 10 Dec 1998 22:28:38 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: unlinking files from Perl CGI under Apache
Message-Id: <m17q47.pt2.ln@magna.metronet.com>
Emmett McLean (emclean@slip.net) wrote:
: When I attempt to remove (unlink) a file with a
: perl cgi script the file doesn't get removed.
:
: For example :
:
: unlink $fname;
No need to be left guessing why it failed.
check the return value:
unlink $fname or die "could not rm '$fname' $!";
^^ this might print
^^ Permission denied or
^^ File not found
Then go have a look at your server error log.
: Is there some parameter I should have set
: in my Apache configuration to enable the
: deletion of files?
: If so, what?
If so, you would need to ask in a server newsgroup.
Perl doesn't have a server ;-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
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 4402
**************************************