[19246] in Perl-Users-Digest
Perl-Users Digest, Issue: 1441 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 4 06:10:31 2001
Date: Sat, 4 Aug 2001 03:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <996919811-v10-i1441@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 4 Aug 2001 Volume: 10 Number: 1441
Today's topics:
Re: How to use IO::Handle to open a pipe (David Efflandt)
Re: HTPASSWD (David Efflandt)
OFFTOPIC but who cares: Re: Remote updating of my websi <walnut@froggy.com.au>
Optimum Sum? benhopkins@mindspring.com
Re: Optimum Sum? (Eric Bohlman)
Re: Optimum Sum? <godzilla@stomp.stomp.tokyo>
pdf file desc <b-sept@gmx.de>
perldoc (was Re: Subject : randomizing a hash) (Tad McClellan)
Please help with NNTP (Matt Daemon)
Re: Please help with NNTP blah@blah.blah.invalid
Save memory and measure used memory??? <markus.cl@gmx.de>
Re: Sending F Keys Through NET::Telnet <gnarinn@hotmail.com>
sendmail attachments <mike_fair1@hotmail.com>
Re: sendmail attachments (David Efflandt)
Re: string extraction <walnut@froggy.com.au>
Re: Understanding parsers <darkon@one.net>
Re: Understanding parsers (Eric Bohlman)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 4 Aug 2001 03:45:49 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: How to use IO::Handle to open a pipe
Message-Id: <slrn9mmrvd.mr8.see-sig@typhoon.xnet.com>
On Fri, 03 Aug 2001, thedoctor@space.net <thedoctor@space.net> wrote:
> I have read how to use open() to establish a pipe. I would like to use
> IO::Handle so I could test properties of the filehandle [e.g., opened or
> closed].
>
> How do you open a pipe with IO::Handle?
perldoc perlipc
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sat, 4 Aug 2001 04:10:13 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: HTPASSWD
Message-Id: <slrn9mmtd5.mr8.see-sig@typhoon.xnet.com>
On Sat, 4 Aug 2001, Sebastian Young <sebastianyoung@btinternet.com> wrote:
> This is the script:
>
> @abc = (a..z, A..Z, 0..9);
Unquoted string "a" may clash with future reserved word
Unquoted string "z" may clash with future reserved word
> srand;
> s/(.*)=(.+?)$/$2/;
Use of uninitialized value in substitution (s///)
> $cryptpass = crypt($input{'password'}, $abc[rand(@abc)].$abc[rand(@abc)]);
>
> open (htpasswd, ">.htpasswd");
> print htpasswd "$acnum:$cryptpass\n";
> }
> close (htpasswd);
Unquoted string "htpasswd" may clash with future reserved word (for the 3
lines it is used for filehandle)
> It's generating the correct password that can be read by .htaccess but I'm
> getting those black squares, which are stopping the htaccess file from
> reading the htpasswd file correctly.
Maybe if you provided a _working_ code sample we could see what you mean.
Where do black squares appear? If you get black squares at the end of
lines when viewing .htpasswd in Windows Notepad, it is because you used
binary mode to transfer text. Try using ASCII mode to ftp transfer text
(either direction) so the line endings will be correct.
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sat, 04 Aug 2001 18:53:37 +1000
From: Walnut <walnut@froggy.com.au>
Subject: OFFTOPIC but who cares: Re: Remote updating of my website
Message-Id: <joilmtc2usogi57sabs1ra0tvb4pvvgja5@4ax.com>
On Mon, 23 Jul 2001 07:47:39 +0000 (UTC), SMarshall@bluedisc.com
(Simon Marshall - SMA) wrote:
> Hi all
>
> I have a website http://www.narrowboat-havana.co.uk
> which is all about the
> boat I live on in London.
>
> I'm going to be going for a year long cruise around
> the waterways of England
> Someone tells me that some perl script on my site
> would enable me to update
> it via email
Let me be brutally honest. No-one on the face of this lonely planet
really gives a stuff about you updating your web site every single day
and in particular couldn't care less about what you do with your time.
People come to your web site for what they will get out of the
experience. The focus is on the reader NOT the writer.
But if you insist ... I have a much better idea.
Go on the cruise with a small tape recorder, lots of tape plus a good
quality digital camera and lots of memory cards and batteries. Every
day, speak your log for five minutes and take five to ten photos. When
you get back home, transcribe one segment each day onto the web and
upload the photos.
People viewing your web site (other than your friends) will be none
the wiser that the trip has already taken place! If I using my laptop
in my igloo in the North Pole, how can I tell that your "web trip" is
not in real time?
The final alternative ... Forget about the stupid web site and enjoy
your holiday. When you get back, recall what you can but add in a
whole pack of outrageous fiction just for fun. Make up the biggest
load of bull dust you can manage about the places where you have been
in excruciating detail so that other suckers can also go there on
holiday full of hope and expectation and be as disappointed as you
were when you got there ;) hahahahahahahaha.
------------------------------
Date: Fri, 3 Aug 2001 22:46:34 -0700
From: benhopkins@mindspring.com
Subject: Optimum Sum?
Message-Id: <q72gk9.m92.ln@127.0.0.1>
This is not a perl question, per se, but it
will be implemented in perl.
I have a collection of ~500 mp3 files (from
napster, audiogalaxy, and (surprise surprise)
from CDs I have paid actual money for.
I want to put these mp3s on CDs, all mixed up,
so there is an old jazz followed by Stevie Ray,
followed maybe by some country -- just the way
I listen to them (mpg123 -Z *.mp3 -- if you
know what I mean).
Anyway, I can put these files into an array,
(filenames plus size using MP3::Info), shuffle
the array (thanks to Perlfaq4), and put out
CD-sized chunks.
But I was wondering if there were some way of
optimizing the groupings so that each one would
be as close to the 80 minute limit as possible,
short of brute force.
I seem to recall something called 'sum optimization'
but I can't find anything about it that I can
implement (i.e. understand).
Any suggestions?
------------------------------
Date: 4 Aug 2001 07:51:41 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Optimum Sum?
Message-Id: <9kg9id$873$1@bob.news.rcn.net>
benhopkins@mindspring.com wrote:
> But I was wondering if there were some way of
> optimizing the groupings so that each one would
> be as close to the 80 minute limit as possible,
> short of brute force.
This is the "packing problem," and it's NP-complete; no better solution
than brute force is currently known.
How variable are the sizes of the files? If the standard deviation of the
sizes is small, then first-come-first-served will give you a solution
that's pretty close to optimal. If not, you might partition the list into
three groups:
1) Those with sizes within X standard deviations of the mean
2) Those with sizes more than X standard deviations below the mean
3) Those with sizes move than X standard deviations above the mean
and go through each list on a first-come-first-served basis. You'll have
to play with various values of X.
For that matter, if most of your files are small compared to the size of a
CD, then it's doubtful that any attempt to optimize the packing will do
much better than first-come-first-served. If, say, each CD holds 750 meg
and most of the MP3s are less than 7.5 meg, then with
first-come-first-served there'd be about 1 CD worth of wasted space for
every 100 CDs you make; hardly worth bothering over.
------------------------------
Date: Sat, 04 Aug 2001 01:26:39 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Optimum Sum?
Message-Id: <3B6BB1BF.72C66E7E@stomp.stomp.tokyo>
benhopkins@mindspring.com wrote:
(snipped to fit on a CD)
> Anyway, I can put these files into an array,
> (filenames plus size using MP3::Info), shuffle
> the array (thanks to Perlfaq4), and put out
> CD-sized chunks.
> But I was wondering if there were some way of
> optimizing the groupings so that each one would
> be as close to the 80 minute limit as possible,
> short of brute force.
> I seem to recall something called 'sum optimization'
> but I can't find anything about it that I can
> implement (i.e. understand).
Oh my, its a rehash of the Knapsnack problem from a
few weeks back.
> Any suggestions?
Yeah, spare us the aggravation and simply post this
code you have already written to resolve your
Napster Knapsnack problem.
Godzilla!
--
http://cheng.ececs.uc.edu/cs543/5-13.html
------------------------------
Date: Sat, 4 Aug 2001 01:04:45 +0200
From: "Bernhard Sept, BHS Schulungen" <b-sept@gmx.de>
Subject: pdf file desc
Message-Id: <9kg5as$v8c$04$1@news.t-online.com>
Hi,
I know, this is not the correct ng, but you might know the answer...
I am looking for the pdf file structure, because I want to create pdf files
from a program.
Any hints?
Have a nice day
Bernd
------------------------------
Date: Fri, 3 Aug 2001 23:57:28 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: perldoc (was Re: Subject : randomizing a hash)
Message-Id: <slrn9mmsl8.1qa.tadmc@tadmc26.august.net>
Stuart Aaron White <superstu@stanford.edu> wrote:
>Oh, and will i find perldoc -f rand and perldoc -q shuffle at perl.com?
The 'perldoc' program ships with the perl distribution. It is installed
as part of a normal install of perl. If you have 'perl' you should
also have 'perldoc' (somewhere).
perldoc looks things up for you in the about 1500 pages of the
standard docs that also are part of a normal install.
If you don't have perldoc, then you need to translate the
references to perldoc that you see here:
perldoc -f rand
means: Please read about the rand() function
perldoc -q shuffle
means: Please search the Perl FAQ's for the word "shuffle"
You should be able to type those on a command line and receive
helpful information in return :-)
To learn about perldoc itself:
perldoc perldoc
But if you would rather go out on the net for information that is
already on your own hard disk, you can go to:
http://www.perldoc.com
http://www.perl.com/pub/q/documentation
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 4 Aug 2001 01:18:29 -0500 (CDT)
From: matt_daemon@webtv.net (Matt Daemon)
Subject: Please help with NNTP
Message-Id: <24269-3B6B93B5-349@storefull-246.iap.bryant.webtv.net>
Can someone please help me with a perl script that will allow me to post
an article to usenet from a webserver like virtualave?
Also, I'm confused about what to put for an NNTP server. Would that be
the NNTP server from my ISP which is "localhost.webtv.net"?
FWIW... I've searched Google and other search engines most of the day,
tried 2 of Randall Schwartz's usenet scripts from his Web Techniques
column, tried example scripts from the Net::NNTP and NNTPClient,
Mail2News, etc... and can't get anything to work. I'm obviously doing
something wrong.
I'd really appreciate some help.
Thanks,
--Matt
------------------------------
Date: Sat, 04 Aug 2001 08:24:38 GMT
From: blah@blah.blah.invalid
Subject: Re: Please help with NNTP
Message-Id: <ajOa7.166$_Y2.44063861@newssvr17.news.prodigy.com>
I rather doubt your nntp server is 'localhost.webtv.net'. Try something
like 'news.webtv.net' instead.
fwiw, I happen to like using Net::NNTP.
Matt Daemon <matt_daemon@webtv.net> wrote:
> Can someone please help me with a perl script that will allow me to post
> an article to usenet from a webserver like virtualave?
>
> Also, I'm confused about what to put for an NNTP server. Would that be
> the NNTP server from my ISP which is "localhost.webtv.net"?
>
> FWIW... I've searched Google and other search engines most of the day,
> tried 2 of Randall Schwartz's usenet scripts from his Web Techniques
> column, tried example scripts from the Net::NNTP and NNTPClient,
> Mail2News, etc... and can't get anything to work. I'm obviously doing
> something wrong.
> I'd really appreciate some help.
>
> Thanks,
> --Matt
>
------------------------------
Date: Sat, 4 Aug 2001 10:55:02 +0200
From: "Markus" <markus.cl@gmx.de>
Subject: Save memory and measure used memory???
Message-Id: <9kgde1$488to$1@ID-101658.news.dfncis.de>
I want to read and store thousands of rules like these:
A -> MPN NP
A -> MPN NP $.
A -> MPN NP NE $.
A -> MPN NP NP NP NP $.
A -> MPN NP NP NP NP NP
A -> MPN NP NP PP NP NP NP AP $.
A -> MPN NP PP NP NP NP $.
B -> NP PP
B -> NP PP CD
What is the most memory-saving efficient way to store the rules?
Note that many rules begin with the same symbols.
Is this better:
$rules{'A'}{'MPN'}{'NP'} = 1;
$rules{'A'}{'MPN'}{'NP'}{'$.'} = 1;
$rules{'A'}{'MPN'}{'NP'}{'CARD'}{'$.'} = 1;
or this:
$rules{'A MPN NP'} = 1;
$rules{'A MPN NP $.'} = 1;
$rules{'A MPN NP CARD $.'} = 1;
or what?
The Benchmark module says access time using the latter method is faster.
But what is less memory-intensive?
Is there a way to measure the memory used by a certain data structure?
Thanx.
Markus.
------------------------------
Date: Sat, 4 Aug 2001 09:26:58 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Sending F Keys Through NET::Telnet
Message-Id: <996917218.527162476442754.gnarinn@hotmail.com>
In article <a4183d67.0108031006.6e116e63@posting.google.com>,
Chris Pickett <cpickett@c21rg.net> wrote:
>I am working on an interface script that will telnet to a server,
>login, run a few commands and then capture screen output. But I need
>to be able to send the return key, and f keys, specifically F9. I
>tried just sending "F9", but that of course didn't work, does anyone
>know how it is done?
>
well, it depends on the terminal, doesnt it?
maybe you should use termcap/terminfo.
on xterm, i believe it is \E[20~
where \E is the escape character, but do not take my word for it.
gnari
------------------------------
Date: Fri, 3 Aug 2001 21:32:36 -0500
From: "Mike Fair" <mike_fair1@hotmail.com>
Subject: sendmail attachments
Message-Id: <GrIa7.84$v56.6384@nnrp1.sbc.net>
This is a multi-part message in MIME format.
------=_NextPart_000_0036_01C11C63.D05A3F80
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
How do I send an attachment using sendmail?
--=20
Mike Fair
------=_NextPart_000_0036_01C11C63.D05A3F80
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4611.1300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>How do I send an attachment using=20
sendmail?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>-- <BR>Mike =
Fair</FONT></DIV></BODY></HTML>
------=_NextPart_000_0036_01C11C63.D05A3F80--
------------------------------
Date: Sat, 4 Aug 2001 04:18:20 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: sendmail attachments
Message-Id: <slrn9mmtsc.mr8.see-sig@typhoon.xnet.com>
On Fri, 3 Aug 2001 21:32:36 -0500, Mike Fair <mike_fair1@hotmail.com> wrote:
> This is a multi-part message in MIME format.
Don't do that. Use plain text.
> How do I send an attachment using sendmail?
MIME::Lite (from any CPAN mirror). It even works well with CGI.pm for
e-mailing uploaded files as attachments.
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sat, 04 Aug 2001 18:53:38 +1000
From: Walnut <walnut@froggy.com.au>
Subject: Re: string extraction
Message-Id: <89klmt4b8fqtdpq6l2g6ougage1uf5fqlc@4ax.com>
On 23 Jul 2001 18:37:33 -0700, ssa1701@yahoo.co.uk (shaz) wrote:
> Does anyone know how to go about extracting keywords from text files?
> The following code only finds some words in the text file but does not
> show the no of occurances of each word.
If you only have a limited number of matches to count, why not suck
the file into a single string then count matches. However, if you have
an unknown number, it would be best to generalise the procedure:
$number_xxx_found = $string =~ m!xxx!g;
$number_yyy_found = $string =~ m!yyy!g;
$number_zzz_found = $string =~ m!zzz!g;
------------------------------
Date: Sat, 04 Aug 2001 06:24:01 -0000
From: "David K. Wall" <darkon@one.net>
Subject: Re: Understanding parsers
Message-Id: <Xns90F318823D074darkononenet@207.126.101.100>
ebohlman@omsdev.com (Eric Bohlman) wrote:
> David Wall <darkon@one.net> wrote:
>> # I used this program to add named anchors to the HHE procedures
>> manual. # To get it to work, I ran the HTML through Dave Raggett's
>> HTML Tidy # utility, which formats the HTML in a way that made it easy
>> for me to # process it. In particular, I was able to make the
>> following assumptions # about the format of the document: # # * <ol>,
>> </ol>, <ul>, </ul>, and <li> are always on lines by themselves.
>
> Using a proper parser would free you of this assumption.
Yes. That's why I was asking for background material on parsers.
I won't respond to the other comments you made on my code other than to
note that I agree completely. My only defense is that it was a run-once
program, and that I was more interested in getting it to work than anything
else. However, since I expect I'll have to write similar programs in the
future, I'm interested in more efficient and prettier solutions.
But I do appreciate you taking the time to look it over and criticize it.
Pointing out shortcomings is much more useful than pointing out where I did
something right.
--
David Wall - darkon@one.net
"If art is communication, then Andy Warhol stutters." -me
------------------------------
Date: 4 Aug 2001 07:25:21 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Understanding parsers
Message-Id: <9kg811$4jk$1@bob.news.rcn.net>
David K. Wall <darkon@one.net> wrote:
> Yes. That's why I was asking for background material on parsers.
You don't actually need to know a whole lot about parsers in general to
use the HTML parsers, because the language they parse is fixed (most
of parser theory is about how to create parsers for arbitrary languages).
The basic Perl HTML parsers are HTML::Parser and HTML::TokeParser, both of
which are part of the HTML::Parser distribution. They take an HTML
document and break it up into logical "pieces": start tags, end tags,
text, comments, and processing instructions. The difference between the
two is in how they present the pieces to you. HTML::Parser has a "push"
interface: you tell it to parse a document, and you give it the names of
subroutines in your code ("callbacks") that it should call for each piece
it encounters. HTML::TokeParser has as "pull" interface: you call a
method (get_token()) which returns the next piece; it's like reading a
file a line at a time, except you're reading pieces, not lines.
I'd suggest you start with HTML::TokeParser, since its pull interface is
probably going to be more familiar to you than a push interface, and it
would be easier to adapt your existing code to it.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1441
***************************************