[12398] in Perl-Users-Digest
Perl-Users Digest, Issue: 5998 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 15 06:07:28 1999
Date: Tue, 15 Jun 99 03:00:27 -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, 15 Jun 1999 Volume: 8 Number: 5998
Today's topics:
Re: Case select statements: are they in Perl? (Bart Lateur)
Child processes, "Please wait" pages ("Thomas J. Margolis")
Re: Decoding Binaries from NewsGroups [ Again ] <thomas@bibsyst.no>
Re: Decoding Binaries from NewsGroups [ Again ] (Sam Holden)
Re: Does Perl have a future? <bill@fccj.org>
Re: Dynamic Regular Expression (Bart Lateur)
Efficiency utils for Perl scripts on Unix and Windblow$ (Marc Bissonnette)
Re: Efficiency utils for Perl scripts on Unix and Windb <uri@sysarch.com>
Re: FancyIndex on old apache 1.2.6 (David Efflandt)
File Processing chumho@my-deja.com
Re: File Processing <gellyfish@gellyfish.com>
Re: File Processing (Bart Lateur)
Re: File Uploading (Marc Bissonnette)
Re: File Uploading (Marcel Grunauer)
HELP!!!!!!!!!!! dansjohnson@geocities.com
how do i make a Multi Dimensional array? <office@asc.nl>
Re: how do i make a Multi Dimensional array? (Marcel Grunauer)
How to flush to the file each time I write a record to <howel@edge.com.sg>
How to flush to the file each time I write a record to <howel88@cyberway.com.sg>
Re: How to flush to the file each time I write a record <sb@sdm.de>
Re: How to start a script and give it some variables ? (David Efflandt)
Re: Large String handling (Philip 'Yes, that's my address' Newton)
mail list customisation <daniel@virtualimpact.com.au>
Re: Mime...Perl...MS Outlook...and HTML <gellyfish@gellyfish.com>
Re: Perl Mongers Book Review page is up <jbc@shell2.la.best.com>
Problems generating a module from a library dinorex@my-deja.com
recursive perl algorithm <eng80386@nus.edu.sg>
Re: recursive perl algorithm <gellyfish@gellyfish.com>
Re: recursive perl algorithm (Marcel Grunauer)
Re: Regex question <JFedor@datacom-css.com>
Regular expressions against keys in a hash <thomas@bibsyst.no>
Re: Regular expressions against keys in a hash (Bart Lateur)
Resizing hashes <thomas@bibsyst.no>
Simple GTK example <thomas@bibsyst.no>
Re: Sort on mtime <gellyfish@gellyfish.com>
Re: Sorting Arrays of Arrays, Thanks! (Completed script (Larry Rosler)
Trouble with CGI.pm @ WebProvider.Com (=?ISO-8859-1?Q?=C7=E5s=86r=FC=E7=EE=F8?=)
Re: Trouble with CGI.pm @ WebProvider.Com <gellyfish@gellyfish.com>
Re: user IP <gellyfish@gellyfish.com>
Re: Verifying date data (Abigail)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 15 Jun 1999 09:04:17 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Case select statements: are they in Perl?
Message-Id: <376c1513.9703544@news.skynet.be>
Tom Christiansen wrote:
>
> {
> "Fred" => \&greet,
> "Barney" => \&shuffle,
> "Wilma" => \&chat,
> }->{$who}->();
>
>Except that now you haven't managed to catch the null case.
This may be done something like:
({ Fred => \&greet, Barney => \&shuffle}->{$who}||\&default)->();
If there's no entry for $who, &default is called. (A CODE reference
counts as true.)
Bart.
------------------------------
Date: Mon, 14 Jun 1999 22:00:50 +0000
From: tmargolis@seqnet.net ("Thomas J. Margolis")
Subject: Child processes, "Please wait" pages
Message-Id: <199906150402.WAA03886@seqserv.seqnet.net>
Greetings,
I am working with some very ugly, long Perl legacy code which, prompted by a
user's form submission, extracts data from a database and prints a report to
the browser. Because this process takes a while, I want a "Please wait"
page to appear after the user presses Submit, and to be replaced by the
database report when the extraction process is completed.
What's the best way to approach this? Pipe data to a child script? Fork a
child process? My main problem has involved headers: I need to send
non-parsed headers to have the child print the "Waiting" page in the
interim, but this horrendous legacy code is so tangled with headers...that
my head hurts from pounding it against my desk.
Any suggestions, vague or specific, would be appreciated. As long as you're
nice and play fair.
Thanks,
Tom
tmargolis@seqnet.net
-------------------------------------------
"Brief but sublime quotation from well-known historical figure."
-- Well-Known Historical Figure
------------------------------
Date: Mon, 14 Jun 1999 22:04:06 +0200
From: Thomas Weholt <thomas@bibsyst.no>
To: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Decoding Binaries from NewsGroups [ Again ]
Message-Id: <37656036.9F6B60EA@bibsyst.no>
I want to make a script that logs onto a nntp-server, checks against a
database for allready downloaded/decoded files and downloads/decodes new
arrivals.
> Thomas Weholt <thomas@bibsyst.no> wrote:
> > Hi,
> >
> > I asked this question before, but got no asnwer.
> >
>
> Perhaps there was a good reason for this.
>
> > Is there a module or simple code that decodes binary files from
> > newsgroups?
> >
>
> What code of encoding - uuencode, Base64 .. ?
>
> If there is a module that will do this then it will be available from
> CPAN <http://www.perl.com/CPAN>.
> --
> "Philippa Forrester, presenter and would-be Smurf" - Howard Stableford,
> Tomorrow's World
------------------------------
Date: 15 Jun 1999 09:03:41 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Decoding Binaries from NewsGroups [ Again ]
Message-Id: <slrn7mc5nd.f1s.sholden@pgrad.cs.usyd.edu.au>
On Mon, 14 Jun 1999 22:04:06 +0200, Thomas Weholt <thomas@bibsyst.no> wrote:
>I want to make a script that logs onto a nntp-server, checks against a
>database for allready downloaded/decoded files and downloads/decodes new
>arrivals.
So do what the last guy said...
Grab the NNTP modules from CPAN.
Grab the modules to decode the encodings you want to support.
Write some code to tie it all together.
--
Sam
Computers in the future may weigh no more than 1.5 tons.
--Popular Mechanics, 1949
------------------------------
Date: Tue, 15 Jun 1999 02:21:27 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: Does Perl have a future?
Message-Id: <Shm93.3493$_t.400293@news2.jacksonville.net>
In article <T4V83.1187$gK.38140@typ22b.nn.bcandid.com>,
pacman@defiant.cqc.com (Alan Curry) wrote:
> One line from that post made my day.
>
> "Does Perl have a future [on the WWW server]?" --Christian Ahkman
> "Does the WWW server have a future?" --Bill Jones
>
> Consider it immortalized.
:]
I also said -
(Apache aside, WWW servers pretty much suck.)
Which I now realize is technically wrong.
WWW servers barf.
HTH, :]
seek DATA,0,1;print<DATA>;
__DATA__ -Sneex- :]
Just Another Perl Monger...
------------------------------
Date: Tue, 15 Jun 1999 06:59:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Dynamic Regular Expression
Message-Id: <3767f4d2.1446504@news.skynet.be>
Tom Christiansen wrote:
>:>Per usual, I see no reason for an eval().
>:It is necessary, if this is modified so that the "code" string in
>:$subtext is generated dynamically from the user query.
>
>So what? That's what qr// is for. :-)
*Boggle*
I'm sorry, but [A] I really can't see what's so bad about using eval
*once* to compile some custom testing code, not once every loop, one
indirect sub call per loop is not that bad; and
[B] how qr// could possibly help in constructing the tests like this:
query test (Perl code)
a /a/
a b /a/ && /b/
a b c /a/ && /bb/ && /c/
As said: using just ONE regex for the whole query (usually) won't cut
it. You need an unpredetermined number of regexes, combined with *and*.
/a.*b|b.*a/s
looks like it's going to be far less efficient than the custom
constructed sub.
Is qr// really going to be lots faster than eval()?
Bart.
------------------------------
Date: Tue, 15 Jun 1999 05:03:00 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: Efficiency utils for Perl scripts on Unix and Windblow$?
Message-Id: <88l93.13778$5a.15775@news20.bellglobal.com>
Hey folks,
Over the last couple of weeks, I've learned a *lot* about making my code more
efficient and faster, thanks to those who critiqued my code and offered
suggestions/directions.
So, I'm wondering if there are any utils out there that will tell me the
efficiency/resource uses of a perl script. I know (well, I think, since I'm not
a Unix wiz) there's a system command in unix that will tell you stuff like CPU
usage, time to process, etc, but I don't know what it is.
so a) can someone tell me how to find that out on a unix machine?
b) is there some way of finding out the same information on a windblow$
machine?
I'm thinking along similar lines when I used a modem to connect to the 'net,
there were a zillion little apps to tell you BPS, latency, dropped packets,
etc, and I could use that to measure registry and modem register tweaks. If
there's something like that for Perl scripts, it'd be a neat thing to have to
help speed them up and/or make them more system friendly.
--
----------------------------
Marc Bissonnette
InternAlysis
Corporate Internet Research and Results!
http://www.internalysis.com
------------------------------
Date: 15 Jun 1999 01:12:17 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Efficiency utils for Perl scripts on Unix and Windblow$?
Message-Id: <x7r9nef3ny.fsf@home.sysarch.com>
>>>>> "MB" == Marc Bissonnette <dragnet@internalysis.com> writes:
MB> So, I'm wondering if there are any utils out there that will tell
MB> me the efficiency/resource uses of a perl script. I know (well, I
MB> think, since I'm not a Unix wiz) there's a system command in unix
MB> that will tell you stuff like CPU usage, time to process, etc, but
MB> I don't know what it is.
use Benchmark ;
i am in the middle of doing lots of that as i type.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 15 Jun 1999 03:22:28 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: FancyIndex on old apache 1.2.6
Message-Id: <slrn7mbhjn.i9.efflandt@efflandt.xnet.com>
On 14 Jun 1999 16:21:42 +0100, Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>I think you must have made a typo for comp.infosystems.www.servers.unix
>when you entered the group.
Sorry about that, I guess I had the cursor in front of the wrong newsgroup
when I hit 'p' in slrn.
--
David Efflandt efflandt@xnet.com
http://www.xnet.com/~efflandt/
------------------------------
Date: Tue, 15 Jun 1999 06:12:12 GMT
From: chumho@my-deja.com
Subject: File Processing
Message-Id: <7k4qro$drq$1@nnrp1.deja.com>
Hi,
Can anyone explain why the first code works but not the second? Do I
have any misconception ?
####Right####
readfile("msgf.hst");
exit(1);
sub readfile {
open(f,$_[0]);
local($r);
$r = <f>;
while ( $r ne undef ) {
print $r;
$r = <f>;
}
close(f);
}
####Wrong####
readfile("msgf.hst");
exit(1);
sub readfile {
open(f,$_[0]);
local($r) = <f>;
while ( $r ne undef ) {
print $r;
$r = <f>;
}
close(f);
The only difference between the "wrong" and "right" is in the
initialization of local variable $r. The "wrong" one declare and
initial $r to be the first record of the file in one line. Where the
"right" one does it in two separate lines.
BTW, I'm using ActivePerl Build 517 (Perl 5.005_3) on WNT 4.0.
Eric.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 15 Jun 1999 10:10:40 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: File Processing
Message-Id: <37661890@newsread3.dircon.co.uk>
chumho@my-deja.com wrote:
> Hi,
>
> Can anyone explain why the first code works but not the second? Do I
> have any misconception ?
>
> ####Right####
>
> readfile("msgf.hst");
> exit(1);
> sub readfile {
> open(f,$_[0]);
> local($r);
> $r = <f>;
> while ( $r ne undef ) {
> print $r;
> $r = <f>;
> }
> close(f);
> }
>
> ####Wrong####
>
> readfile("msgf.hst");
> exit(1);
> sub readfile {
> open(f,$_[0]);
> local($r) = <f>;
> while ( $r ne undef ) {
> print $r;
> $r = <f>;
> }
> close(f);
>
>
> The only difference between the "wrong" and "right" is in the
> initialization of local variable $r. The "wrong" one declare and
> initial $r to be the first record of the file in one line. Where the
> "right" one does it in two separate lines.
>
Except they are both wrong by some measures of wrong:
sub readfile
{
my $file = shift || die "No filename supplied\n";
open(FILE,$file) || die "error opening $file - $!\n";
my $r
while($r = <FILE>)
{
print $r;
}
close FILE;
}
Specifically you are not checking the success of your file open, you
are using local when you almost certainly want to be using my() and
you are not using the special behaviour of the while when reading from
a file.
I would suggest reading the perlfunc and perlsyn manpages which are installed
as HTML under the "Active Perl" link in your start menu.
/J\
--
"You've got to remember it was the 1980s. There were a lot of people
alive back then who died in the Second World War" - This Morning with
Richard Not Judy
------------------------------
Date: Tue, 15 Jun 1999 09:44:45 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: File Processing
Message-Id: <3766203f.12563324@news.skynet.be>
chumho@my-deja.com wrote:
>####Wrong####
>
>readfile("msgf.hst");
>exit(1);
>sub readfile {
> open(f,$_[0]);
> local($r) = <f>;
This will read the entire file, and assign the first line to $r, because
of the list context. This could work:
local $r = <f>;
Bart.
------------------------------
Date: Tue, 15 Jun 1999 05:07:31 GMT
From: dragnet@internalysis.com (Marc Bissonnette)
Subject: Re: File Uploading
Message-Id: <ncl93.13786$5a.15775@news20.bellglobal.com>
In article <kTk93.2008$fR5.12111@ozemail.com.au>, aneesha@vettweb.net.au
says...
> Is there any way to use ftp from a perl cgi
>script? Any help in the right direction would be much appreciated.
This is what I've been using for ages; works nicely;
http://www.terminalp.com/scripts/file_upload.shtml
--
----------------------------
Marc Bissonnette
InternAlysis
Corporate Internet Research and Results!
http://www.internalysis.com
------------------------------
Date: Tue, 15 Jun 1999 09:01:57 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: File Uploading
Message-Id: <3768165f.1337933@enews.newsguy.com>
On Tue, 15 Jun 1999 14:50:57 +1000, "Aneesha" <aneesha@vettweb.net.au>
wrote:
>Hi
>
>While I'm familiar with ASP, and Javascript I'm very new to writing cgi
>programs with perl. I basically need to get a script that will allow a user
>to upload a file to a directory on my webserver. All the scripts i have
>tried don't work and just get an internal server error. The problem is that
>all the scripts i can find use the CGI.pm module which i don't think is
>installed on the server.
See perlfaq8: How do I keep my own module/library directory?
HTH
Marcel
------------------------------
Date: Tue, 15 Jun 1999 07:12:20 GMT
From: dansjohnson@geocities.com
Subject: HELP!!!!!!!!!!!
Message-Id: <37660278.F1D8D5DF@geocities.com>
Have stuff due tomorow. Have this error, what does it mean? I am trying
to get the msql stuff installed properly, not sure if I messed up.
Can't load '/usr/lib/perl5/site_perl/i386-linux/auto/DBD/mSQL/mSQL.so'
for module DBD::mSQL:
/usr/lib/perl5/site_perl/i386-linux/auto/DBD/mSQL/mSQL.so: undefined
symbol: msqlErrMsg at /usr/lib/perl5/i386-linux/5.00404/DynaLoader.pm
line 168.
at /usr/lib/perl5/site_perl/Msql.pm line 13
Please help.
Dan Johnson
dansjohnson@geocities.com
------------------------------
Date: Tue, 15 Jun 1999 09:15:34 +0200
From: "Bastiaan S van den Berg" <office@asc.nl>
Subject: how do i make a Multi Dimensional array?
Message-Id: <7k4ulr$fb8$1@zonnetje.NL.net>
hiya
just wondering if everyone ever used one of these , and could shake some
code to explain it to me..
couldn't find anything in perlref & perldata :(
tnx in advance!
--
Bastiaan v/d Berg ; aka buZz
Internet Specialist
Account Software Consultancy
-[ http://www.asc.nl/ ]-[ office@asc.nl ]-
-[ http://huizen.ddsw.nl/bewoners/buzz/ ]-[ buzz@ddsw.nl ]-
------------------------------
Date: Tue, 15 Jun 1999 08:57:02 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: how do i make a Multi Dimensional array?
Message-Id: <37671504.990914@enews.newsguy.com>
On Tue, 15 Jun 1999 09:15:34 +0200, "Bastiaan S van den Berg"
<office@asc.nl> wrote:
>hiya
>
>just wondering if everyone ever used one of these , and could shake some
>code to explain it to me..
>
>couldn't find anything in perlref & perldata :(
Try perldsc (the Data Structures Cookbook), as well as "Programming
Perl".
HTH
Marcel
------------------------------
Date: Tue, 15 Jun 1999 03:34:35 +0800
From: "Howel88" <howel@edge.com.sg>
Subject: How to flush to the file each time I write a record to a file?
Message-Id: <3766020a.0@news.cyberway.com.sg>
Anyone knows how to flush each time I write a record to a file?
------------------------------
Date: Tue, 15 Jun 1999 03:37:25 +0800
From: "Howel" <howel88@cyberway.com.sg>
Subject: How to flush to the file each time I write a record to a file?
Message-Id: <376602b4.0@news.cyberway.com.sg>
Anyone can help?
------------------------------
Date: 15 Jun 1999 09:16:18 GMT
From: Steffen Beyer <sb@sdm.de>
Subject: Re: How to flush to the file each time I write a record to a file?
Message-Id: <7k55l2$ia1$1@solti3.sdm.de>
In article <3766020a.0@news.cyberway.com.sg>, Howel88 <howel@edge.com.sg> wrote:
> Anyone knows how to flush each time I write a record to a file?
RTM "perldoc perlvar" about "$|".
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/
http://www.engelschall.com/u/sb/download/
http://www.perl.com/CPAN/authors/id/STBEY/
http://www.oreilly.de/catalog/perlmodger/bnp/
------------------------------
Date: 15 Jun 1999 03:33:53 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: How to start a script and give it some variables ?
Message-Id: <slrn7mbi94.i9.efflandt@efflandt.xnet.com>
On Mon, 07 Jun 1999 00:13:13 -0800, Mag <captain_mag@hotmail.com> wrote:
>Hi!
>
>I need to start several scripts with one starting script.
>(This first one starts other scripts and pipes them.
>These other scripts now need some information that should be
>supplied by the first script.
>Now:
>How do I get my first script to start the others and give
>them this information?
>
>I know how to do this via Browser:
>http:......fireball.pl?URL=testurl&QUE=querystring&FIN=50
>
>but whenever I try to get this started by the script, it
>won't work:
>
> open FIREBALL, "./fireball.pl
>URL=$in_url&QUE=$in_query&FIN=$FINDER_depth 2>&1 |" or die
>"Fireball:can't fork; $!";
Just make sure that the string is all on one line or that you append the
pieces with a dot like:
open FIREBALL, "./fireball.pl ".
"URL=$in_url&QUE=$in_query&FIN=$FINDER_depth 2>&1 |"
or die "Fireball:can't fork; $!";
Then fireball.pl will find its input in @ARGV, or in this case since you
have only one parameter, it is in $ARGV[0]. What error are you getting?
--
David Efflandt efflandt@xnet.com
http://www.xnet.com/~efflandt/
------------------------------
Date: Tue, 15 Jun 1999 06:21:38 GMT
From: nospam.newton@gmx.net (Philip 'Yes, that's my address' Newton)
Subject: Re: Large String handling
Message-Id: <3765f03d.251544937@news.nikoma.de>
On Mon, 14 Jun 1999 20:04:45 GMT, nospam.newton@gmx.net (Philip 'Yes,
that's my address' Newton) wrote:
> s#(<TR><TD>)(.*?)(</TD></TR>)#$1\n$2\n$3\n#i;
Oops... add a 'g' to the end of that (.....#ig), of course.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.net>
------------------------------
Date: Tue, 15 Jun 1999 14:45:43 +0800
From: Daniel Barnett <daniel@virtualimpact.com.au>
Subject: mail list customisation
Message-Id: <3765F62F.E5A50A56@virtualimpact.com.au>
Hi,
We're after a customization of a Perl mail list script that can be found
here:
http://www.robplanet.com/cgi/robmail/
Basically we would like all the output from the script to be presented
in a HTML template....with the script parsing a different template for
each output.
I have emailed the scripts original author and have not had a reply.
Please email me if interested.
Regards,
Daniel Barnett.
--
_________________________________
VIRTUAL IMPACT
Level 4 225 St Georges Tce Perth WA
PO BOX 144, South Perth WA 6951
Tel: (08) 9485 2966
Mobile: 0412 636101
http://www.virtualimpact.com.au
_________________________________
_________________________________
Best of Perth
http://www.bestofperth.com.au
"Find everything that's in or about Perth & WA, and
on the Net. Or use it as a gateway to the World!"
_________________________________
------------------------------
Date: 15 Jun 1999 09:23:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Mime...Perl...MS Outlook...and HTML
Message-Id: <37660d6d@newsread3.dircon.co.uk>
Tim Clark <cpdog@rma.edu> wrote:
> This question is not specifically Perl related but I thought if anyone knew
> the answer to this question it would be this newsgroup...
>
Flattery will get you nowhere.
> Anyway, the
> problem is that the email displays in HTML fine in Outlook Express but NOT
> in microsoft outlook. The reason for this, I believe is that Outlook Express
> looks for the mime type: text/html but Outlook (I think) will only read HTML
> messages that another Outlook has sent, and it used a mime type called:
> Application: Content-Type: application/ms-tnef
Works fine for me:
#!/usr/bin/perl
use MIME::Lite;
use Getopt::Std;
my $blah = localtime;
my $mesg_text = <<ETY;
<HTML>
# Bunch of HTML snipped
</HTML>
ETY
# Create a new multipart message:
my $msg = new MIME::Lite
To => '************* <*************@internal.dircon.net>',
Cc => '*********** <***********@internal.dircon.net>, ************** <**************@internal.dircon.net>',
Bcc => 'jonathan.stowe@internal.dircon.net',
From =>'Jonathan Stowe <tdcjs@fatmog.dircon.net>',
Reply-to => 'jonathan.stowe@dircon.net',
Subject =>'Radius Statistics',
Type =>'text/html',
Data =>$mesg_text;
# Attach a part:
attach $msg Type =>'text/html',
Path =>'/home/tdcjs/radius/gtel.html',
Filename =>'gtel.html';
attach $msg Type =>'text/html',
Path =>'/home/tdcjs/radius/all.html',
Filename =>'all.html';
attach $msg Type =>'text/html',
Path =>'/home/tdcjs/radius/video.html',
Filename =>'video.html';
attach $msg Type =>'text/html',
Path =>'/home/tdcjs/radius/en.html',
Filename =>'en.html';
$msg->send;
This works fine and displays the message correctly on my Outlook and the
various other Mail clients that the other recipients might use ...
/J\
--
"I suggest you apply some lubrication before any bending begins" -
Antoine de Caunes, Eurotrash
------------------------------
Date: 15 Jun 1999 08:57:07 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: Perl Mongers Book Review page is up
Message-Id: <37661563$0$203@nntp1.ba.best.com>
John Mignault <jbm@panix.com> wrote:
> http://www.pm.org/book_reviews
On the Tk (baby emu) book, I was disappointed to see the generally
negative review. I don't actually need to know Tk at the moment, and
don't have much reason to buy it, but as a general sucker for anything
with cute animals on the cover I was looking forward to picking one up
and seeing if the author would be at the upcoming Perl Conference for
an autograph session.
Come to think of it, I'm still looking forward to it. Nancy Walsh is a
babe and a half, especially compared to people like Larry and Randal
and TomC. :-)
--
John Callender
jbc@west.net
http://www.west.net/~jbc/
------------------------------
Date: Tue, 15 Jun 1999 08:55:29 GMT
From: dinorex@my-deja.com
Subject: Problems generating a module from a library
Message-Id: <7k54dv$h9l$1@nnrp1.deja.com>
Hi!
I'm trying to generate a module from a library.
I have used the SWIG program to generate it, this library have externals
and internals functions. I saw that the externals functions run Ok! but
not the internals. I don't export the internals functions. Do I have to
export these functions too?
I execute the same program in c and perl but the results are not success
full with perl. I suppose that the problem is that the internals
functions don't run Ok :(
P.D.
I've read the man pages and the FAQ's.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 15 Jun 1999 13:57:28 +0800
From: "cwt" <eng80386@nus.edu.sg>
Subject: recursive perl algorithm
Message-Id: <7k4qh7$n95$1@newton.pacific.net.sg>
Hallo all , below is a scripts that would go into a directory , search for
files with a target string and write to a log file the line that the string
occurs.
Can anyone help me to make it a recursive algorithm such that it would go
into the directory and execute the process from the parent into the
sub-directories downwards like a tree ??
Thanks !!
##########################################################
#!/usr/bin/perl
$SCRIPTSPATH='/home/usr//cgi-bin/Scripts'; #path of this script
$SAVEPATH='/home/usr/cgi-bin/Scripts/data'; # path of the log
$SEARCHPATH='/home/usr/cgi-bin/other/Search'; #path of the searched dir
$TARGETSTR="/opt/pkgs/release/cgi-bin"; # the target string
opendir(SEARCHDIR,"$SEARCHPATH") || die "Cannot open SEARCHDIR file";
while( $_=readdir(SEARCHDIR) ){
$presentfile=$_;
if(-d "$SEARCHPATH/$_" ){
mkdir("$SAVEPATH/$_", 0777);
chmod(0777 , "$SAVEPATH/$_");
}elsif(-f "$SEARCHPATH/$_" ){
open(SAVEFILE,">>$SAVEPATH/$_");
chmod(0777 , "$SAVEPATH/$_");
open(SEARCH,"$SEARCHPATH/$_");
while(<SEARCH>){
if($_=~ /$TARGETSTR/){
print SAVEFILE $.;
print SAVEFILE "\n";
}
}
close SEARCH;
}
close(SAVEFILE);
}
open(LOG,">>$SCRIPTSPATH/log");
opendir(SAVEDIR,"$SAVEPATH") || die "Cannot open SAVEDIR file";
while( $_=readdir(SAVEDIR) ){
if( (-f "$SAVEPATH/$_") && !(-z "$SAVEPATH/$_") ){
print LOG "****Files in $SEARCHPATH/$_ *******";
open(DESFILE,"$SAVEPATH/$_");
print LOG "$_\n";
while(<DESFILE>){
print LOG $_;
}
print LOG "*************\n\n";
close DESFILE;
}
}
system("rm $SAVEPATH\/* ");
system("rmdir $SAVEPATH\/* ");
closedir SAVEDIR;
close LOG;
exit;
------------------------------
Date: 15 Jun 1999 10:11:40 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: recursive perl algorithm
Message-Id: <376618cc@newsread3.dircon.co.uk>
cwt <eng80386@nus.edu.sg> wrote:
> Hallo all , below is a scripts that would go into a directory , search for
> files with a target string and write to a log file the line that the string
> occurs.
> Can anyone help me to make it a recursive algorithm such that it would go
> into the directory and execute the process from the parent into the
> sub-directories downwards like a tree ??
I would recommend using the module File::Find ....
/J\
--
"If they want a circus, they have come to the right person" - Neil
Hamilton
------------------------------
Date: Tue, 15 Jun 1999 08:54:46 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: recursive perl algorithm
Message-Id: <3766140c.742858@enews.newsguy.com>
On Tue, 15 Jun 1999 13:57:28 +0800, "cwt" <eng80386@nus.edu.sg> wrote:
>Hallo all , below is a scripts that would go into a directory , search for
>files with a target string and write to a log file the line that the string
>occurs.
>Can anyone help me to make it a recursive algorithm such that it would go
>into the directory and execute the process from the parent into the
>sub-directories downwards like a tree ??
File::Find is your friend. Comes standard with the Perl distribution.
>#!/usr/bin/perl
#!/usr/bin/perl -w
use strict;
>opendir(SEARCHDIR,"$SEARCHPATH") || die "Cannot open SEARCHDIR file";
It's good that you check the return value of the system call, but you
might also want to output the error message:
opendir(SEARCHDIR,"$SEARCHPATH") || die "Cannot open $SEARCHPATH
directory: $!\n";
HTH
Marcel
------------------------------
Date: Tue, 15 Jun 1999 02:34:49 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: Regex question
Message-Id: <7k4qe6$mrp$1@plonk.apk.net>
OK, there's more than one way to skin a cat....
$date=localtime;
$date =~ s/://g;
$date =~ s/(\w+){6} /,/;
print $date;
Looks great and formatted.
Tue Jun 15, 1999
instead of
Tue Jun 15 02:33:23 1999
Thanks All
------------------------------
Date: Mon, 14 Jun 1999 22:10:19 +0200
From: Thomas Weholt <thomas@bibsyst.no>
Subject: Regular expressions against keys in a hash
Message-Id: <376561AB.85411A37@bibsyst.no>
Hi,
I got a hash with a structure like this :
"keyword" = "ids"
eg.
"perl" = "2.32,32.543,21.42,432.43,23.432";
"python"="32.54,543.34,9.100";
etc.
The values describe id-codes telling the script where to look up for a
word in another hash, containing filenames and info about that file.
eg.
"2.32"="/linux/development/perl.tar.gz....";
What I need is a way of hitting stuff like pyth* and per*, like simple
regular expressions. How do I get the keys that pass that test *without*
going thru the hash key by key? ( If this is possible at all. If not
I`ll stop trying ;->)
Thomas Weholt
------------------------------
Date: Tue, 15 Jun 1999 09:49:24 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Regular expressions against keys in a hash
Message-Id: <376720c0.12692178@news.skynet.be>
Thomas Weholt wrote:
>What I need is a way of hitting stuff like pyth* and per*, like simple
>regular expressions. How do I get the keys that pass that test *without*
>going thru the hash key by key? ( If this is possible at all. If not
>I`ll stop trying ;->)
Stop trying.
You could create another hash, with those keys, for example, grouped per
starting letter.
%firstletter = ( p => [qw(perl python)]);
You can then limit you search through the keywords to only those keys
starting with "p".
foreach $keyword (@{$firstletter{p}}) { ... }
HTH,
Bart.
------------------------------
Date: Mon, 14 Jun 1999 22:12:43 +0200
From: Thomas Weholt <thomas@bibsyst.no>
Subject: Resizing hashes
Message-Id: <3765623B.90338D2C@bibsyst.no>
Does anybody know how resizing ( like removing parts of the value of
some keys etc) of a hash stored on disc affects the size? Does the
filesize of the file stay the same or does it shrink too? I use the
Berkley DB-package.
Thanks!
Thomas Weholt
------------------------------
Date: Mon, 14 Jun 1999 22:35:10 +0200
From: Thomas Weholt <thomas@bibsyst.no>
Subject: Simple GTK example
Message-Id: <3765677E.75FEA163@bibsyst.no>
Hi,
Can anybody show me a simple, beginners-kinda perl/GTK example? All I
need is to display is a ls-like filelisting and a ok-button.
Thomas Weholt
------------------------------
Date: 15 Jun 1999 09:11:31 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Sort on mtime
Message-Id: <37660ab3@newsread3.dircon.co.uk>
AEF <aef@pangea.ca> wrote:
>
> Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
> news:7k08e0$ib$1@gellyfish.btinternet.com...
>> On Sat, 12 Jun 1999 21:20:26 -0500 AEF wrote:
>> my $base_dir = shift;
>>
>> my %filedate;
>>
>> opendir(DIR, $base_dir) || die "Can't open $base_dir\n";
>>
>> my @files = map { $base_dir . '/' . $_ } grep !/^.{1,2}$/, readdir(DIR);
>
> Jonathan:
>
> Thanks.
>
> Got it going. Questions...
>
> I tried to find info on the up the
>
> grep !/^.{1,2}$/
>
That should be grep !/^\.{1,2}$/
I think leaving out that backsklash is my most common typo.
> with little success about the explanation. What is happening with {1,2}?
> Basically, could you please explain the search "not" matching...
>
At least one but no more than two '.'s - some prefer:
/^\.\.?$/
Which is the same in effect being a '.' followed by zero or one '.'s
(And one less character for LR).
You might benefit from looking at the perlre manpage.
> Also, I got a error for opening the $base_dir, with the lexical scope, and
> the
>
> my $base_dir = shift;
>
> Is there a reason for using the lexical scope? Works fine without it!
>
not if you use strict it doesnt ...
/J\
--
"I sign my paintings Vincent because people can't pronounce Van Gough"
- Vincent Van Gough
------------------------------
Date: Mon, 14 Jun 1999 23:29:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting Arrays of Arrays, Thanks! (Completed script included)
Message-Id: <MPG.11cf929ca396c00c989be2@nntp.hpl.hp.com>
In article <377172f4.8474535@enews.newsguy.com> on Mon, 14 Jun 1999
21:54:44 GMT, Marcel Grunauer <marcel.grunauer@lovely.net> says...
> On Mon, 14 Jun 1999 19:16:56 GMT, dragnet@internalysis.com (Marc
> Bissonnette) wrote:
...
> >For anyone who's interested, the completed script follows.
> >
> >What it does: Reads in from a text file pipe-separated data, sorts
> >alphabetically based on last name, prints an html file for each letter of the
> >alphabet in a simple table format.
I had started a commentary similar to this, but didn't get to finish it.
So I'll piggy-back on Marcel's.
...
> >$indata="icd.txt";
>
> my $indata ... etc.
...
> >open (DATA, $indata) || &CgiError("Unable to open database for reading
> >$indata");
Opening a file in a CGI program using a relative pathname is disaster-
prone. You have no guarantee as to what the current directory is when
the program is started by the webserver. *Always* use an absolute path
or an explicit chdir() to the directory you want.
> >my (%data, @names, $hash, $line, $data, @printed, $temp, $blarg);
Several of these declarations are either superfluous or in to broad a
scope, $blarg for example.
...
> > my @line = split /\|/;
(my @line = split /\|/) >= 13 or die 'conveniently';
> > $blarg="$line[1]"."$line[0]";
>
> $blarg = "$line[1]$line[0]";
my $blarg = "$line[1]$line[0]";
> > $data{$blarg} = {
> > fname => $line[0],
> > lname => $line[1],
> > title => $line[2],
> > company => $line[3],
> > address1 => $line[4],
> > address2 => $line[5],
> > city => $line[6],
> > province => $line[7],
> > postal => $line[8],
> > country => $line[9],
> > work_phone=> $line[10],
> > work_fax => $line[11],
> > email => $line[12],
>
> Isn't there a more elegant way? Anyone?
You bet. It's called a hash slice.
@{$data{$blarg}}{qw(
fname lname title company address1 address2
city province postal country work_phone
work_fax email
)} = @line;
But I'm not sure the hash adds value. One could do simply:
@{$data{$blarg}} = [ @list ];
and recover the data from the array. It might also make the messy HTML
generation that I clipped from below loopable.
> > };
> >
> > push @names, $blarg;
This array is superfluous, as the names can be recovered from the keys
of the hash %data. See below.
> >}
...
> >$last_letter eq 'a';
>
> This line confuses me. Should it be an assignment?
'-w' would have identified this error.
> >foreach (@names) {
> > $temp=(substr $_, 0, 1);
>
> Should probably read
> $temp = substr($_,0,1);
>
> > $temp=~ tr/A-Z/a-z/;
> > if ($temp ne $last_letter) {
> > $last_letter = $temp;
> > push @$temp, $_;
>
> Shouldn't you use a hash instead of this variable-constructing thing?
Indeed!!! Symbolic references are Evil.
> > } else {
> > push @$temp, $_;
> > }
> >}
...
All of the above loop can be written much more straightforwardly.
my %letters;
push @{$letters{lc substr $_, 0, 1}}, $_ for keys %data;
I love Perl!!!
...
> Or rather, foreach ('a'..'z') {
> then there is no need for @printed at all.
Why not just:
for (keys %letters) { ... }
That way, files that happen to have no data need not be written.
...
> $writefile="../members/"."$_".".htm";
> open (WPUBLISH, ">>$writefile") || die "Couldnt open ";
The comments above about relative filenames apply here too. Also, about
including $! in the error message.
> >print WPUBLISH<<EOF;
>
> I'm not sure, does this need a space between the filehandle and the
> "<<"?
No. But why conjecture when a simple experiment would have told you?
In any case, it's a good idea to separate tokens for readability.
...
> There's probably more that could be improved here. Sorry about the
> nit-picking.
I'm not sorry. It isn't nit-picking. There are some serious structural
issues to fix here.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 15 Jun 1999 00:34:07 -0700 (MST)
From: Casaveli@webtv.net (=?ISO-8859-1?Q?=C7=E5s=86r=FC=E7=EE=F8?=)
Subject: Trouble with CGI.pm @ WebProvider.Com
Message-Id: <10482-376601EF-83@newsd-211.iap.bryant.webtv.net>
How do I use CGI.pm at http://www.webprovider.com ? It works well at
http://www.hypermart.net .. but since I got my own domain from
WebProvider ( http://www.keleko.net ) -- I wanna stick my WebTV IRC on
that... but I keep getting this error:
(Remember, you can only run perl scripts).
The error encountered was
Can't locate loadable object for module Apache::Constants in @INC (@INC
contains:
/usr/lib/perl5/i386-linux/5.004 /usr/lib/perl5
/usr/local/lib/site_perl/i386-linux
/usr/local/lib/site_perl .) at /usr/local/lib/site_perl/Apache.pm line 4
BEGIN failed--compilation aborted at /usr/local/lib/site_perl/Apache.pm
line 4.
If anyone knows, please let me know.. Thanks.
-The Don Castracani
Castrucio's IRC
http://keleko.hypermart.net/cgi-bin/join.pl
Keleko, Inc.
http://keleko.net
"I got nothin 2 lose but everything 2 live 4"
------------------------------
Date: 15 Jun 1999 10:23:59 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Trouble with CGI.pm @ WebProvider.Com
Message-Id: <37661baf@newsread3.dircon.co.uk>
Gesr|gnx <Casaveli@webtv.net> wrote:
> How do I use CGI.pm at http://www.webprovider.com ? It works well at
> http://www.hypermart.net .. but since I got my own domain from
> WebProvider ( http://www.keleko.net ) -- I wanna stick my WebTV IRC on
> that... but I keep getting this error:
>
> (Remember, you can only run perl scripts).
> The error encountered was
> Can't locate loadable object for module Apache::Constants in @INC (@INC
> contains:
> /usr/lib/perl5/i386-linux/5.004 /usr/lib/perl5
> /usr/local/lib/site_perl/i386-linux
> /usr/local/lib/site_perl .) at /usr/local/lib/site_perl/Apache.pm line 4
> BEGIN failed--compilation aborted at /usr/local/lib/site_perl/Apache.pm
> line 4.
>
But that isnt a CGI.pm error - it appears that your server is using
mod_perl but it hasnt been installed properly. You will need to reinstall
mod_perl or arrange not to use it. You will probably need to contact the
helpdesk at your ISP.
/J\
--
"The chef's salty balls have dropped" - Christopher Price, BBC NEWS 24
------------------------------
Date: 15 Jun 1999 09:55:50 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: user IP
Message-Id: <37661516@newsread3.dircon.co.uk>
Leonid Goltser <leonid76@erols.com> wrote:
> Is there a method in perl to check for IP?
>
>
#!/usr/bin/perl -w
use Socket;
my $is = inet_aton($ARGV[0]);
my ($address,$aliases,@junk) = gethostbyaddr($is,AF_INET);
print $address,"\n";
read the perlipc manpage ...
/J\
--
"Nourishes at the root and penetrates right to the tip" - Pantene
Advertisement
------------------------------
Date: 14 Jun 1999 18:46:47 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Verifying date data
Message-Id: <slrn7mb5jj.cmq.abigail@alexandra.delanet.com>
Skip Hollowell (thollowe@opentext.com) wrote on MMCXIII September
MCMXCIII in <URL:news:7k2pnu$30iu@enews1.newsguy.com>:
""
"" I don't know who pays your salary, but in my world, the customer is always
"" right.
I get payed for being right.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
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 5998
**************************************