[12171] in Perl-Users-Digest
Perl-Users Digest, Issue: 5771 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 25 10:07:20 1999
Date: Tue, 25 May 99 07:00:24 -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, 25 May 1999 Volume: 8 Number: 5771
Today's topics:
Re: ? collecting data from URL, then save as text-file (Randal L. Schwartz)
anyone knows if theres any bug with my code? smnayeem@my-dejanews.com
Re: Bookmarking Favorites in Word (Scott McMahan)
Re: Don't understand ctime / stat[10] <tchrist@mox.perl.com>
Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe (Chris Nandor)
Re: finding min in hash of hashes <kensai@nortel.com>
Re: Finding the date... (Dave Cross)
Re: help on openiong and manipulating files (Tad McClellan)
Re: Help Requested with PERL script <kensai@nortel.com>
Re: How to use "system" with csh ?? <jdporter@min.net>
Re: Interesting question (Tad McClellan)
Re: Interesting question <jdporter@min.net>
Re: need an anti-leech script <bill@fccj.org>
Re: need an anti-leech script <tchrist@mox.perl.com>
Re: need an anti-leech script <jdporter@min.net>
Re: need an anti-leech script <tchrist@mox.perl.com>
Re: parent directories <ebohlman@netcom.com>
Re: Perl in the News: _Cryptonomicon <cmcurtin@interhack.net>
Re: Perl in the News: _Cryptonomicon <tchrist@mox.perl.com>
Re: Perl in the News: _Cryptonomicon <droby@copyright.com>
Re: Perl Newbie <jdporter@min.net>
Re: PERLFUNC: unshift - prepend more elements to the be <kensai@nortel.com>
Re: Pigheadedness (was Re: Newbie; Perl/Tk Event models <bill@fccj.org>
Re: Printers <jdporter@min.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 May 1999 05:15:25 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: ? collecting data from URL, then save as text-file ?
Message-Id: <m1so8luyzm.fsf@halfdome.holdit.com>
>>>>> "Paolo" == Paolo <PrinsPaul@DELETETHIShotmail.com> writes:
Paolo> Still I have this problem that I think even a Perl newbie can
Paolo> help me with. I've looked at some perl-scripts and I think
Paolo> that what I have to accomplish is easy to be done.
Paolo> I have to collect some data from an ASP-page, giving my userid and password
Paolo> that looks
Paolo> like this :
Paolo> http://www.somefirm.com/download.asp?ID=userid&PWD=pw
Paolo> I would like to save the information it returns as a .txt-file.
use LWP::Simple;
getstore("http:/...", "file.txt");
LWP::Simple is in LWP, available in the CPAN.
--
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: Tue, 25 May 1999 13:03:35 GMT
From: smnayeem@my-dejanews.com
Subject: anyone knows if theres any bug with my code?
Message-Id: <7ie737$pek$1@nnrp1.deja.com>
i am trying to implement the lcs (longest common subsequence) algorithm
using perl, but perl seems to be acting strangely in some cases. If
anyone can let me know if theres anything i might have overlooked.
heres my code :
# usage lcs \@A, \@B
# returns the count of matched operators.
# this function compares two strings and returns the resultant sequence
match
sub lcs {
local ($A, $B) = @_; #$A and $B are the two arrays to be compared.
my $i, $j, @X, @Y;
my $m = $#$A; $n = $#$B;
for ($i = $m; $i >= 0; $i--) {
for ($j = $n; $j >= 0; $j--) {
if ($$A[$i+1] eq $$B[$j+1])
{$X[$j] = 1 + $Y[$j+1];}
else
{$X[$j] = max($Y[$j],$X[$j+1]);}
}
@Y = @X;
}
return $X[0];
}
# returns the maximum of two values.
sub max {
return $_[0] ge $_[1] ? $_[0] : $_[1];
}
# this function takes in two arrays of strings and returns a percentage
(1-100)
# representing the difference between the two strings.
sub percent {
local ($A, $B) = @_;
$lenA = $#$A+1;
$lenCommon = lcs(\@A, \@B);
print $lenCommon,"\n";
return (1-($lenCommon/$lenA))*100
}
##### BEGIN #####
@A = split(//," this file isnt working nicely 21/06/1999");
@B= split(//,"this file isnt working nicely 21/06/1999");
$percent = percent(\@A, \@B);
print $percent;
# this will print the percentage of difference between the two files.
if you try to remove the leading space from the @A array and make some
modification further into the program it gives a more accurate output.
by the way heres the link i got the algorithm from :
http://www.ics.uci.edu/~eppstein/161/960229.html
please let me know if possible, where i might have gone wrong thanks :)
smnayeem
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 25 May 1999 12:20:52 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: Bookmarking Favorites in Word
Message-Id: <374a95a4.0@news.new-era.net>
aidancurrie@hotmail.com wrote:
> Hey there,
> I was hoping somebody could give me some desparatel needed direction...
> I have a five chapter word document saved as html. I would like to make
> it so that when I open the doc in my browser, the five chapters
> automatically appear in my Favorites menu.
> Does anyone know how I could do this??!
Your favorites is a folder. It's in the Windows directory, under
Profiles\YourUserName\Favorites. The shortcuts are .URL files, which
if I remember correctly are just regular shortcuts (.LNK) with a .URL
extension.
You should be able to use Win32::Whatever to add shortcuts in the
directory -- or if you're like me and were around long before Win32::*
came out, use your command-line shortcut program from the Win95/8 CD.
Scott
------------------------------
Date: 25 May 1999 07:12:14 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Don't understand ctime / stat[10]
Message-Id: <374aa1ae@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, gerg@shell1.ncal.verio.com (Greg Andrews) writes:
:Not on the Unix systems I've used. Just tested it on UFS filesystems
:on Solaris 2.x and FreeBSD. Reading the file updates the atime only.
:Else the distinction between atime and ctime would be meaningless.
You're right. Interesting.
--tom
--
At MIT the server is the unit of invention. --Rob Pike
------------------------------
Date: Tue, 25 May 1999 12:17:52 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <pudge-2505990817530001@192.168.0.77>
In article <37474364@cs.colorado.edu>, tchrist@mox.perl.com (Tom
Christiansen) wrote:
# :For those of you wanting to know more about the Perl Y2K booby-trap code
# :problem, check out:
# :
# :http://www.y2kinfo.com/journal/features/0499_amona.html
#
# You expect us to take seriously a document that refers to "CGI" as a
# language and goes on to claim this CGI language's localtime function
# has a problem? Oh please.
Wow, part of that article is pretty bad. Take this:
> One of the booby-trap languages listed is MacPerl, a language used on
> Apple Macintosh computers. While it is true that Apple hardware does not
> have the same internal clock problems as the industry standard PCs, any
> software is just as likely to have year 2000 software problems. MacPerl
> applications are just as likely to be booby-trapped as applications
> written in the other affected languages.
First, MacPerl is not a language, but a program that runs under Mac OS
that implements the Perl language. Second, the set of affected computers
is not "Apple Macintosh" computers, but a siginificantly larger set of
computers: those running Mac OS. This includes computers manufactured by
a dozen different manufacturers.
The author is just very imprecise. And I love this:
> Other definitions include "the number of years since 1900" and similar
> phrases. Programmers may assume that this is the technical wording for
> "the last two digits of the year", especially since we are accustomed to
> writers of technical manuals giving obscure explanations instead of
> simple answers.
I don't see how a programmer may assume that. It is not what is written.
There is only one possible interpretation of "the number of years since
1900", and that interpretation mandates that for the year 2000, the
function will report 100 as the year. The only way a programmer may
assume something else is if the programmer cannot read well or believes
the documentation is lying.
> The knee-jerk reaction that this subject often provoked was unexpected
> and alarming. A common response was "Problem? What problem?" from
> programmers who understood the correct use of year values but who were
> reluctant to concede that their language could cause any year 2000
> problem.
But it is NOT the language, it is the programmer. The language when used
as documented won't give any problems with the year 2000. Yes, you can
have code that will break in the year 2000 with Perl and C. No, it is not
the language causing the problem, it is the ignorant programmer.
Then again, how can we trust anything published by EarthWeb in the first
place? :D
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Tue, 25 May 1999 08:35:27 -0400
From: digital kensai <kensai@nortel.com>
Subject: Re: finding min in hash of hashes
Message-Id: <374A990F.95287ABF@nortel.com>
Here's an example of how to do it... this isn't at all optimized, it is
written to make it easy to show you how.
#!/usr/bin/perl -w
use diagnostics;
use strict;
my (%test, $key, $smallest);
#I'm going to be looking for smallest "m" from the below hash
%test = (
"A" => { "m" => 0, "n" => 1 },
"B" => { "m" => 1, "n" => 2 }
);
#for every nested hash
foreach $key (keys %test){
#informational
print ref($test{$key}) . " $key: ";
print %{$test{$key}}->{"m"} . "\n";
#if we have a candidate "smallest" m, we need
# to check that this m is not smaller ...
if($smallest){
$smallest = $key
if(%{$test{$key}}->{"m"} < %{$test{$smallest}}->{"m"});
## the notation used here breaks down:
## $test{$key} points is the nested hash's reference.
## %{$test{$key}} is the nested hash.
## ->{"m"} says give me the subscript (element) of the left-hand
## value (%{$test{$key}}), which is fairly clear notation (who'd want
## to say something like ${$test{$key}}{"m"}, anyway?)
#otherwise, we have no candidate m, so we'll
# gladly accept this one. (ie, the first nested hash)
}else{
$smallest = $key;
}
}
print "\n\nSMALLEST HASH: $smallest (value " .
%{$test{$smallest}}->{"m"} . ")\n\n";
Diarmuid Collins wrote:
> Hi,
> I have created a hash of hashes something like :
> %HoH = (
> 0 => {
> size => '2',
> type => 'a',
> },
> 1 => {
> size => '3',
> type => 'a',
> },
> 2 => {
> size => '1',
> type => 'a',
> },
> 3 => {
> size => '1',
> type => 'a',
> },
> );
>
> now what I'm trying to write is a subroutine that finds the hash with
> the smallest size? Any ideas. I have been messing around with sorts
> but it's driving me mad and I can't find anything in the FAQ..
>
> Diarmuid
>
> --
> Diarmuid Collins | +353-1-2185544
> Silicon & Software Systems Ltd | dcollins@s3two.ie
------------------------------
Date: Tue, 25 May 1999 12:48:36 GMT
From: dave@dave.org.uk (Dave Cross)
Subject: Re: Finding the date...
Message-Id: <374a9bde.73700175@news.demon.co.uk>
On Tue, 25 May 1999 07:41:51 GMT, dave@dave.org.uk (Dave Cross) wrote:
>On Mon, 24 May 1999 20:10:56 -0400, nick <nick@auger.net> wrote:
>
>>How can I find what day it was 7 days ago? If I use $day =
>>(localtime(time))[3];, I can get todays date, and subtracting 7 from it
>>will give me the date 7 days ago. But what if it is the 5th, then after
>>subracting 7, it will give me -2. Is there an easy way to do this? Or
>>am I gonna have to create a whole subroutine? Thanks in advance for
>>help.
>
>The Date::Manip module from CPAN <http://www.cpan.org> will allow you
>to do all of those kinds of things very easily.
>
>If you're stuck with the standard Perl distribution than this snippet
>of code will add (or subtract) a given number of days from the current
>date and time.
>
>use Time::Local;
>
>my $delta; # Number of days to add or subtract (-ve for substractions)
>my @now = localtime;
>my @then = @now;
>
># Adjust to midday to avoid errors with DST
>@then[0 .. 2] = (0, 0, 12);
>my $then = timelocal(@then[0 .. 5]);
>
># Add or subtract the relevant number of days
>$then += ($delta * 23 * 60 * 60);
>
>@then = localtime($then);
># Restore original time
>@then[0 .. 2] = @now[0 .. 2];
>
>At the end of this code, @then will contain all of the various parts
>of the the data and time as you would get from localtime.
>
>Dave...
Obviously the '23' for the number of hours in a day was a deliberate
error I threw in there to make sure you didn't just cut and paste the
code without understanding it... er... or something :-(
Dave...
--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>
------------------------------
Date: Tue, 25 May 1999 03:53:35 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help on openiong and manipulating files
Message-Id: <vtkdi7.itj.ln@magna.metronet.com>
Reese Butler (reese@value.net) wrote:
: Im triying to open a simple .txt file and store txt into variables
: using code from a tutorial book that goes like so
^^^^^^^^^^^^^^^^^^^^
If this is the real code, then you have a piss poor book.
Sorry.
: #!/usr/bin/perl
You should *always* enable warnings:
#!/usr/bin/perl -w
: print "Content-type: text/html\n\n";
: open(dbtest, "http://www.server.com\Hank\db.txt");
1)
You should *always* check the return value from open():
open(dbtest, 'http://www.server.com\Hank\db.txt') ||
die "could not open 'http://www.server.com\Hank\db.txt' $!";
2)
You open *files* with open().
You fetch WWW pages with LWP::Simple:get().
3)
Do you know what happens to backslashes in double quoted strings?
4)
You should use UPPER CASE for filehandles.
: select(dbtest);
That statement serves no function in this program.
: while (<dbtest>) {
: chop;
chomp() is *much* better that chop() for what you are using it for.
Is your book a Perl 4 book?
: ($item, $price) = split(/:/,$_,2);
: $price_list{item} = $price;
^^^^
^^^^ are you missing a dollar sign there?
: }
: close ( dbtest );
: this much of the code works,
I doubt that very very much.
I think you are lying to us...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 May 1999 08:53:24 -0400
From: digital kensai <kensai@nortel.com>
Subject: Re: Help Requested with PERL script
Message-Id: <374A9D44.9EBA6CB5@nortel.com>
this script will divide the page up for you ... I don't know/have
installed Net::SMTP to add that part to the script, but from what I gather
on my favorite CPAN site, it wouldn't be much work to send the mail while
you're building the file.... (you'd need to get the Net::SMTP module to
run such a solution anyway)
Write me if you need help debugging this script (otherwise, I'll assume it
worked . ;)
David Winet wrote:
> I need to cut up a large file of email addresses into smaller files,
> then send each smaller files to each of the addresses it contains.
> (I'm trying to break up a large online class into dicussion groups this
> way)
> Any help appreciated! My PERL skills are limited to modifying not
> creating scripts. Thanks!
> dwinet@transbay.net
#!/usr/bin/perl -w
$USAGE = "usage thisscript.pl myfile #lines/file (eg, thisscript.pl myfile
100)";
die $USAGE unless ((-e $ARGV[0]) && ($ARGV[1] =~ /\d+/));
open(IN, $ARGV[0]) or die $!;
open(OUT, ">$ARGV[0].out$count") or die $!;
while(<IN>){
$line = $_;
if($a == $ARGV[1]){
$count++;
$a = 0;
close OUT;
open(OUT, ">$ARGV[0].out$count") or die $!;
}
print OUT $line;
$a++;
}
close IN; close OUT;
------------------------------
Date: Tue, 25 May 1999 13:19:16 GMT
From: John Porter <jdporter@min.net>
Subject: Re: How to use "system" with csh ??
Message-Id: <7ie80h$q0m$1@nnrp1.deja.com>
In article <374A7922.D99E3B6D@awi-bremerhaven.de>,
abelem@awi-bremerhaven.de wrote:
>
> my $SWscript = "/bios4/user1/HAWI/SWl01/runl1a"; # full name of runl1a
> script
> my $L0dir = "/bios4/user1/HAWI/L0/";
> my $namelev0 = "S1999077105755.L0_HAWI";
>
> system("$SWscript $L0dir.$namelev0");
This will call system() with an argument of:
/bios4/user1/HAWI/SWl01/runl1a
/bios4/user1/HAWI/L0/.S1999077105755.L0_HAWI
That's not what you said it should be: it has an extra dot in it.
Where do you suppose that came from?
(Hint: the dot concatenation operator does not work inside quoted
strings.)
(Sorry for the linewrapping; Deja's "newsreader" is awful.)
--
John Porter
Put it on a plate, son. You'll enjoy it more.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 25 May 1999 03:56:39 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Interesting question
Message-Id: <n3ldi7.itj.ln@magna.metronet.com>
billy_collins@my-dejanews.com wrote:
: I was asked by one of my clients today if it is possible to prevent a
: web page from being printed, or cut/pasted from. Is this possible?
No.
: Apologize for the cross posting but I definitely think that this is a
: great question and the answers would be highly appreciated.
It may be a great question, but it is still off-topic.
Please don't make off-topic posts. It will only get you killfiled.
clpmisc is not a WWW newsgroup, so we don't care about your great
question. Folks in a WWW newsgroup might though...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 25 May 1999 13:33:07 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Interesting question
Message-Id: <7ie8qk$qpg$1@nnrp1.deja.com>
In article <7ida7n$5fd$1@nnrp1.deja.com>,
billy_collins@my-dejanews.com wrote:
> Apologize for the cross posting but I definitely think that this is a
> great question and the answers would be highly appreciated.
Great question? Not in comp.lang.perl.misc. Get a clue.
--
John Porter
Put it on a plate, son. You'll enjoy it more.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 25 May 1999 06:30:46 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: need an anti-leech script
Message-Id: <374a7bc9.0@usenet.fccj.cc.fl.us>
In article <Pine.LNX.3.96.990525101032.2759A-100000@deadlock.et.tudelft.nl>,
Henjo <henjo@deadlock.et.tudelft.nl> wrote:
> Hi all,
>
> I'm constantly losing bandwidth because other people are linking directly
> to my files.
> Can anyone give me a script which prevents this?
> I've already searched on the net, but couldn't find anything free/working.
>
> Or at least give me some hints on how to achieve this, so maybe I can
> write it myself.
>
> Thanks!
Definitely a web server issue, did you ask in a Web server group?
This isn't a perl question; you should really consider
using Apache, and if you are, then you should really
consider learning about Apache.
HTH
-Sneex- :]
______________________________________________________________________
Bill Jones Data Security Specialist http://www.fccj.org/cgi/mail?dss
______________________________________________________________________
We are the CLPM... Lower your standards and surrender your code...
We will add your biological and technological distinctiveness to
our own... Your thoughts will adapt to service us...
...Resistance is futile...
Jacksonville Perl Mongers
http://jacksonville.pm.org
jax@jacksonville.pm.org
------------------------------
Date: 25 May 1999 07:24:21 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: need an anti-leech script
Message-Id: <374aa485@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, Henjo <henjo@deadlock.et.tudelft.nl> writes:
:I'm constantly losing bandwidth because other people are linking directly
:to my files.
:Can anyone give me a script which prevents this?
Remove the files:
perl -e 'unlink @ARGV' file1.html file2.html file3.thml
If you don't want people accessing them, don't put them up!
--tom
--
Perl has grown from being a very good scripting language into something
like a cross between a universal solvent and an open-ended Mandarin
where new ideograms are invented hourly. --Jeffrey Davis
------------------------------
Date: Tue, 25 May 1999 13:28:06 GMT
From: John Porter <jdporter@min.net>
Subject: Re: need an anti-leech script
Message-Id: <7ie8h3$qeo$1@nnrp1.deja.com>
In article
<Pine.LNX.3.96.990525101032.2759A-100000@deadlock.et.tudelft.nl>,
Henjo <henjo@deadlock.et.tudelft.nl> wrote:
>
> I'm constantly losing bandwidth because other people are linking
directly
> to my files.
> Can anyone give me a script which prevents this?
And your Perl question is...?
You might try checking the 'Referer' header (which in CGI is usually
the HTTP_REFERER environment variable), and deny the service to any
referer which is not on your own site.
--
John Porter
Put it on a plate, son. You'll enjoy it more.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 25 May 1999 07:50:20 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: need an anti-leech script
Message-Id: <374aaa9c@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, John Porter <jdporter@min.net> writes:
:You might try checking the 'Referer' header (which in CGI is usually
:the HTTP_REFERER environment variable), and deny the service to any
:referer which is not on your own site.
That's rude. Fortunately, it's trivial to spoof. Anybody who relies on
the referrer is silly. If he doesn't want it viewed, he should remove
it from the net.
--tom
--
If I had only known, I would have been a locksmith. --Albert Einstein
------------------------------
Date: Tue, 25 May 1999 13:05:50 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: parent directories
Message-Id: <ebohlmanFCAHpq.G7v@netcom.com>
Tim Shapcott <tim.shapcott@NOSPAMvirgin.net> wrote:
: However, I now have a new problem. I get a return from the host saying the
: page requested does not exist on the server. If you want to have a look, go
: to www.moreno-band.freeserve.co.uk and click on the geustbook button in the
: navbar, the on sign guestbook in the main page area.
: I think the problem is due to specifying a parent directory in the script; i
: am not sure how to do this, so it probably isn't right.
: $directory_gbook = "../guestsv.html";
: $guestbook = "../guestsv.html";
: $cgi = "/guest.cgi";
: The script is obviously in cgi-bin, but guestsv.html is up one level. The
: way to do it in HTML is ../ but it doesn't seem to work here.
: Any suggestions?
In CGI programs, it is unsafe to use anything but an absolute path to
refer to a filename. The current directory that a Web server gives a
program is very often *not* what you think it is.
Note that the use of ".." in URLs is *not* the same as its use in file
paths. ".." in a URL is intended to be interpreted by the *user agent*
(such as a browser) and *not* the server. The meaning of
"../mystuff.html" is that the user agent should request the URL created
by stripping off the last path component from the base URL and appending
"mystuff.html." URLs are *not* filenames!
------------------------------
Date: 25 May 1999 08:26:33 -0400
From: Matt Curtin <cmcurtin@interhack.net>
Subject: Re: Perl in the News: _Cryptonomicon
Message-Id: <xlxemk5e3nq.fsf@gold.cis.ohio-state.edu>
>>>>> On 24 May 1999 12:36:47 -0700,
Tom Christiansen <tchrist@mox.perl.com> said:
Tom> Decks are 54 cards, not a half-dozen. Or do I misunderstand you?
Ace-King * ( hearts, clubs, diamonds, spades ) = 13 * 4 = 52.
Or am I confused? (Including jokers, maybe?)
--
Matt Curtin cmcurtin@interhack.net http://www.interhack.net/people/cmcurtin/
------------------------------
Date: 25 May 1999 07:13:15 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl in the News: _Cryptonomicon
Message-Id: <374aa1eb@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, Matt Curtin <cmcurtin@interhack.net> writes:
:Ace-King * ( hearts, clubs, diamonds, spades ) = 13 * 4 = 52.
:Or am I confused? (Including jokers, maybe?)
Yes. The two jokers are important to the algorithm.
--tom
--
"Sometimes I wish I could put an expiration date on my quotes." --Larry Wall
------------------------------
Date: Tue, 25 May 1999 13:42:32 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: Perl in the News: _Cryptonomicon
Message-Id: <7ie9c8$r77$1@nnrp1.deja.com>
In article <xlxemk5e3nq.fsf@gold.cis.ohio-state.edu>,
Matt Curtin <cmcurtin@interhack.net> wrote:
> >>>>> On 24 May 1999 12:36:47 -0700,
> Tom Christiansen <tchrist@mox.perl.com> said:
>
> Tom> Decks are 54 cards, not a half-dozen. Or do I misunderstand you?
>
> Ace-King * ( hearts, clubs, diamonds, spades ) = 13 * 4 = 52.
>
> Or am I confused? (Including jokers, maybe?)
>
Indeed.
If you refer to the article under discussion, the algorithm described
requires a deck of cards with two distinguishable jokers.
--
Don Roby
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 25 May 1999 13:09:12 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Perl Newbie
Message-Id: <7ie7dn$pih$1@nnrp1.deja.com>
In article <374a8136.131864454@24.2.68.71>,
legodude@home.net (mike dombrowski) wrote:
>
> if(!(($xartist eq "") || ($xsongname eq ""))){
Any time you're negating the entire sense of the test, as you are
doing here, you can replace if(!...) with unless(...).
However, in this case, I would reverse the sense of the equality
tests, and change the 'or' to 'and':
if ( $xartist ne '' && $xsongname ne '' ) { ...
> $mike = $xartist . "--" . $xsongname . ".mp3";
> $mike =~ s/\ /\-/g;
Spaces are always taken literally as part of the pattern*, so you
don't accomplish anything by backwhacking them. Same goes for the
replacement text on the right. So do this:
$mike =~ s/ /-/g;
(*except for /x, but never mind that for now.)
> #$mike =~ s/ ' | ` | & | : | ? /_/g;
Now that you know that spaces are literally part of the pattern,
you don't want them here. So:
$mike =~ s/'|`|&|:|?/_/g;
Now, you have a kind of special case here: all the alternatives are
single characters. So it might be nicer to use a character class
instead of alternation in the match pattern. That would look like
this:
$mike =~ s/['`&:?]/_/g;
Now we're all set for a major optimization: use tr/// instead of s///g:
$mike =~ tr/'`&:?/_/;
This makes "fo:ob?ar" become "fo_ob_ar",
and "foo?:bar" becomes "foo__bar".
If you want resulting sequences of multiple underscores to be squeezed
down to a single one, add the /s option:
$mike =~ tr/'`&:?/_/s;
This makes "foo?:bar" become "foo_bar".
If you want to get rid of these undesirable characters altogether,
without being replaced by anything, use the /d option instead:
$mike =~ tr/'`&:?//d;
This makes "foo?:bar" become "foobar".
Read perldoc perlop for more info on the s/// and tr/// operators,
and perldoc perlre for more info on regular expressions (patterns).
--
John Porter
Put it on a plate, son. You'll enjoy it more.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Tue, 25 May 1999 07:40:11 -0400
From: digital kensai <kensai@nortel.com>
Subject: Re: PERLFUNC: unshift - prepend more elements to the beginning of a list
Message-Id: <374A8C1B.2C9DE741@nortel.com>
David Cantrell wrote:
> On 25 May 1999 01:54:25 -0700, Tom Christiansen
> <perlfaq-suggestions@perl.com> enlightened us thusly:
>
> >This excerpt is from the perlfunc manpage ...
>
> Tom, can you please stop posting these? I am beginning to find these
> posts far more annoying than the newbies' FAQs. And it's not
> preventing them from wasting our time.
I dunno... I was kinda hoping he'd hit things like bless, tie, or fork,
myself (and send more than just the perldoc page, as they are totally
useless for these functions).
Anyways, some of these little "gems" are wonderful resourses -- some1
just asked "are there dynamic arrays in perl?" the other day (I know, I
took the time to demonstrate it in responce), and now there's the
perldoc for unshift in the newsgroup...
I'm imagining that guy reading through, seeing the responces to his own
question, and then sees unshift (the context of the question assumes the
asker has knowledge of push/pop/shift routines), so there's further
reference available to him right in the newsgroup, right away. I
certainly have no problem answering questions I've already been so lucky
to 'grok', and in that spirit, these posts are pretty cool. (keep it up,
Tom!)
> [Copying newsgroup posts to me by mail is considered rude]
>
> --
> David Cantrell, part-time Unix/perl/SQL/java techie
> full-time chef/musician/homebrewer
> http://www.ThePentagon.com/NukeEmUp
------------------------------
Date: Tue, 25 May 1999 06:36:07 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: Pigheadedness (was Re: Newbie; Perl/Tk Event models)
Message-Id: <374a7d0a.0@usenet.fccj.cc.fl.us>
In article <MPG.11b3d307851cfdfd989aeb@nntp.hpl.hp.com>, lr@hpl.hp.com
(Larry Rosler) wrote:
> That godforsaken code *could* be:
>
> $century = $year > 99 ? 20 : 19;
> $string = sprintf <<"eop", $year % 100, $hour, $min, $sec;
> It is $day, $month $mday, $century%02d %02d:%02d:%02d
> eop
>
> And we all know what it *should* be.
>
Definitely starting to fall into the
"How hard can we possibly make things?"
Category...
-Sneex- :]
______________________________________________________________________
Bill Jones Data Security Specialist http://www.fccj.org/cgi/mail?dss
______________________________________________________________________
We are the CLPM... Lower your standards and surrender your code...
We will add your biological and technological distinctiveness to
our own... Your thoughts will adapt to service us...
...Resistance is futile...
Jacksonville Perl Mongers
http://jacksonville.pm.org
jax@jacksonville.pm.org
------------------------------
Date: Tue, 25 May 1999 13:31:46 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Printers
Message-Id: <7ie8o2$qop$1@nnrp1.deja.com>
In article <374a2286.17862049@news.chaven.com>,
amerar@unsu.com (Arthur Merar) wrote:
>
> Everything is talking fine except the Linux box and the printer. The
> printer does not seem to have an IP address. Rather it has a network
> name and hardware address......since I think Windows 98 uses the
> Client for Netware Networks and stuff.
And you somehow thought this was a Perl question?
--
John Porter
Put it on a plate, son. You'll enjoy it more.
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5771
**************************************