[10310] in Perl-Users-Digest
Perl-Users Digest, Issue: 3902 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 6 12:07:30 1998
Date: Tue, 6 Oct 98 09:01:42 -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 Tue, 6 Oct 1998 Volume: 8 Number: 3902
Today's topics:
Re: Data Search Question <jdporter@min.net>
File Upload on Windows NT <kwc@ebs.hw.ac.uk>
Re: forms with perl <e.christensen@netjob.dk>
Re: Help using Perl and Tk <bradw@newbridge.com>
Help with Here Document <ap85@cornell.edu>
Help with Here Document <ap85@cornell.edu>
Re: Help with mutilple HTML lines droby@copyright.com
Re: How do I 'su' to in a perl script (when password is <eashton@bbnplanet.com>
Re: How to pass a hash array to a sub program <Paul.Makepeace@POBox.com>
Re: How to pass a hash array to a sub program (Larry Rosler)
Re: How to pass an array in AND out of a subroutine? huntersean@hotmail.com
Re: I hate it when I do that. <aqumsieh@tigre.matrox.com>
Mac::Apps::Launch 1.60 (Chris Nandor)
Re: NEEDED: A good perl programer to... <eashton@bbnplanet.com>
Re: NEEDED: A good perl programer to... <Paul.Makepeace@POBox.com>
Re: new term for illogical <jdporter@min.net>
Re: Omaha Perl Mongers - First Meeting ! (Patrick Timmins)
Re: Passing Variables: $_ vs. @_ <jdporter@min.net>
Re: Perl and Novell Netware v4 <eashton@bbnplanet.com>
Re: Perl Cookbook, does anyone have it? <bradw@newbridge.com>
perl html tag parser ekaull@my-dejanews.com
Re: perl html tag parser <jdf@pobox.com>
perlpkg 5.005_02 - Perl man pages in Newton Book format (Chris Nandor)
Re: please check my CGI.pm/Perl Syntax <jdporter@min.net>
Re: Problems Using a Compare Subroutine with Sort (Lloyd Zusman)
Q: How do I force perl to deallocate hash tables? <cdegroot@hdc.net>
Re: Q: Speed up a regular expression <jdf@pobox.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 06 Oct 1998 10:57:37 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Data Search Question
Message-Id: <361A2FE1.90D88F81@min.net>
Larry Rosler wrote:
>
> The best I can do is an array and a linear search.
> I'd love to be shown a better way.
I'm certainly not suggesting this is a better way,
but it's how I thought about the problem.
The downside is it greps the list of words once for
each character in the input word.
sub best_match {
my $t = shift;
my @w = @_;
my $len = length($t);
my %h;
for my $i ( 0 .. $len-1 ) {
my $pat = '.' x $len;
substr($pat,$i,1) = substr($t,$i,1);
for ( grep { /$pat/ } @w ) {
$h{$_}++;
}
}
my @best = ('',0); # word, number of matching letters
while ( my @e = each %h ) {
if ( $e[1] > $best[1] ) {
@best = @e;
}
}
@best
}
#
# test it
#
my( $word, $letters ) = best_match (
'UQPALRIEOF',
qw(
JSUWIGKROD
KIWPLODGQF
WOQPLIFJSK
OQPALSNEUG
ISOPQKEOSP
)
);
print "Best match is '$word', with $letters letters.\n";
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: Tue, 06 Oct 1998 14:57:18 +0100
From: Ken Currie <kwc@ebs.hw.ac.uk>
Subject: File Upload on Windows NT
Message-Id: <361A21BE.192E3796@ebs.hw.ac.uk>
I have Perl 5.005 Win 32 on NT Server 4 and IIS 4.0.
I cannot upload a file greater than about 50K bytes. Above this size
the 'Transferring data" message stays on and I have to restart the WWW
server to stop the underlying process consuming almost 100% of the cpu
time.
If anyone knows why there is this limit I would be keen to know how to
get round it. Doesn't happen on UNIX.
Ken Currie
E-mail replies to kwc@ebs.hw.ac.uk
------------------------------
Date: Tue, 06 Oct 1998 16:14:06 +0100
From: EC <e.christensen@netjob.dk>
Subject: Re: forms with perl
Message-Id: <361A33BE.FA29B6C@netjob.dk>
or checkout cgi-http.pl
r
Ernst
Justin Harvey wrote:
> Check out CGI.pm in:
>
> http://stein.cshl.org/WWW/software/CGI/cgi_docs.html
>
> Steve Goodyear wrote:
> >
> > Essentially I need to replace a standard HTML form using the POST method
> > with a perl script...
> >
> > I'm not real sure where to start....
>
> --
> Justin B. Harvey http://www.auspex.net/jbharvey
> jbharvey@auspex.net Mountain View, CA
>
> use Perl || die "trying";
------------------------------
Date: 06 Oct 1998 11:19:23 -0400
From: bj <bradw@newbridge.com>
Subject: Re: Help using Perl and Tk
Message-Id: <op14sthvhtw.fsf@ca.newbridge.com>
dave@mag-sol.com writes:
> In article <360B8F94.A89AD99E@shaw.wave.ca>,
> Rick Delaney <rick.delaney@shaw.wave.ca> wrote:
> > Jonathan Feinberg wrote:
> > >
> > > Soon there will be an O'Reilly book about Perl/Tk. Hang in there.
> >
> > Is this fact or wish?
>
> Fact:
>
> <http://www.oreilly.com/catalog/lperltk/>
>
> and
>
> <http://www.oreilly.com/catalog/perltkpr/>
Slipping sliding away (just like 2nd edition of the Camel)... now
suppost to be available in January... :-(
bj
------------------------------
Date: Tue, 06 Oct 1998 10:00:59 -0400
From: Andrew Perrella <ap85@cornell.edu>
Subject: Help with Here Document
Message-Id: <361A229B.70971D24@cornell.edu>
Hello,
Is it possible to use the "Here Document" method to print to a
variable?
I have tried
print TEXT<<end_of_text;
Hello this is a atest
end_of_text
$words = <TEXT>;
print $words;
but I can't get this to work. I am not even sure it is possible.
Thanks in advance.
Andrew Perrella
ap85@cornell.edu
------------------------------
Date: Tue, 06 Oct 1998 09:57:03 -0400
From: Andrew Perrella <ap85@cornell.edu>
Subject: Help with Here Document
Message-Id: <361A21AF.570D026E@cornell.edu>
Hello,
Is it possible to use the "Here Document" method to print to a
variable?
I have tried
print TEXT<<end_of_text;
Hello this is a atest
end_of_text
$words = <TEXT>;
print $words;
but I can't get this to work. I am not even sure it is possible.
Thanks in advance.
Andrew Perrella
ap85@cornell.edu
------------------------------
Date: Tue, 06 Oct 1998 12:53:38 GMT
From: droby@copyright.com
Subject: Re: Help with mutilple HTML lines
Message-Id: <6vd3sj$f89$1@nnrp1.dejanews.com>
In article <6vb8br$u2d$1@ultra.sonic.net>,
"Gala Grant" <gala@sonic.net> wrote:
> I am trying to write a perl program that among other things searchs an HTML
> file for a text match. The problem I am having is that what HTML and perl
> think is a line is different. So what I am searching for spreads over 2
> lines in HTML, so when I do
> if ($line = /$match/)
> it won't match. I tried removing theline delimiter, but that created a
> whole new buch of problems. If anyone can help it would be greatly
> appreciated.
> Gala Grant
> gala@sonic.net
>
>
In perlfaq6, the question is posed:
I'm having trouble matching over more than one line. What's wrong?
It is also answered.
By the way, what HTML thinks is a line is irrelevant, and sort of a
meaningless phrase. An html file is just text, and has line-breaks like any
other text file. Where they occur has little to do with HTML, and where html
puts breaks in a browser display varies with the browser.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 06 Oct 1998 13:09:51 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: How do I 'su' to in a perl script (when password is known)
Message-Id: <361A1426.ACA6F628@bbnplanet.com>
Gerard Hammond wrote:
> I am stuck at the point when I need the perl script to setuid to the
> person who entered the data from the web page. The person will have
> entered their user name and passwd from the web page. Yes I understand
> there are a lot of security issues with this whole idea!)
> So how do I set the perl script to write files in their directory. Is
> there some call that temporarily runs the script as the web user.
How will you authenticate the users? Have a look at 'perldoc perlsec'.
e.
So the Earth endures, in every petty matter
And in the lives of men, irreversible.
And it seems a relief. To win? To lose?
What for, if the world will forget us anyway. -C. Milosz-
------------------------------
Date: Tue, 6 Oct 1998 14:58:04 +0100
From: "Paul Makepeace" <Paul.Makepeace@POBox.com>
Subject: Re: How to pass a hash array to a sub program
Message-Id: <6vddju$fmu$1@statler.server.colt.net>
[cancelled/reposted]
huntersean@hotmail.com wrote in message <6vd1in$bvb$1@nnrp1.dejanews.com>...
> sub print_hash
> {
> print "Here is the hash array passed into the subprogram:\n";
> while (my ($key,$value) = each %{$_}) {print "$key=$value\n";}
> }
$_ doesn't have the first argument of a subroutine. @_ contains the
arguments, so you want $_[0].
Unless you're optimising for unreadability, name your variables. Newlines in
code generally don't hurt (says I...).
sub print_hash {
my $hash_ref = shift; # or $_[0] which is slighty (how much?) quicker
while (my ($k,$v) = each %$hash_ref) {
print "$k => $v\n";
}
}
print_hash (\%a);
--
Paul Makepeace, Independent Thinkers Ltd (UK)
0171 377 8668 / 0973 800436
"People are all monkeys, and I am Captain Banana"
-- Vincent Gallo
------------------------------
Date: Tue, 6 Oct 1998 08:15:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to pass a hash array to a sub program
Message-Id: <MPG.1083d405e7250ece9898a1@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <6vd1in$bvb$1@nnrp1.dejanews.com> on Tue, 06 Oct 1998 12:14:15
GMT, huntersean@hotmail.com <huntersean@hotmail.com> says...
> You need to pass it as a hash reference. Check out perldoc perlref.
> Something like:
...
> while (my ($key,$value) = each %{$_}) {print "$key=$value\n";}
How about something like:
while (my ($key,$value) = each %{$_[0]}) {print "$key=$value\n";}
which has the advantage of working correctly (and which I posted
yesterday :-).
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 06 Oct 1998 12:51:36 GMT
From: huntersean@hotmail.com
Subject: Re: How to pass an array in AND out of a subroutine?
Message-Id: <6vd3oo$f7g$1@nnrp1.dejanews.com>
Use a reference if you want to modify items in place. Something like
my @items;
my $num_items;
&read_data ($file1, \$num_items, \@items);
...
sub read_data {
my ($file, $count, $list) = @_;
open INPUT "< $file" or die "Aiee!!!";
@{$list} = <INPUT>;
$$count = @{$list};
}
In certain cases, however, it may be better to use something like:
my @items = read_data($file);
...
sub read_data {
my $file = $_[0];
open INPUT "< $file" or die "Aiee!!!";
my @list = <INPUT>;
return @list;
}
This can be scaled to:
my ($foo, $bar, @washpot) = &mysub($baz);
...
sub mysub {
...
return $foo, $bar, @baz;
}
References can be used when returning multiple lists and/or hashes, and to
avoid copying.
Good luck and may "perldoc perlre" be with you...
Sean Hunter
Sean Hunter
In article <19981006011956.01129.00001070@ng137.aol.com>,
tianxiong@aol.com (Tianxiong) wrote:
>
> For example, I want to read data from two data files using a subroutine. If
> there are 5 and 10 items in those two files, and I would expect that
$num_items
> = 15 and @items contains 15 items after the folling routine is executed. I
> know how to do it in C but not in perl. Thanks in advance for your help.
>
> ############
> $num_items = 0;
> &read_data ($file1, $num_items, @items);
> print "num_items = ",$num_items, "\n";
> &read_data ($file2, $num_items, @items);
> print "num_items = ",$num_items, "\n";
>
> sub read_data{
> # ???? how ????
> }
>
> ###########
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 06 Oct 1998 10:23:20 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: I hate it when I do that.
Message-Id: <x3y3e91g46f.fsf@tigre.matrox.com>
bart.mediamind@ping.be (Bart Lateur) writes:
>
> Andrew M. Langmead wrote:
>
> >Sorry, didn't mean to offend. Its just that there is a school of
> >thought that in writing substantial programs one should avoid implicit
> >$_. I don't necessarily agree with it, but I do see their
> >point. (Although I'd probably feel comforable with the rule "assign to
> >an explicit variable instead of $_ if you can no longer see in your
> >text editor both where $_ gets set and where it is used without
> >scrolling."
>
> Do without $_? Nah. But you have to avoid treating $_ as just an
> ordinary variable.
>
> I think of it as the Perl equivalent of the accumulator in assembler
> (general purpose CPU register). It's a convenient short term place to
> manipulate values that you need to access more than once in subsequent
> statements.
>
> You may not expect to keep the value in there for long; it will soon be
> overwritten. So, if you ever use it so that subsequent uses don't even
> fit on the same screen in the editor, then you're definitely using it
> the wrong way.
Not necessarily true .. but I have to admit that my excessive
dependency on the default variable ran me into some problems in the
past. But I don't think I can "perl" without it. So I (sometimes)
localize the scope where $_ is used to avoid confusion.
>
> BTW a "nice" way to manipulate a variable through $_, is using "for":
>
> for($ary[-1]) {
> chomp;
> tr/,/./;
> }
>
> This will manipulate the last item of this array.
"Nice" indeed ... but not very useful if you have only one element in
the list!!
>
> It's actually a looping construct, but with only one item in the array
> it's looping through, it will be executed exactly once. I would like it
> if Perl allowed a yet more conventient synonym for the "for" (but
> what?), but it will do for now.
Hmmm... haven't you heard of map() ??
To execute your above code on the whole @ary, you can do:
@ary = map { chomp; tr/,/./; } @ary;
which is equivalent to:
for (@ary) {
chomp;
tr/,/./;
}
Also, if you have the latest Perl (5.005 or higher) you can do :
do {
chomp;
tr/,/./;
} for (@ary);
Now THAT is nice!
>
> Bart.
--
Ala Qumsieh | No .. not Just Another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: 6 Oct 1998 15:26:50 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Mac::Apps::Launch 1.60
Message-Id: <6vdcrq$cqn$1@news.neta.com>
Recent changes:
v.1.60, September 28, 1998
Added `LaunchSpecs'. Use this when the app does not have a unique
app ID, the app is not really an app (like the Finder), or you
have more than one instance of the app, and want to launch a
particular one.
Full README below.
Monday, September 28, 1998
This archive can always be obtained from:
http://pudge.net/macperl/
http://perl.com/CPAN/authors/id/CNANDOR/
http://perl.com/CPAN/modules/by-module/Mac/
The file is a tarred, gzipped file. Use Stuffit Expander or a
similar program to get at the archive.
Please let me know how well it does(n't) work, and any changes you'd
like to see.
#============================================================================
NAME
Mac::Apps::Launch - MacPerl module to launch applications
SYNOPSIS
use Mac::Apps::Launch;
my @apps = qw(R*ch Arch MPGP);
my $path = "HD:System Folder:Finder";
LaunchApps([@apps], 1) || warn($^E); # launch and switch to front
LaunchApps([@apps]) || warn($^E); # launch and don't switch
LaunchApps($app[1], 1) || warn($^E); # launch and switch to front
LaunchSpecs($path, 1) || warn($^E); # use path instead of app ID
QuitApps(@apps) || warn($^E); # quit @apps
QuitAllApps(@apps) || warn($^E); # quit all except @apps
IsRunning('MACS'); # returns boolean for whether
# given app ID is running
DESCRIPTION
Simply launch or quit applications by their creator ID. The Finder can
be quit in this way, though it cannot be launched in this way.
This module is used by several other modules.
This module as written does not work with MacPerls prior to 5.1.4r4.
EXPORT
Exports functions `QuitApps', `QuitAllApps', and `LaunchApps',
`IsRunning', `LaunchSpecs'.
HISTORY
v.1.60, September 28, 1998
Added `LaunchSpecs'. Use this when the app does not have a unique
app ID, the app is not really an app (like the Finder), or you
have more than one instance of the app, and want to launch a
particular one.
v.1.50, September 16, 1998
Added `IsRunning'.
v.1.40, August 3, 1998
Only launches application if not already open; e.g., won't launch
newer version it finds if older version is open.
v.1.31, May 18, 1998
Added `AEDisposeDesc' call (D'oh!). Dunno why I forgot this.
v.1.3, January 3, 1998
General cleanup, rewrite of method implementation, no longer
support versions prior to 5.1.4r4, addition of Quit methods,
methods return undef on failure (most recent error in `$^E', but
could be multiple errors; oh well).
AUTHOR
Chris Nandor <pudge@pobox.com> http://pudge.net/
Copyright (c) 1998 Chris Nandor. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself. Please see the Perl Artistic License.
VERSION
Version 1.60 (28 September 1998)
#============================================================================
- --
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
Version: PGPfreeware 5.0 for non-commercial use <http://www.pgp.com>
Charset: noconv
iQCVAwUBNg/8LShcZja3bnKtAQFSZQP5ATE4Re/HKErJekjBKYPmn9kk0iFi/6Xq
E9ih7Qgi66C42OkE+zmSfJ6T3F4joD+bT3iJM5cxd8G9bgTbHligisuYW6oHMxwI
qoVr0IZZYIsIxxMyN29HvnUnGOnXbtRvSHb4XBakO066kbj7bU3citeG1mGoeGL8
Uzggq6i/hLY=
=1L2Z
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 06 Oct 1998 13:25:43 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: NEEDED: A good perl programer to...
Message-Id: <361A17DE.8F1E748A@bbnplanet.com>
Michal Rutka wrote:
> You forgot to mention a price which you are willing to pay. Therefore
> dont expect any serious offer.
I'll bet you don't play poker very well. ;)
e.
I turn off the last light and close the door.
Moving toward whatever ancient thing
it is that works the chains
and pulls us so relentlessly on. -R. Carver-
------------------------------
Date: Tue, 6 Oct 1998 13:08:24 +0100
From: "Paul Makepeace" <Paul.Makepeace@POBox.com>
Subject: Re: NEEDED: A good perl programer to...
Message-Id: <6vd76f$ddm$1@statler.server.colt.net>
Elaine -HappyFunBall- Ashton wrote in message
<361A17DE.8F1E748A@bbnplanet.com>...
>Michal Rutka wrote:
>
>> You forgot to mention a price which you are willing to pay. Therefore
>> dont expect any serious offer.
>
>I'll bet you don't play poker very well. ;)
Poker's very different... if an agent/client isn't able to start talking
money in a matter of seconds the conversation has a pretty short lifespan.
------------------------------
Date: Tue, 06 Oct 1998 10:32:42 -0400
From: John Porter <jdporter@min.net>
Subject: Re: new term for illogical
Message-Id: <361A2A0A.E13475FF@min.net>
Ben Sauvin wrote:
>
> Dunno about abrasiveness being any reliable indication of
> insecurity or sensitivity. Some people are abrasive simply
> because they don't give a damn.
How is that different from being insensitive, exactly?
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: Tue, 06 Oct 1998 15:42:24 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Omaha Perl Mongers - First Meeting !
Message-Id: <6vddp0$stl$1@nnrp1.dejanews.com>
In article <6vchcm$d4d@news1.panix.com>,
dha@panix.com (David Adler) wrote:
> >The first meeting of the Omaha Perl Mongers will be next week:
>
> Yay! Congratulations!
Thank you Mr. Adler! What, with all of the pelicans, flamingos, King Lear,
Lewis Carroll, and croquet wickets that are floating about in this thread,
the Omaha area locals, perhaps, did not hear the forest through the falling
tree:
The first meeting of the Omaha Perl Mongers will be tomorrow:
Wednesday, October 7, 1998
6:00 pm-ish
The Dubliner Pub
1205 Harney (in the Old Market)
Omaha, NE
Show up, and you could win a free Perl Mongers T-shirt !
> >( follow the 'Omaha, the Beautiful' link to see the top 10 reasons
> > why Omaha should host the year 2000 Perl Conference! )
>
> Hey, watch it buddy. We East Coasters called dibs on that one at the
> 1998 conference...
Well, I'm sorry, but I've already heard from Larry, and he's decided it
*will* be in Omaha. (This is currently a lie, but if I say it two more
times it will come true.)
New York has no night life, and the locals could be easily upset by
an invasion of a large number of Perl eccentric types. Omaha folks, on
the other hand, enjoy meeting and conversing with anything that doesn't
say "Moooo! .... MooooOooo!" incessantly.
Or so I've herd.
Patrick Timmins
$monger{Omaha}[0]
Omaha, NE - "The City that Doesn't Sleep"
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 06 Oct 1998 10:07:04 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Passing Variables: $_ vs. @_
Message-Id: <361A2408.69FD8F64@min.net>
Bart Lateur wrote:
>
> John Porter wrote:
>
> >Robert Bell wrote:
> >>
> >> I guess that I usually don't think about this scoping relevance in
> >> Perl, but I also tend to place subroutines early in a script.
> >
> >So maybe that practice isn't such a good idea after all.
>
> Say what?
>
> Are you actually saying that you should not put sub declarations
> before your plain code?
I'm saying, if there is a problem with putting subs first, then
don't do it. I'm not trying to be dogmatic. I just think
putting subs last is "better".
I do it both ways myself, actually. But even if I put my main code
at the bottom (as I typically do with benchmarks), I'll still put
initializaions at the top, because it is imperative that they
get executed first. BEGIN blocks don't work (not very well) for
initializing file lexicals -- the lexicals still need to be
outside the block.
> 'use' and especially 'require' can be considered as
> including the text of the modules/library files in place, so as soon as
> you 'use' a module, you are putting the definitions of the subs in front
> of the working code!
'use' gets executed before any of the rest of your code, regardless
of placement; it's in an implicit BEGIN block.
'require' should be put whereever you think it should be.
Maybe at the top, maybe in some subroutine. It's up to you.
And there oughtn't be variables shared between your file and
the required/used file, so issues of initializations shouldn't
come up. But if they do, then you better do the initializations
in the right place, e.g. before the use/require.
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: Tue, 06 Oct 1998 13:48:10 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Perl and Novell Netware v4
Message-Id: <361A1D22.AFEF08E3@bbnplanet.com>
Jeffrey R. Drumm wrote:
> The other posts you've received in response to your query probably weren't
> quite as helpful as you'd like.
Indeed and I would like to apologise for that rather awful stupid post
that not only missed the question but also was way out of character. Mea
culpa.
e.
"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon." R. Carver
------------------------------
Date: 06 Oct 1998 10:59:48 -0400
From: bj <bradw@newbridge.com>
Subject: Re: Perl Cookbook, does anyone have it?
Message-Id: <op167dxviqj.fsf@ca.newbridge.com>
echao@interaccess.com (Eisen Chao) writes:
> I got examples from Web site and put on a floppy to take home.
>
> Some goooood stuff there...
>
> John Call (johnc@interactive.ibm.com) wrote:
> : Has anyone gotten a copy of this yet? I'm dying to get it and it doesn't
> : seem to have reached Georgia yet.
> :
> : If you do have it, do you like it? From what I've seen on the ORA site it
> : looks good.
Tis very good! I would not recomend trying to learn Perl from it, but
as a reference book for a beginner (thats me), it is a great book for
getting ideas and starting points. The Panther book still hurts my
head in places.
Currently in the middle of reading it cover to cover, whilst jumping
around as I use the recipes to solve day to day crap. I would say it
is a must have for the bookcase unless you are a serious Perl hacker.
Why go through the pain of writing crap code, when you can start with
good code, and then break it... :-)
bj
------------------------------
Date: Tue, 06 Oct 1998 13:18:31 GMT
From: ekaull@my-dejanews.com
Subject: perl html tag parser
Message-Id: <6vd5b8$h41$1@nnrp1.dejanews.com>
Here's the scoop. I have a project with 600 or so html files that have
numerous links in "mixed case". The problem is that they are bein uploaded
into a unix box. I've aready written a program to find the href tags.
Actually, it finds them and converts then entire line to lowercase. That is
not a valid solution since there is often other text on the line that get's
converted.
Could anybody give me a regular expression that finds the href tag and
converts the contents between the double quotes to lowercase.
Here's what I've got.....it's only a snippet so ignore the things like
incrementing counters etc....
if ($listing[$index]=~/href+\s*\=+\"/i) # looking for the href - this works
{
$listing[$index]=~tr/A-Z/a-z/; # convert line to lower case
# want to only convert inside quotes here
# print $index;
# print " ";
print $listing[$index];
$counter++;
}
else
{
# print $index;
# print " ";
print $listing[$index];
# print "\n";
}
Thanks!
Please respond by email..
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 06 Oct 1998 16:09:01 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: ekaull@my-dejanews.com
Subject: Re: perl html tag parser
Message-Id: <m3ogrp9402.fsf@joshua.panix.com>
ekaull@my-dejanews.com writes:
> Could anybody give me a regular expression that finds the href tag and
> converts the contents between the double quotes to lowercase.
No. Any such regex would be either very, very long or inaccurate. You
need to use a parser. Luckily the libwww modules contain HTML::Parser
and its child HTML::Filter.
#!/usr/bin/perl -w
package HREF_to_Lowercase;
require HTML::Filter;
@ISA = qw( HTML::Filter );
sub start {
my $self = shift;
my ($tag, $attr, $attrseq, $text) = @_;
if ($tag eq 'a') {
$attr->{href} = lc $attr->{href} ;
$_[3] = '<a ' . (join ' ', map qq($_="$attr->{$_}"),@$attrseq) . '>';
}
$self->SUPER::start(@_);
}
package main;
my $p = HREF_to_Lowercase->new->parse_file(\*DATA);
__END__
This line has a <a href="HTtP://pObOx.COM/~jdf/">link</a>.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 6 Oct 1998 15:26:35 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: perlpkg 5.005_02 - Perl man pages in Newton Book format
Message-Id: <6vdcrb$cpj$1@news.neta.com>
This is the collection of Perl 5.005_02 man pages in Newton Book format. They
were created using the pod files and pod2html utility with the perl5.005_02
distribution, then converted into Newton Book format using Newt's Cape.
These were designed for the large-screen landscape mode and work only on
devices with NewtonOS 2.0 or higher and the larger MessagePad 2000 screen.
Why? Because the smaller window size to fit on smaller screens was
annoying me. If you need the smaller screen size, the Newton Books for
perl5.004 are still available at the URL below.
Also, the Minico font (sizes 9 and 10) is used. If you don't have Minico, it
will default to Casual or something. Ugh.
It is all online on my site and soon to be on a CPAN near you.
http://www.perl.com/CPAN/authors/id/CNANDOR/
http://pudge.net/perlpkg/
- --
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
Version: PGPfreeware 5.0 for non-commercial use <http://www.pgp.com>
Charset: noconv
iQCVAwUBNhABJShcZja3bnKtAQHutgP/Tgi9ctTHdmcq/a0utRmGq5ZGZkJhcTeH
I/y3Gre7OqC8WcOA3ix7wnNEKWQAx/lPDm25LIGwKZT/ruBfzU+i+0PTSM7e+ciu
bjwuNmak7qwFRa8I2Y2y6cJHkQu3/vNKBZNV26F1IHvViQn150c4DSWOve9XMQlg
B7khtudrLxs=
=wlhC
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 06 Oct 1998 11:26:02 -0400
From: John Porter <jdporter@min.net>
Subject: Re: please check my CGI.pm/Perl Syntax
Message-Id: <361A368A.8A548389@min.net>
madame philosophe wrote:
>
> Is this syntax correct?
Huh, no.
> sub spy {
> local $q = shift;
> local $activity_path;
What do you have against 'my'?
> my $spy_entry = new CGI($q);
> my(@spy_set, $stuff, $log_row);
>
> foreach ( $spy_entry->param() =~
> /^(person|action|contribution|email|date)$/
> ) {
> push(@spy_set, map{ $stuff = $spy_entry->param($_) });
> $log_row = join( ' ][ ', @spy_set);
> }
Quite wrong. Try this:
for ( qw( person action contribution email date ) ) {
next unless $spy_entry->param($_);
push @spy_set, $spy_entry->param($_);
}
# this line should be OUTSIDE the foreach loop:
$log_row = join( ' ][ ', @spy_set );
>
> sysopen(LOG, "$activity_path", O_WRONLY|O_APPEND, 0660) ||
> log_error('LOGTRACK_ERR',$spy_entry);
As far as I can tell, $activity_path never got set. Big Bug!
Also, what does your log_error() do? If it tries to write
to LOG, then this statement has a big problem.
> $spy_entry->save($log_row);
If you're trying to save a subset of the params (as I understand
from another posting from you), then the best way would be
to delete the unwanted fields from the copy, and save that.
sub save_some_fields {
my $copy = CGI->new(shift); # make the copy
local *F = shift;
my %fields; @fields{@_} = (); # 'exist'ify them.
for ( $copy->param ) {
unless ( exists $fields{$_} ) {
$copy->delete($_);
}
}
$copy->save(*F);
}
save_some_fields( $q, *F, qw( person action contribution ) );
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: 6 Oct 1998 14:06:52 GMT
From: ljz@asfast.com (Lloyd Zusman)
Subject: Re: Problems Using a Compare Subroutine with Sort
Message-Id: <slrn71k8v8.ldd.ljz@sunspot.tiac.net>
On Mon, 05 Oct 1998 22:56:11 GMT, Garry T. Williams <garry@america.net> wrote:
>
> [ ... ]
>
> I don't believe that interpreting 0xffffffff as a minus one is a bug.
> That *is* minus one (assuming a 32-bit word size).
I'm in agreement here.
> [ ... ] The real problem is
> using a numeric compare to sort IP addresses. They are strings and a
> string compare is the only way to order them.
I'm sorry to say that I'm not in agreement here. Consider this:
@a = qw( 2.100.100.100 30.10.100.100 100.99.10.10
100.100.10.10 100.101.10.10 );
foreach $item (sort { $a cmp $b } @a) {
print " $item\n";
}
Here's the output:
100.100.10.10
100.101.10.10
100.99.10.10
2.100.100.100
30.10.100.100
This ordering is not very meaningful.
The dotted form of IP addresses is a shorthand to represent unsigned,
32-bit integers, and this is how these addresses are stored in network
packets. Hence, a sort using unsigned integer comparisons seems to be
the most logical way to do this.
--
Lloyd Zusman
ljz@asfast.com
God bless you.
------------------------------
Date: Tue, 6 Oct 1998 13:41:14 GMT
From: Craig De Groot <cdegroot@hdc.net>
Subject: Q: How do I force perl to deallocate hash tables?
Message-Id: <361A1DFA.3D0FE221@hdc.net>
I am trying to force perl to deallocate some hashes because I am running
low on memory. I tried using undef, but this merely removes the
reference to the hash and does not allow me to reclaim the memory. Is
there any way for me to actually remove the hash from memory?
------------------------------
Date: 06 Oct 1998 15:20:35 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: tilman@spp.hpc.fujitsu.co.jp
Subject: Re: Q: Speed up a regular expression
Message-Id: <m3u31h968s.fsf@joshua.panix.com>
tilman@spp.hpc.fujitsu.co.jp writes:
> if ($line =~ /(^$Search )|( $Search )/io)
>
> I want to match a string $Search either in the beginning of $line or
> within the string $line, but then with a leading SPACE.
Are you sure you really mean "with a leading space"? I'll bet you mean
"at a word boundary".
$line =~ /\b$Search\b/io;
See perlre.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
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 3902
**************************************