[15830] in Perl-Users-Digest
Perl-Users Digest, Issue: 3243 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 3 14:10:23 2000
Date: Sat, 3 Jun 2000 11: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: <960055812-v9-i3243@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 3 Jun 2000 Volume: 9 Number: 3243
Today's topics:
Perl to write to a text file <choopark@prodigy.com>
Re: Perl to write to a text file <red_orc@my-deja.com>
Re: Perl vs Python for Numerical Analysis (Peter J Scott)
Predicted generation of ID numbers <webmaster@beautiful-ladies.com>
Re: Predicted generation of ID numbers (Bart Lateur)
Re: Predicted generation of ID numbers (David Efflandt)
Re: Predicted generation of ID numbers <red_orc@my-deja.com>
Re: relative paths to modules / libraries (Tad McClellan)
Re: REQ: bytewise string manipulation C style instead o (James W. Sandoz)
Re: REQ: bytewise string manipulation C style instead o (Gwyn Judd)
Re: REQ: bytewise string manipulation C style instead o <j.bessels@quicknet.nl>
Re: REQ: bytewise string manipulation C style instead o <dan@tuatha.sidhe.org>
using 'exists' in a program to test for keys in a hash <escaflowne@neo-tokyo.org>
Web Based E-mail Sorting System Required sg@sia.nu
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 3 Jun 2000 10:00:43 -0400
From: "Navneet Behal" <choopark@prodigy.com>
Subject: Perl to write to a text file
Message-Id: <8hb325$d26$1@newssvr03-int.news.prodigy.com>
Hi,
I have been developing some Multimedia work using Macromedia Flash and not
until quite recently have I had to tackle with Perl for the first time,
because of Flash. The Perl code actually makes a lot of sense since the
coding of Perl is quite similar to Action Script for Flash.
Here is what I am trying to achieve but failing miserably. I set up
variables in the Flash movie, just like I would in a HTML page. So let's say
a variable called Name and another Email is set up in Flash. Now, I can send
these variables to a CGI script which can process them and print out a HTML
page. But this is NOT what I want.. I want to print out a Text file which
would read something like this..
Name=Blah, Blah, Blah &Email=Blah, Blah
Then I can read those variables inside Flash to move on further within the
Flash environment. If it's not too much to ask could someone guide me in the
right direction.
Thank you for your time,
Navneet
mailto:navneetbehal@bigfoot.com
------------------------------
Date: Sat, 03 Jun 2000 14:36:07 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Perl to write to a text file
Message-Id: <8hb54n$i37$1@nnrp1.deja.com>
In article <8hb325$d26$1@newssvr03-int.news.prodigy.com>,
"Navneet Behal" <navneetbehal@bigfoot.com> wrote:
>
> Hi,
>
> I have been developing some Multimedia work using Macromedia Flash and not
> until quite recently have I had to tackle with Perl for the first time,
> because of Flash. The Perl code actually makes a lot of sense since the
> coding of Perl is quite similar to Action Script for Flash.
>
> Here is what I am trying to achieve but failing miserably. I set up
> variables in the Flash movie, just like I would in a HTML page. So let's say
> a variable called Name and another Email is set up in Flash. Now, I can send
> these variables to a CGI script which can process them and print out a HTML
> page. But this is NOT what I want.. I want to print out a Text file which
> would read something like this..
>
> Name=Blah, Blah, Blah &Email=Blah, Blah
>
open (FH, "/full/path/to/file/text.txt") || die "Cannot open text file\
n";
print FH "Name=Blah, Blah, Blah &Email=Blah, Blah";
close FH;
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 03 Jun 2000 16:24:46 GMT
From: peter@PSDT.com (Peter J Scott)
Subject: Re: Perl vs Python for Numerical Analysis
Message-Id: <ija_4.5813$F9.193051@news1.gvcl1.bc.home.com>
[Posted & mailed]
In article <MPG.13a18cb397a8ab0398ab1b@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> writes:
>I have been considering joining a team that is heavily into numerical
>analysis, specifically image processing. The leader of the team (who
>considers himself a physicist, not a programmer)
Been there :-)
> vigorously advocates
>Python, for the following reasons:
>
> Easier than Perl to integrate with C or C++.
> Better numerical-analysis support.
> Inherently object-oriented (multiple inheritance, operator
> overloading).
I do not understand this argument.
>I would appreciate help in understanding these issues. The 'Perl vs.
>Python' article
><URL:http://www.perl.com/pub/language/versus/python.html>
>was posted by Tom Christiansen on June 2, 1995 (Happy Fifth Birthday!),
>and can hardly be presumed to reflect current reality.
>
>I searched CPAN for numerical analysis modules, and couldn't find
>fundamental stuff, such as the FFT (Fast Fourier Transform), the BLAs
>(Basic Linear Algorithms) or LNPACK.
FWIW, PDL was invented for this type of problem. Here's a coupla pages I found:
http://pdl.perl.org/HtmlDocs/FFT.html
http://pdl.perl.org/HtmlDocs/Image2D.html
I didn't see BLA or LNPACK, but I wouldn't be surprised if they were out there.
HTH.
--
Peter Scott
------------------------------
Date: Sat, 03 Jun 2000 13:07:27 GMT
From: Andrej <webmaster@beautiful-ladies.com>
Subject: Predicted generation of ID numbers
Message-Id: <8havu9$ene$1@nnrp1.deja.com>
Hello All,
I need to generate ID number in a range 400-999(I have already IDs less
than 400)
I can use
ENV{'RAND'} = int(rand(599)) + 400;
But I have no guarantee, that these numbers will not be repeated by
script...
How this problem is solved? I understand, all previously generated ID
numbers should be written in the file. Then, script should check this
file, before new ID will be generated...
You could help me to create it?
Other way, if ID numbers will be generated not chaotically but
sequentially, like 400 then 401, 402...(we can write last ID in the
file here)
This way better...
Thank you and sorry for my English
--
Thank you,
Andrej
http://www.beautiful-ladies.com/
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 03 Jun 2000 13:36:20 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Predicted generation of ID numbers
Message-Id: <393a08dd.1027207@news.skynet.be>
Andrej wrote:
>Hello All,
>I need to generate ID number in a range 400-999(I have already IDs less
>than 400)
>I can use
>ENV{'RAND'} = int(rand(599)) + 400;
>
>But I have no guarantee, that these numbers will not be repeated by
>script...
It WILL be repeated. After all, how many integers do you expect to be
able to get between 400 and 999?
>How this problem is solved? I understand, all previously generated ID
>numbers should be written in the file. Then, script should check this
>file, before new ID will be generated...
Well, apart from the above problem...
Make an array of numbers 400 through 999. Shuffle that array. Get one of
them at a time, keeping track of where you were last time.
Er... shuffling arrays is mentioned in the FAQ, I think. It pops up here
at least a few times a year, anyway.
perldoc -q shuffle
-->
Found in perlfaq4.pod
How do I shuffle an array randomly?
--
Bart.
------------------------------
Date: 3 Jun 2000 14:18:05 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Predicted generation of ID numbers
Message-Id: <slrn8ji4su.225.efflandt@efflandt.xnet.com>
On Sat, 03 Jun 2000, Andrej <webmaster@beautiful-ladies.com> wrote:
>I need to generate ID number in a range 400-999(I have already IDs less
>than 400)
>
>Other way, if ID numbers will be generated not chaotically but
>sequentially, like 400 then 401, 402...(we can write last ID in the
>file here)
I don't know if this is the most efficient way to do it, but this is one
way to safely generate consecutive numbers without getting messed up by
multiple hits at once:
#!/usr/bin/perl -w
$idfile = "id_num";
if (open(ID,"+<$idfile")) {
flock ID,2; seek ID,0,0;
$id = <ID>; chomp($id);
seek ID,0,0; print ID ++$id,"\n";
close ID;
} elsif (open(ID,">$idfile")) {
$id = 400;
flock ID,2; seek ID,0,0;
print ID "$id\n";
} else {
print "Can't open $idfile: $!\n";
exit;
}
print "Do something useful with $id.\n";
I also posted an earlier message about how to find the last line in the
data file that contains a digit and increment that.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Sat, 03 Jun 2000 14:27:02 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Predicted generation of ID numbers
Message-Id: <8hb4jc$hnb$1@nnrp1.deja.com>
In article <8havu9$ene$1@nnrp1.deja.com>,
Andrej <webmaster@beautiful-ladies.com> wrote:
> Hello All,
> I need to generate ID number in a range 400-999(I have already IDs less
> than 400)
read in the file to get last number assigned
add one to it to get new number
check if > 999
append the number to the file
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 3 Jun 2000 08:01:59 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: relative paths to modules / libraries
Message-Id: <slrn8ji0e7.ts.tadmc@maxim.metronet.com>
On Fri, 2 Jun 2000 16:05:29 +0200, Seansan <sean77@dds.nl> wrote:
>I wrote two library files that have to be executed before anything else in a
>cgi script.
>require lib::getpost
You are missing some quotes there.
You are missing a semicolon there.
>OK, so far it works,
I don't see how it can "work" when it cannot even compile...
>Is there a way I can reference the absolute path to the lib directory and
>include the whole path to @INC ??
Perl FAQ, part 8:
"How do I add a directory to my include path at runtime?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 3 Jun 2000 09:10:44 -0400
From: sandoz@umbc.edu (James W. Sandoz)
Subject: Re: REQ: bytewise string manipulation C style instead of substr
Message-Id: <8hb04k$9tpp$1@umbc7.umbc.edu>
In article <3939014F.CFC3C92C@quicknet.nl>,
Jan Bessels <j.bessels@quicknet.nl> wrote:
>I want to make a ROTT13 implementaton. Letter a replaced by n, b
>replaced by o etc. Executing two rott13's on a string gives the
<stuff deleted>
Lots of work. Try this:
#!/usr/local/bin/perl5 -w
use strict;
my $x = shift();
$x =~ tr/a-zA-Z/n-za-mN-ZA-M/;
print "Encoded string:\t$x\n";
$x =~ tr/a-zA-Z/n-za-mN-ZA-M/;
print "Decoded string:\t$x\n";
--
Mr. James W. Sandoz, Instructor, UMBC Dept of Biol Sciences,
1000 Hilltop Circle
Catonsville, MD 21250
voice: (410) 455-3497; fax: 455-3875; net: sandoz@umbc.edu
------------------------------
Date: Sat, 03 Jun 2000 13:30:25 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: REQ: bytewise string manipulation C style instead of substr
Message-Id: <slrn8jkmjs.35f.tjla@thislove.dyndns.org>
I was shocked! How could Jan Bessels <j.bessels@quicknet.nl>
say such a terrible thing:
>I want to make a ROTT13 implementaton. Letter a replaced by n, b
>replaced by o etc. Executing two rott13's on a string gives the
>original one back. Basically I take a string and manipulate it on char a
>time. I can do this by using substr to extract a single char Somehow
>I'll think this to much of an overhead. I would like to do it the -c
>language way, directly manipulating the memory addresses where the
>string resides. I'm currently at home, without perl books. Anyone any
>pointer to info how to do this, maybe even examples
Well this is the "rot13" program on my computer:
#!/bin/sh
tr 'a-zA-Z' 'n-za-mN-ZA-M' $@
So translating that to Perl:
perl -pe 'tr/a-zA-Z/n-za-mN-ZA-M/'
ie. it's not hard to do :).
--
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
It's not easy, being green.
-- Kermit the Frog
------------------------------
Date: Sat, 03 Jun 2000 15:31:02 +0200
From: Jan Bessels <j.bessels@quicknet.nl>
Subject: Re: REQ: bytewise string manipulation C style instead of substr
Message-Id: <39390896.6C880536@quicknet.nl>
"James W. Sandoz" wrote:
> In article <3939014F.CFC3C92C@quicknet.nl>,
> Jan Bessels <j.bessels@quicknet.nl> wrote:
> >I want to make a ROTT13 implementaton. Letter a replaced by n, b
> >replaced by o etc. Executing two rott13's on a string gives the
> <stuff deleted>
>
> Lots of work. Try this:
>
> #!/usr/local/bin/perl5 -w
> use strict;
>
> my $x = shift();
> $x =~ tr/a-zA-Z/n-za-mN-ZA-M/;
> print "Encoded string:\t$x\n";
> $x =~ tr/a-zA-Z/n-za-mN-ZA-M/;
> print "Decoded string:\t$x\n";
Thanks, works like a charm.
Have used tr before but didn't came up with something like "
tr/a-z/n-za-m/;".
Of course there are times that tr won't sufice.
Anyone pointers to info how to do bytewsie string manipulation in Perl.
I'm stubborn, sorry...
Jan Bessels
------------------------------
Date: Sat, 03 Jun 2000 17:45:28 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: REQ: bytewise string manipulation C style instead of substr
Message-Id: <Yub_4.100798$hT2.410435@news1.rdc1.ct.home.com>
In comp.lang.perl.misc Jan Bessels <j.bessels@quicknet.nl> wrote:
> Of course there are times that tr won't sufice.
For one-to-one character mapping? tr will work all the time for those.
> Anyone pointers to info how to do bytewsie string manipulation in Perl.
Don't. Really, don't. There's very rarely any need. This is perl--strings
are *strings*. They aren't arrays of bytes, and trying to treat them like
that will just cause you grief. If you absolutely must, then use split
with a null pattern to split the scalar into a list, one element per
character, like so:
$foo = "abc";
@chars = split //, $foo;
and then iterate over the array. It's pretty darned slow, though.
> I'm stubborn, sorry...
No, you're fighting the language. This isn't C, it's perl. Trying to write
code as if it was C (or BASIC, or APL, or COBOL, or Fortran, or...) will
just make your life less pleasant than it has to be.
Fighting the language you're programming in, *whatever* language it is, is
a silly thing. A computer language is a tool. using perl as if it were C
makes as much sense as using a screwdriver like it's a hammer.
Dan
------------------------------
Date: Sat, 03 Jun 2000 16:01:34 GMT
From: "RGW303" <escaflowne@neo-tokyo.org>
Subject: using 'exists' in a program to test for keys in a hash
Message-Id: <yZ9_4.2378$NT4.69029@newsread1.prod.itd.earthlink.net>
Hello, I've just started learning Perl a few weeks ago and have gone through
2 books and for hours I've tried to successfully implement a method for
storing a retrieving keys and values in a hash DBM database. I'm using
ActivePerl 5.6. Anyhow my latest problem is testing for keys with the
'exists' keyword after loading a hash from a DBM file with the dbmopen()
function. If I do the following anywhere in my code:
while(exists $hash{"$key_$num"}) { <code...> }
--or something just as similar with an if statement.--
I get the error:
"AnyDBM_File doesn't define an EXISTS method at myprog.pl line xx".
Any help would be greatly appreciated.
-RGW303
------------------------------
Date: Sat, 03 Jun 2000 14:31:50 GMT
From: sg@sia.nu
Subject: Web Based E-mail Sorting System Required
Message-Id: <8hb4sn$hpv$1@nnrp1.deja.com>
We are an all-online travel agency, dealing with reservation of
accommodations in Charming Castels, Villas, Hotels, Cottages and
Farmhouses in Italy.
We have an "urgent" need of implementing a web-based e-mail client in
order to manage the huge flow of e-mails we are receiving for our
Website www.Tuscany.net . For this site we handle an average of 500
messages a day (will be 5.000 in 3-4 years of time) for all the 135
hotels/villas hosted on the site (will be 1.000 in 3-4 years of time),
and we forwarding the e-mails in this way:
vacationer >>>> OUR COMPANY >>>> requested villa
villa >>>> OUR COMPANY >>>> vacationer
being in the middle between vacationers and villas, and getting
revenues
from the reservations booked through us.
The application I'm requesting would solve some of the problems we are
encountering now, and will have the following advantages:
1- Provide a web-based management of the e-mail traffic, so that
anyone in
the world from a regular browser will be able to manage reservations
(currently we manage e-mail from the outlook98 e-mail client, which is
obviously not accessible by anyone out of our offices).
2- Provide the ability of storing in a database the e-mail addresses
of the
potential vacationers, creating a mailing list on which we could
marketing
the huge population that have visited the site since now (anytime
we'll
detect an unknown to the database e-mail address, we'll store it as
new
mailing target).
3- Provide the possibility of assigning a "tracking number" to every
request. The tracking number will be unique for a unique request and
assigned when the e-mail address of the vacationer matches with the
villa
he has requested (so if a new message is coming from Mr. X asking
villa Y,
the tracking number will be assigned if no other tracking number will
be
recognised in the subject line. Let's say that the rule of assigning
the
tracking number could be something like that: if the e-mail address of
the
vacationer is unknown to the database, and he request the villa nr.
345,
then a unique tracking number (some 0000-345 o likewise) will be
assigned
and put in the subject line of the incoming message. Then, any e-mail
message who contain the tracking number in the subject (the
vacationers and
villas will be instructed to always leave the tracking number in the
subject like) will be easy to retrieve when the agent will make a
query
based on tracking number.
4- Provide the possibility (as we are currently doing it now with
outlook98) to handle e-mails storing them automatically into sub-
folders of
incoming and outgoing mail, classifying them by villas. Let me
explaining
that:
All our e-mails coming from villa#1 are automatically stored on the
subfolder "villa#1>>>SIA" in the "incoming messages" main folder (we
have
created the so-called "mail rules" in outlook98):
We, then, forward the message to the vacationer, and the message is
stored
in the subfolder "SIA>>>villa#1 vacationers", automatically (the mail
rule
here is: if the message has that particular tracking nr. in the
subject
(say, villa1), and is not directed towards villa1 e-mail address, then
put
it in the "SIA>>>villa#1 vacationers" (tracking number of that
particular
villa with recipient other than the villa cannot be anyone but a
message
sent to a vacationer for that villa..)
This system is, as you have certainly understood, a "hotmail-like"
system
with some other features:
1- Tracking number assigning (just for the first unknown-to-the-system
vacationer matched for a particular villa, then vacationers and villas
will be instructed to always use that tracking number on the subject
line
of their messages)
2- Queries on tracking numbers
3- Messages automatically stored in the right subfolders thanks to the
"mail rules" (MS Outlook98-like)
4- A text or ASCII file in which we can store one-line-one-e-mail
address
database for marketing purposes)
All manageable from a browser, and developed for a UNIX BSDI server,
Apache WebServer, with Perl facility
I’d like to have a quote & timing for that? I'll be ready to invest in
it immediately.
Thanks,
Stefano Galastri
Company Director
Charming Vacations Ltd
sg@sia.nu
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 3243
**************************************