[8811] in Perl-Users-Digest
Perl-Users Digest, Issue: 2428 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 27 12:07:14 1998
Date: Mon, 27 Apr 98 09:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 27 Apr 1998 Volume: 8 Number: 2428
Today's topics:
Re: "Slurp"? (Mark-Jason Dominus)
Re: 'each' and recursion, do they mix? (Mark-Jason Dominus)
Re: 'each' and recursion, do they mix? (Mark-Jason Dominus)
ANNOUNCE: Authen::ACE 0.90 - Perl interface to SecurID <Dave.Carrigan@iplenergy.com>
Available: Perl tools for Bayesian inference <ihh@sanger.ac.uk>
Re: convert an @array into a single $variable? <jim.michael@gecm.com>
Re: convert an @array into a single $variable? (M.J.T. Guy)
Re: Hello people, want to learn Perl ? <merlyn@stonehenge.com>
Re: Help! FCNTL Problems: Solaris 2.6 (M.J.T. Guy)
Re: help...can't rcp a file to another machines (Abigail)
Re: http Reg Exp (Abigail)
Re: http Reg Exp <jdf@pobox.com>
Re: Memory Leak? Embedding into C panning@thomtech.com
Re: o-modifier <jdf@pobox.com>
Re: Parsing HTML ... (Abigail)
Re: Print Currency (Mark-Jason Dominus)
Re: Reg Exp problem (Abigail)
REQ: Win32 POP3 client (Joel Rubin)
Re: RFI: Counting repeated substrings within a string (Abigail)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 27 Apr 1998 11:51:20 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: "Slurp"?
Message-Id: <6i29ho$ghn$1@monet.op.net>
Keywords: gander Hausdorff mountainous trio
In article <ogxnla05.fsf@jimmer.charm.net>, root <jimmer@charm.net> wrote:
>I vaguely remember seeing a technique once where an entire input file
>is read in with a single command, carriage returns and all.
{ local $/ = undef;
$file = <FILEHANDLE>; # slurp
}
------------------------------
Date: 27 Apr 1998 11:03:00 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <6i26n4$g3o$1@monet.op.net>
Keywords: fractious Grayson multiplication pug
In article <6hl8ia$99d$1@aurwww.aur.alcatel.com>,
John Klassa <klassa@aur.alcatel.com> wrote:
>I was just looking at the man page for "each" and noticed the phrase
>"single iterator for each hash, shared by all each(), keys(), and values()
>function calls in the program"... Can one of the p5p folks elaborate on
>this? I'm sure there's a sound technical reason, but it's not readily
>apparent to me.
I just wrote a long article about why it is this way,and the executive
summary is: If there's any sound technical reason at all for doing it
any other way, it's not apparent to *me*. Your question is sort of
like asking why office buildings are not made out of peanut butter.
``I'm sure there's a sound technical reason, but...''
Well, here's my attempt to explain.
0. The iterator is part of the hash data structure. That means it's
associated with the hash variable itself. That's a natural place
to put it. It's simple, easy, and obvious. It leads to
easily-explained semantics. In fact it's so obvious, I'm not sure
anyone ever thought of doing it a different way.
1. Having the iterator state associated with the variable might cause
someone a problem if they want changes to the hash to be local to
some scope.
Big deal. Sometimes that's what you want, sometimes it isn't.
Having the iterator associated with the hash, and not with some
lexical scope, means that you can have two unrelated functions or
scopes that advance the same iterator. That's sometimes useful too.
2. Having the iterator be anywhere else would probably be very
difficult to implement. Consider this:
sub x {
my $hashref = shift;
return each %$hashref;
}
This subroutine, and any other subroutine like it, would
potentially have to keep track of one iterator for every single
hash in the program. When you passed in a hash ref, it would have
to find the right private iterator and bump it up by one.
Where will these iterators be stored? They have to be associated
with the function, and keyed to the hash variables somehow. There
might be a lot of them.
3. If iterators are going to be lexical instead of variable-
associated, you have to worry about something like this:
sub x {
my ($k1, $v1) = each %hash;
... something ...
my ($k2, $v2) = each %hash;
... something else ..
}
Now one day, someone comes along and adds a loop to the second
part:
sub x {
my ($k1, $v1) = each %hash;
... something else ...
foreach $i (1, 2, 3) {
my ($k2, $v2) = each %hash;
... something else ..
}
}
Suddenly the program breaks. The two `each'es are no longer in the
same scope, so they no longer access the same iterator. That would
suck.
I think any further discussion of this should probably be accompanied
with a specific proposal of how you think it should work instead.
------------------------------
Date: 27 Apr 1998 11:30:46 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: 'each' and recursion, do they mix?
Message-Id: <6i28b6$gdj$1@monet.op.net>
Keywords: Bambi contiguous manse Pembroke
In article <VA.000000a4.0f7c0ed0@jll>, Jean-Louis Leroy <jll@skynet.be> wrote:
> Ilya says:
>> First choice is the current one, the other two will give non-intuitive
>> behaviour in *most* of the cases.
>
>Hmm, could you give example(s)?
I gave an example elsewhere in this thread of a case where moving a
statement into a foreach loop would break it:
sub z {
my ($k1, $v1) = each %hash;
... do something ...
my ($k2, $v2) = each %hash;
... do something else ...
}
Now someone decides that the second part of the function needs to
repeat a few times, so that the function processes four keys each call
instead of two:
sub z {
my ($k1, $v1) = each %hash;
... do something ...
for $i (1,2,3) {
my ($k2, $v2) = each %hash;
... do something else ...
}
}
Unfortunately, this drastically alters the behavior of the program.
The second `each' has moved into a different scope, so it uses a
different iterator. This is exactly what the language designer should
never do.
>> And then you suddently discover that you need to know what to do
>> with iterator if the hash changes...
>
>We could simply say, ` la Camel p. 159: "You must not add elements to
>the hash while there exist iterators on it".
What do you mean, `while there exist iterators'? I think you've
really missed the point here.
sub x {
my $href = shift;
my ($k, $v) = each %$href;
return $k;
}
my %hash = qw(a 1 b 2);
my $k = x(\%hash); # Get first key.
my $k = x(\%hash); # Get second key.
$hash{c} = 3; # ``NOT ALLOWED''
Why is it not allowed? Because `x' still has an iterator for the hash.
But x will *always* have an iterator for the hash.
So what happens now?
* Modifying a hash somehow tracks down all the extant iterators and
updates them? Slow, difficult (or impossible), and it has to be
done every time *any* hash is updated). You would probably be
very unhappy with the results anyway.
* x dumps core next time you call it? Well, this could probably be
avoided. But you can't rule out this possibility.
* x returns some random hash key next time you call it? Isn't that
just what you wanted to avoid? What benefit were we going to get
here, exactly?
* Or are you saying that once you've used `each' on a hash, you're
`not allowed' to modify it again?
Hmmm?
Please don't say that the iterator is destroyed when it goes out of
scope. If that were the case, then x would always return the first
key from the hash, and never anything else:
sub x {
my $href = shift;
my ($k, $v) = each %$href;
return $k;
}
my %hash = qw(a 1 b 2);
my $k = x(\%hash); # Get first key.
my $k = x(\%hash); # Get same key as before.
my $k = x(\%hash); # Get same key again.
------------------------------
Date: 27 Apr 1998 15:24:20 GMT
From: Dave Carrigan <Dave.Carrigan@iplenergy.com>
Subject: ANNOUNCE: Authen::ACE 0.90 - Perl interface to SecurID
Message-Id: <6i27v4$b93$1@news.neta.com>
Announcing the first alpha release of Authen::ACE
Authen::ACE is a Perl interface to Security Dynamics' SecurID ACE/Client
API. With Authen::ACE, it is possible to enable SecurID authentication
with any Perl application.
This release is still considered alpha. While it is stable in our
environment (Solaris 2.5.1+, perl 5.004_03+, ACE/Server 3.0.1), that is
the only environment that it has been tested in. The purpose of this
release is to allow other SecurID users to try it in their environment,
so that I can broaden the scope of the testing.
The latest version of Authen::ACE is available at your nearest CPAN
archive, or at ftp://ftp.iplenergy.com/pub/perl/. All bug reports and/or
suggestions for improvement are welcome.
--
Dave Carrigan, Technology Integration | Yow! Hey, waiter! I want a NEW
IPL Technical Services | SHIRT and a PONY TAIL with lemon
Interprovincial Pipe Line Inc. | sauce!
Edmonton, Alberta, Canada |
------------------------------
Date: 27 Apr 1998 15:25:14 GMT
From: Ian Holmes <ihh@sanger.ac.uk>
Subject: Available: Perl tools for Bayesian inference
Message-Id: <6i280q$ban$1@news.neta.com>
Some very basic perl command-line scripts for Bayesian inference given
tabulated log-likelihood data can be found at:
http://www.sanger.ac.uk/Users/ihh/perl/Bayes.html
The scripts facilitate elementary tasks such as model comparison,
multiplication of data by priors, integration over parameter spaces and so
on.
More complete documentation of the tools can be found at the above URL.
Thanks,
Ian Holmes
Bioinformatics
The Sanger Centre
------------------------------
Date: Mon, 27 Apr 1998 10:43:15 -0400
From: Jim Michael <jim.michael@gecm.com>
Subject: Re: convert an @array into a single $variable?
Message-Id: <35449983.31DD@gecm.com>
Bryan T Hoch wrote:
>
> Hi, does any one know how to take the seperate elements of an
> array an pass them all as a string into a single variable?
> Thanks in advance.
> Bryan H
perldoc -f join
--
------------------------------
Date: 27 Apr 1998 15:21:28 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: convert an @array into a single $variable?
Message-Id: <6i27po$ebe$1@lyra.csx.cam.ac.uk>
In article <Pine.GSO.3.96.980427093122.14673A-100000@hercules.acsu.buffalo.edu>,
Bryan T Hoch <bth@acsu.buffalo.edu> wrote:
> Hi, does any one know how to take the seperate elements of an
>array an pass them all as a string into a single variable?
You want the join() function. See perldoc -f join.
Or you could just write
$scalar = "@array";
if you want the elements separated by spaces.
Mike Guy
------------------------------
Date: Mon, 27 Apr 1998 15:59:14 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
To: mm@c64.org (Mattias Pihlstrvm)
Subject: Re: Hello people, want to learn Perl ?
Message-Id: <8c90orjly0.fsf@gadget.cscaper.com>
>>>>> "Mattias" == Mattias Pihlstrvm <mm@c64.org> writes:
Mattias> I am working as a freetime WEBMASTER on www.c64.org, www.c64.com,
Mattias> www.c64.net and www.c64.nu
Mattias> I need some perl programmers to help me out, no money involved, just
Mattias> friendship, and doing things to learn from it.
Might be interesting to visit those sites in about two months and see
how many holes there are in the /cgi bin. :-)
You *definitely* don't want "first time perl people" hacking web scripts.
You don't. Trust me.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 127 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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: 27 Apr 1998 15:13:15 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Help! FCNTL Problems: Solaris 2.6
Message-Id: <6i27ab$e2i$1@lyra.csx.cam.ac.uk>
Duncan D. Sterling <buffalo@Radix.Net> wrote:
>I'm in the process of setting up the latest stable version of Perl
>on a Sun ultra 2 running Solaris 2.6.
>
>Perl seems to compile OK, but when I do a "make test" I see only
>an 83% success rate, with 21 tests failing.
>
>The most critical problem of them all is with fcntl, which is
>essential to most of the scripts I'm planning on transfering to this
>machine.
Since you didn't say what your configuration is or what the error was,
it's a little difficult to guess.
Did you read the section in the INSTALL file starting
=item Solaris and SunOS dynamic loading
If you have problems with dynamic loading using gcc on SunOS or
Solaris, and you are using GNU as and GNU ld, you may need to add
-B/bin/ (for SunOS) or -B/usr/ccs/bin/ (for Solaris) to your
$ccflags, $ldflags, and $lddlflags so that the system's versions of as
and ld are used.
?
It's also worth reading the comments in the Solaris hints file.
If these don't help, try posting again, this time including details of
the error and the output of ./myconfig, as suggested in the
"Reporting Problems" section of the INSTALL file.
Mike Guy
------------------------------
Date: 27 Apr 1998 14:58:37 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: help...can't rcp a file to another machines
Message-Id: <6i26et$72h$3@client3.news.psi.net>
David Waffen (dmwaff@erols.com) wrote on MDCXCVIII September MCMXCIII in
<URL: news:6htlsd$ntl$1@winter.news.erols.com>:
++
++ Syntax used: system ("rcp -p /Admin/Boneyard/LOGS/$user/.rm_usr.log
++ SERVER: /Users/$user");
Looks like valid Perl syntax to me.
If you have problems with your network configuration, or a non Perl
command, this groups is not the right place to ask.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: 27 Apr 1998 14:47:03 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: http Reg Exp
Message-Id: <6i25p7$72h$1@client3.news.psi.net>
Chris Lambrou (archive@cglis.com) wrote on MDCXCIX September MCMXCIII in
<URL: news:354346F0.CCC9CA0@cglis.com>:
++ Hello,
++
++ I'm writting a Perl based web interface for reading/sending email.
*boggle* Why would anyone want that?
++ $msg =~ s!(ftp|https?)://([^\s]+)!<a href="$1://$2">$1://$2<\/a>!gsi;
++
++ 90% this works. The problem is that the above will match text that
++ starts with
++ ftp/http/https followed by :// up to the next white space character,
++ so this breaks down if the URL is followed by a non word character such
++ as comma, a ">" or something else.
++
++ Any ideas how to fix it?
Sure.
$msg =~ s`
(?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.
)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)
){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F
\d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{
2}))|[;:@&=])*))*)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{
2}))|[;:@&=])*))?)?)|(?:ftp://(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?
:%[a-fA-F\d]{2}))|[;?&=])*)(?::(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-
fA-F\d]{2}))|[;?&=])*))?@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-
)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?
:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?))(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!
*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'()
,]|(?:%[a-fA-F\d]{2}))|[?:@&=])*))*)(?:;type=[AIDaid])?)?)|(?:news:(?:
(?:(?:(?:[a-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)))?)|(?:/(?:(?:(?:(?:(?:[a-zA-Z\d
\$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*)(?:/(?:(?:(?:[a-zA-Z\d\$\
-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*))*)?))|(?:(?:(?:(?:(?:[a-zA-
Z\d\$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*)(?:/(?:(?:(?:[a-zA-Z\d
\$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*))*)?)))
`<a href = "$&">$&</a>`xg;
See also <URL:http://cthulhu.mandrake.net/%7Eabigail/Perl/url2.html>
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: 27 Apr 1998 11:08:42 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: http Reg Exp
Message-Id: <emyjl01h.fsf@mailhost.panix.com>
abigail@fnx.com (Abigail) writes:
> $msg =~ s`
[snip]
> `<a href = "$&">$&</a>`xg;
ROTFL
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Mon, 27 Apr 1998 09:51:09 -0600
From: panning@thomtech.com
Subject: Re: Memory Leak? Embedding into C
Message-Id: <6i260t$l6d$1@nnrp1.dejanews.com>
In article <6h5f5h$osm$1@camel29.mindspring.com>,
"Scott" <sdh1@anchor.hotmail.com> wrote:
>
>
> Gurusamy Sarathy wrote in message <6h5a80$rqg@srvr1.engin.umich.edu>...
> > [ mailed and posted ]
> >
> >In article <6h3bkb$jm33@eccws1.dearborn.ford.com>,
> >Ken Fox <kfox@pt0204.pto.ford.com> wrote:
> >>BTW, I'm running 5.004_04 on SunOS 5.5.1 and if I do a tight loop
> >>of your original test() function it leaks like a sieve here too. My
> >>perl doesn't use MULTIPLICITY -- that might make a difference. Anybody
> >>know if the development track has this problem?
> >
> >5.004_65 should fix all known embedding leaks. Remember to set
> >C<perl_destruct_level = 1;> if you don't build perl with
> >-DMULTIPLICITY.
> >
> > - Sarathy.
> > gsar@umich.edu
>
> Sounds like a winner, but where do I get version 5.004_65? I checked on the
> www.perl.com
> web site and it isn't there.
>
> Thanks for your help....
> -Scott
I too have a memory leak when embedding perl in C! I am using perl5.004_02 on
Windows NT (obviously the mainstream port).
If I do something like
static PerlInterpreter *Interpreter;
int someFunction (void)
{
char* embedded[] = {"","someScript.pl"};
Interpreter = perl_alloc();
perl_construct(Interpreter);
perl_parse(Interpreter,xs_init,2,embedded,(char **)NULL);
perl_run(Interpreter);
perl_destruct(Interpreter);
perl_free(Interpreter);
}
Every time you run this it takes up a chunk of memory (the amount depends on
the complexity of the perl script). NB The above code is obviously
simplified, the real code has error checking etc.
Are there any workarounds that anyone knows of? I am loathed to use anything
but final release code as the above needs to run in a production environment!
Regards
Peter Anning
Senior Consultant Thomson Technology Consulting
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 27 Apr 1998 11:04:11 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: o-modifier
Message-Id: <g1izl090.fsf@mailhost.panix.com>
Jonathan Feinberg <jdf@pobox.com> writes:
> "Robert Friberg" <robban@it-konsult.com> writes:
> > Is there a more perlish equivalent of the following?
> >
> > $d{'max'} = $maxhits if $d{'max'} > $maxhits;
>
> That's how I'd do it.
If I were high. s/>/</;
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 27 Apr 1998 15:05:19 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Parsing HTML ...
Message-Id: <6i26rf$72h$4@client3.news.psi.net>
Anas Mughal (anas@erols.com) wrote on MDCXCIX September MCMXCIII in
<URL: news:6i06fb$map$1@winter.news.erols.com>:
++
++ Does anyone has a script to parse HTML?
Are you sure you would be able to use it? It might be too complicated.
After all, locating it on CPAN seems to be a task already too complicated
for you.
Abigail
--
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
print+Just (), another (), Perl (), Hacker ();'
------------------------------
Date: 27 Apr 1998 11:49:28 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Print Currency
Message-Id: <6i29e8$ggl$1@monet.op.net>
Keywords: chokeberry crappie deuce optometrist
In article <35449B3F.1609@min.net>, John Porter <jdporter@min.net> wrote:
>tanr@vancpower.com wrote:
>> What would be the easiest way to print a float number in a currency format
>> ($xx,xxx.xx)? Thanks!
> use Interpolation commify => 'commify';
> $gross = 666000.42;
> print "Total tax: \$$commify{ $gross * 0.28 } \n";
I personally might try this:
> use Interpolation '$' => 'commify';
> $gross = 666000.42;
> print "Total tax: \$$${ $gross * 0.28 } \n";
It does the same thing, but looks funnier.
Someone had a really delightful suggestion for a use for
`Interpolation' that I had not thought of before. They are using it
to escape character strings when they interpolate them into SQL
queries:
use Interpolation SQ => \&SQL_escape_single_quoted;
...
$query = join " AND ", map { "$_ = '$SQ{$field{$_}}'" } keys %field;
$db->query("select from $table where $query");
------------------------------
Date: 27 Apr 1998 15:17:58 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Reg Exp problem
Message-Id: <6i27j6$72h$5@client3.news.psi.net>
troxel@sammcgees.com (troxel@sammcgees.com) wrote on MDCXCIX September
MCMXCIII in <URL: news:6hu17m$3gh$1@nnrp1.dejanews.com>:
++ I am writing a site search engine that simple reads a directory and
++ returns a list of links to the html files that match an expression
++ along with the number of hits in each file.
++
++ Any pointers on an example or module that would help would be greatly
++ appreciated.
I think people who are not able to search CPAN should not be given
task that require more than 2 lines of code.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Mon, 27 Apr 1998 15:22:18 GMT
From: jmrubin@ix.netcom.com (Joel Rubin)
Subject: REQ: Win32 POP3 client
Message-Id: <3544a18f.6735615@nntp.best.ix.netcom.com>
I'd like to see an example of a POP3 client, written in Perl, which
takes mail from mail.mars.edu port 110, user john, pass abcde, and
dumps anything which has "cyberpromo.*" anywhere in the header and
puts all the other email in mail.txt.
It can work with either of the two free Perl 5 interpreters written
for Win32.
TIA.
=======
No honest business is promoted by spam
with the possible exception of Hormel.
------------------------------
Date: 27 Apr 1998 15:31:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: RFI: Counting repeated substrings within a string
Message-Id: <6i28bq$72h$7@client3.news.psi.net>
Ronald J Kimball (rjk@coos.dartmouth.edu) wrote on MDCXCIX September
MCMXCIII in <URL: news:3542CDC3.834331EE@coos.dartmouth.edu>:
++ [posted and mailed]
++
++ Alfred Landrum wrote:
++ >
++ > Hi,
++ >
++ > I'm working on a cryptology problem. I would like to create
++ > a perl script that will read in a cyphertext file, and find all
++ > repeated substrings within that file.
++ >
++ > Ex: An input of 'werasdwerasdwer' would return all of the times
++ > that 'wer', 'era', 'ras', 'asd' occured. (For the assignment, I'm just
++ > going to be looking at repeated patterns with 4 or more characters, then
++ > do some frequency study on the results to try and crack the cyphertext.)
++
++ How many more characters?
++
++ This one does up to the length of the entire string.
++
++ for ($pos=0; $pos <= length($_) - 4; ++$pos) {
++ for ($len=4; $len <= length($_) - $pos; ++$len) {
++ $substr = substr($_, $pos, $len);
++ next if exists $freq{$substr};
++ $freq{$substr} = () = /\Q$substr/g;
++ }
++ }
That would require a pretty big machine for any non trivial text.
If the length of the text is a few kilobytes, the number of subpatterns
will be counted in millions. Perl isn't the most suitable language for
the above algorithm.
Abigail
--
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
print+Just (), another (), Perl (), Hacker ();'
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2428
**************************************