[7353] in Perl-Users-Digest
Perl-Users Digest, Issue: 978 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 5 00:07:43 1997
Date: Thu, 4 Sep 97 21:00:26 -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 Thu, 4 Sep 1997 Volume: 8 Number: 978
Today's topics:
Re: Communication between objects and global subroutine (Dan Sumption)
Re: Complex map problem <fawcett@nynexst.com.spam-me-not>
Re: Dynmical pattern problem (Scott Houck)
Re: eval warning "Backslash found ..." <rootbeer@teleport.com>
Re: flock() problem (Charles DeRykus)
Re: FTP with perl (Scott Houck)
Re: Help! Book needed!! (Faust Gertz)
Re: Help! How to make http request from perl CGI? (Charles DeRykus)
Re: How do I embed C in Perl <Jacqui.Caren@ig.co.uk>
Re: How do I embed C in Perl <rpsavage@ozemail.com.au>
Re: How do I embed C in Perl <rootbeer@teleport.com>
How does split find its argument? (Jahwan Kim)
Re: How to kill a child? <stuartc@ind.tansu.com.au>
Re: Is Perl for Win32 really as brain damaged as it see <woerns@dwc.ch>
Re: Is Perl for Win32 really as brain damaged as it see <rpsavage@ozemail.com.au>
Re: Newbie File Locking <rootbeer@teleport.com>
Re: NT Mail Question <Jacqui.Caren@ig.co.uk>
Re: Perl usage statistics <rootbeer@teleport.com>
Re: shell commands <Jacqui.Caren@ig.co.uk>
Re: Simple Perl for Win 32 Question (not in FAQ) (Kevin)
split question <pkeller@cisco.com>
Re: split question <doug@ono.tc.net>
Re: test CGI's wwithout uploading to ISP w/Frontpage 97 <flavell@mail.cern.ch>
Re: test CGI's wwithout uploading to ISP w/Frontpage 97 <rootbeer@teleport.com>
Re: Trivial(?) readdir question <woerns@dwc.ch>
Re: Weighting elements of an array <rootbeer@teleport.com>
Re: WIN95 server with perl?file.pl <rootbeer@teleport.com>
Re: Wrote new module, need help with system dependencie (Steven W McDougall)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 05 Sep 1997 00:10:37 GMT
From: dan@gulch.demon.co.uk (Dan Sumption)
Subject: Re: Communication between objects and global subroutines in Perl
Message-Id: <340f4b15.708098@news.demon.co.uk>
On Thu, 04 Sep 1997 12:23:55 +0200, Doug Seay <seay@absyss.fr> wrote:
>Then junk the templates strings. There is nothing magical or sacred
>about interpolation. Just have the last line of your subroutine be
>
> $obj->description()." is worth ".$obj->value();
My example was something of an oversimplification - the templates are
actually going to be sections (possibly whole pages) of HTML with many
points where variables may be inserted.
The reason I wanted to store the template as a string was so that
different objects or subclasses could have different templates.
For example, one object may have the template:
<INPUT TYPE="$type" NAME="$name" VALUE="$value">
while another may have:
<TEXTAREA NAME="$name" ROWS="$rows" COLUMNS="$columns">
but because of the object-oriented nature, both will be obtained using
the object's display_form_html method.
I could of course code a different display_form_html method for each
subclass (although this still restricts me from varying the template
within members of a single class), but one of my key aims is to make
the program easy to adapt to different circumstances - the person
customising the program for an individual website should only have to
plug the new strings into the object, rather than having to override
subroutines.
Or, again, I could well be missing the point. My knowledge of OO Perl
is certainly much better than it was yesterday, but that's no big
claim! Tomorrow, I'm sure I will know twice as much again
(I finally forked out for the 2nd edition of Programming Perl today -
the previous edition is not much help in the kind of territory I'm
getting into. Unfortunately, the book is so well written that I can't
help re-reading all the basic stuff again, so it'll be a while before
I'm on to objects....)
Dan Sumption, Technical Director dan@gulch.demon.co.uk
Hard Reality, Canary Wharf, London E14 dan@hardnet.co.uk
http://www.hardnet.co.uk/dan/
------------------------------
Date: 04 Sep 1997 21:42:27 -0400
From: Tom Fawcett <fawcett@nynexst.com.spam-me-not>
Subject: Re: Complex map problem
Message-Id: <8j90xc1qpo.fsf@nynexst.com.spam-me-not>
Chris Phillips <cphillip@kerr.phys.utas.edu.au> writes:
> I have just discovered the joys of the map function, but have run
> into a problem :-(
> Basically, I want the map function to skip a couple of the
> elements of the array in question. I cannot get it to work.
>
> A trivial example (that doesn't work):
>
> #!/usr/bin/perl -w
>
> sub testsub {
> print "@_\n";
> return;
> }
>
> $a[0] = 'a';
> $a[1] = 'b';
> $a[2] = 'c';
>
> # The following line is what I would like to use. It does not compile
> #testsub('*', map(@{$_} if ($_ ne 'b'), @a[0..2]), '*');
>
> # This line does compile, but all elements are printed
> testsub('*',map(eval {@{$_} if ($_ ne 'b')}, @a[0..2]),'*');
> # Another problem with this version is that it returns ' ', rather
> #than nothing if I replace the ($_ ne 'b') with 0.
If I understand your problem, try:
@a = qw(a b c);
testsub("*", map($_ eq 'b' ? () : ($_), @a), "*");
Works for me.
-Tom
------------------------------
Date: Fri, 05 Sep 1997 01:08:38 GMT
From: scott@radix.net (Scott Houck)
Subject: Re: Dynmical pattern problem
Message-Id: <34105b6f.91824236@news1.radix.net>
"Andreas SLATEFF"
<slateff@netway.at.Please.remove.this.I.really.hate.spam> wrote:
>> Remember: I don't want hard-coded
>> s/.../$2/;
>> I prefer it dynamically.
>
>Because nobody has answered me so far, I found a brute force solution:
>
>Print "s/.../$e/" in a temorary file and execute it with `perl ...`.
>Ugly.
>
>Isn't there any better solution?
eval, young man, eval.
------------------------------
Date: Thu, 4 Sep 1997 19:30:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Karen Yao <kareny@junglee.com>
Subject: Re: eval warning "Backslash found ..."
Message-Id: <Pine.GSO.3.96.970904192101.22463V-100000@julie.teleport.com>
On Thu, 4 Sep 1997, Karen Yao wrote:
> I have an eval statement that occasionally generates the following
> warning:
>
> "Backslash found where operator expected at (eval 1212) line 1, near
> "min_to_max(\"
You're probably suffering from backslashidosis, which is caused by
overzealous use of the backslash key. :-)
> The eval statement is:
>
> $new_row->[$i] = eval($function_ref->[$i]);
>
> Where $function_ref->[$i] is the string
> min_to_max(\@set10)
>
> min_to_max is a function that accepts a reference to an array. It simply
> finds the min and max in the list and returns a string "<min> to <max>"
Are you certain that that's the string that you're passing? It would be
easy to accidentally be passing the string without the backslash, or
something worse. (That's why it's almost always possible to avoid evaling
a string; and where it's possible, it's almost always preferable. Can you
recode to evade the evil eval? :-)
> This eval is invoked thousands of times. Once in a blue moon, this
> warning appears.
It _might_ be that you've found a way to trip up the parser. (Using 5.004?
That could make a difference.) You could put in some code to try to catch
the error before it happens.
warn "No backwhacked at-sign found in '$function_ref->[$i]'"
unless index($function_ref->[$i], '\\@') > -1;
If that warning, placed just before the eval line, doesn't trigger when
the error occurs, you've probably found a bug in Perl.
> Just curious. For now, I have suppressed the warning (via sig handler)
> from stdout/stderr unless the eval returns an undefined value.
Why not use an eval block to trap the failed eval string? That's easier.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 4 Sep 1997 23:39:44 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: flock() problem
Message-Id: <EG0CE8.E4I@bcstec.ca.boeing.com>
In article <340F120B.2942BAC0@home.net>, Farzad Mansour <zod@home.net> wrote:
> Can someone please point out what is wrong:
> Platform: Sparc 5
> OS: Solaris 2.5.x
> open(FILE,"< /tmp/junk");
> flock(FILE,2);
> Does not lock! Do I need rpc.lockd or some other thing running on my
> machine?
>
Opening a file read only will set a shareable attribute and
the exclusive lock will be ignored. (Ahem, this is my best
guess anyway :).
At any rate, if you open read/write instead, e.g.,
open(FILE,"+</tmp/junk) or die $!; # exclusive lock now works.
HTH,
--
Charles DeRykus
------------------------------
Date: Fri, 05 Sep 1997 00:32:39 GMT
From: scott@radix.net (Scott Houck)
Subject: Re: FTP with perl
Message-Id: <340f4d71.88242686@news1.radix.net>
Tom Grydeland <tom@mitra.phys.uit.no> wrote:
>Sure, but when asked for +easy perl script or module for FTPing
>something?;, does *expect* strike you as an obvious choice?
Obvious is good. However, obvious won't necessarily impress your
employer or always provide the best solution. I tend to exercise
divergent thinking when presented with a task. Besides, I said
"maybe" he should look into Expect. For this particular problem, Perl
may be the better solution for his needs. If Perl is your only tool
and you're happy with that, fine. But the more tools in your shed,
the more options you have.
------------------------------
Date: Fri, 05 Sep 1997 02:03:31 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Help! Book needed!!
Message-Id: <340f53de.463951@news.wwa.com>
On 4 Sep 1997 19:09:09 GMT, "Bernhard" <Bernhard.Streit@gmx.de> wrote:
>HI!
>Who knows a good BEGINNER (!!) book for learning perl? It could be in
>english or german language.
I assume you mean other than the books mentioned in the FAQ. :-)
I bet that brand spanking new book _Advanced Perl Programming_ by
Sriram Srinivasan is a great book! According to the O'Reilly page, it
covers practical use of packages and classes (object-oriented
programming), complex data structures, persistence (e.g., using a
database) , networking, graphical interfaces (using the Tk toolkit),
interaction with C language functions, embedding and extending the
perl interpreter, and more. Okay, I am being a smart ass.
Personally, I like the recommendations in the FAQ. I am learning perl
by reading Randal's _Learning Perl_ (I believe it to be the best
possible first contact.), Eric Johnson's _Cross-Platform Perl_ (As
there is more than one way to do things in perl, there is more than
one way to learn perl. I really like Eric's book for another way to
look at things.), _Programming Perl_ (to look at the stuff the intro
books don't cover), the FAQ (I learn a lot from just picking a section
and reading it), various and sundry articles in _Web Techniques_ and
_The Perl Journal_, and articles in comp.lang.perl.misc. You might
try looking at http://www.webdesigns1.com/perl/ for the experience of
a beginner who had trouble with Randal's book. While neither of us
had programmed before perl, my math, physics, and philosophy (logic
and philosophy of language) background may make learning perl easier
for me than for most other non-programmers.
Now is the time I quote from the FAQ.
>Perl Books
>
>A number books on Perl and/or CGI programming are available. A few of these are good, some are ok,
>but many aren't worth your money. Tom Christiansen maintains a list of these books, some with
>extensive reviews, at http://www.perl.com/perl/critiques/index.html.
>
>The incontestably definitive reference book on Perl, written by the creator of Perl and his apostles, is
>now in its second edition and fourth printing.
>
> Programming Perl (the "Camel Book"):
> Authors: Larry Wall, Tom Christiansen, and Randal Schwartz
> ISBN 1-56592-149-6 (English)
> ISBN 4-89052-384-7 (Japanese)
> (French and German translations in progress)
>
>Note that O'Reilly books are color-coded: turquoise (some would call it teal) covers indicate perl5
>coverage, while magenta (some would call it pink) covers indicate perl4 only. Check the cover color
>before you buy!
>
>What follows is a list of the books that the FAQ authors found personally useful. Your mileage may
>(but, we hope, probably won't) vary.
>
>If you're already a hard-core systems programmer, then the Camel Book just might suffice for you to
>learn Perl from. But if you're not, check out the ``Llama Book''. It currently doesn't cover perl5, but the
>2nd edition is nearly done and should be out by summer 97:
>
> Learning Perl (the Llama Book):
> Author: Randal Schwartz, with intro by Larry Wall
> ISBN 1-56592-042-2 (English)
> ISBN 4-89502-678-1 (Japanese)
> ISBN 2-84177-005-2 (French)
> ISBN 3-930673-08-8 (German)
>
>Another stand-out book in the turquoise O'Reilly Perl line is the ``Hip Owls'' book. It covers regular
>expressions inside and out, with quite a bit devoted exclusively to Perl:
>
> Mastering Regular Expressions (the Cute Owls Book):
> Author: Jeffrey Friedl
> ISBN 1-56592-257-3
>
>You can order any of these books from O'Reilly & Associates, 1-800-998-9938. Local/overseas is
>1-707-829-0515. If you can locate an O'Reilly order form, you can also fax to 1-707-829-0104. See
>http://www.ora.com/ on the Web.
>
>Recommended Perl books that are not from O'Reilly are the following:
>
> Cross-Platform Perl, (for Unix and Windows NT)
> Author: Eric F. Johnson
> ISBN: 1-55851-483-X
>
> How to Set up and Maintain a World Wide Web Site, (2nd edition)
> Author: Lincoln Stein, M.D., Ph.D.
> ISBN: 0-201-63462-7
>
> CGI Programming in C & Perl,
> Author: Thomas Boutell
> ISBN: 0-201-42219-0
>
>Note that some of these address specific application areas (e.g. the Web) and are not general-purpose
>programming books.
>
>
>
>Perl in Magazines
>
>The Perl Journal is the first and only magazine dedicated to Perl. It is published (on paper, not online)
>quarterly by Jon Orwant (orwant@tpj.com), editor. Subscription information is at http://tpj.com or via
>email to subscriptions@tpj.com.
>
>Beyond this, two other magazines that frequently carry high-quality articles on Perl are Web
>Techniques (see http://www.webtechniques.com/) and Unix Review (http://www.unixreview.com/).
Please note that _Camel Critiques_ has moved from
http://www.perl.com/perl/critiques/index.html to
http://language.perl.com/critiques/index.html
There is some perl documentation in german at
http://www.phy.uni-bayreuth.de/~btpa25/perl/perl_main.html As I only
dabble in german, I can't comment on the quality of the material.
Streben nach Wahrheit
Faust Gertz
Philosopher at Large
"We're headed for social anarchy when people start pissing on
bookstores!" --Tom Waits, _The Fisher King_
------------------------------
Date: Thu, 4 Sep 1997 23:27:16 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Help! How to make http request from perl CGI?
Message-Id: <EG0BtH.DAD@bcstec.ca.boeing.com>
In article <340F08BF.32DE@cedar.ca.goc>,
Mike Wong <mgwong@cedar.ca.gov> wrote:
> I'd like to know how to write a perl CGI script that would make an
> http request for an html document, do some stuff to the document, and
> then push the results to the browser.
>
> Writing a CGI doesn't trip me at all--but making the http
> request--that's the trick. If anyone can help me, I'd greatly appreciate
> the knowledge.
Check CPAN for the wonderful LWP modules. In your case, you can
just do this for instance:
use LWP::Simple;
$html_document = get "http://www.xxx.yyy.html";
HTH,
--
Charles DeRykus
------------------------------
Date: Thu, 4 Sep 1997 21:14:42 GMT
From: Jacqui Caren <Jacqui.Caren@ig.co.uk>
Subject: Re: How do I embed C in Perl
Message-Id: <EG05oJ.4u5@ig.co.uk>
In article <873377199.4853@dejanews.com>, <duesterwald@gei-aachen.de> wrote:
>Hi folks!
>
>I need to embed C in a perl script. What do I need to do?
>
>Which are the most helpful tools and modules?
to start :-)
man perlxstut
also see the copious documentation as www.perl.com
or with your perl installation :-)
>Thank you,
>
>Marc
or, alternatively pay someone to do it for you :-)
Jacqui
--
Jacqui Caren Email: Jacqui.Caren@ig.co.uk
Paul Ingram Group Fax: +44 1483 419 419
140A High Street Phone: +44 1483 424 424
Godalming GU7 1AB United Kingdom
------------------------------
Date: Fri, 05 Sep 1997 11:09:14 +1100
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: How do I embed C in Perl
Message-Id: <340F4DAA.3527@ozemail.com.au>
duesterwald@gei-aachen.de wrote:
[snip]
> I need to embed C in a perl script. What do I need to do?[snip]
I learned about this 10 minutes ago. The rest is history...
The SWIG home page:
http://www.cs.utah.edu/~beazley/SWIG/
--
PO`!1a
------------------------------
Date: Thu, 4 Sep 1997 18:17:51 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: duesterwald@gei-aachen.de
Subject: Re: How do I embed C in Perl
Message-Id: <Pine.GSO.3.96.970904181648.22463O-100000@julie.teleport.com>
On Thu, 4 Sep 1997 duesterwald@gei-aachen.de wrote:
> I need to embed C in a perl script. What do I need to do?
>
> Which are the most helpful tools and modules?
Start with 'man perl', which will direct you to other manpages. After
you've read the manpages on this subject, if you've still got questions,
please ask again. Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 5 Sep 1997 00:33:49 GMT
From: jahwan@supernova.math.lsa.umich.edu (Jahwan Kim)
Subject: How does split find its argument?
Message-Id: <slrn60ukrc.47k.jahwan@supernova.math.lsa.umich.edu>
Hi all,
Well, I thought I knew how it works. Here's my question.
(1) perl -wne 'print split if /^alias/' < mail-aliases
works in the way I expect.
(2)(Main Question) perl -wne 'print split[1] if /^alias/' < mail-aliases
doesn't. Isn't this the same as
perl -wne 'print +(split)[1] if /^alias/' < mail-aliases
which is what I want? Apparently, the output tells me it's not.
(3) So I wonder, [1] in split[1] is interpreted as regex (so it does not
split anything because no line in my mail-aliases contain 1)? But (code and
output indented for clarity),
perl -wne 'print split[1] if /^alias/' <<TEXT
alias this1that
TEXT
gives me
alias this1that
while,
perl -wne 'print split /1/ if /^alias/' <<TEXT
alias this1that
TEXT
outputs
alias thisthat
(4) None of the above give me any warning.
(5) Of course, I used
perl -ane 'print $F[1]," " if /^alias/' < mail-aliases
for what I want.
TIA as always,
Jahwan
------------------------------
Date: 05 Sep 1997 09:54:50 +1000
From: Stuart Cooper <stuartc@ind.tansu.com.au>
Subject: Re: How to kill a child?
Message-Id: <yeog1rkvdmd.fsf@kudu.ind.tansu.com.au>
jzhuang@ringer.cs.utsa.edu (Jun Zhuang) writes:
> I tried to kill a child process after a fork(), but I find out
> it ALWAYS ovewrwrite my printf in the parent process.
No- it's a bad printf to start with. See below.
> The code is:
>
> $pid_A = fork;
> if ($pid_A != 0) { # this is parent process
> for( ; ;) {
> if (waitpid($pid_A,0) == -1) #wait for child to finish
> {last; }
> }
> }
> else { # this is child process
> alarm 30; # set timeout to 30 seconds
> #do something here
> alarm 0;
A) > die or exit(1);
> }
>
B) > printf(some_file, "Hello world!"); #this should be parent only,
> #but I found child is still alive here.
no it isn't! you just had a bad printf (see below).
>
> How do I kill a child completely?
>
You're doing it right, Jun, but your printf itself is wrong; you need
\n at the end to get it to work. Also lose the comma after the some_file
filehandle and stick a string argument to die.
Let's rewrite A) as simply die "Child dead\n";
and B) as printf(STDOUT "Hello world!\n");
When run this gives:
Child dead
Hello world!
ie we get 1 Hello World! from the parent after the child is dead (as you want).
If we comment out the die line A) we get
Hello world!
Hello world!
ie *both* child and parent continue to the end of the script; because
there's no longer and exit or die in the child's code.
In summary, then, you're doing it right (ie your child is exiting and
waitpid and die are doing the right things); you were just checking this with
a bad printf and that's where the confusion lies. Exactly why the printf
is bad is an extra issue I will not touch on here; although you can look
up documentation on Perl's $| variable to get a feel for it.
Hope this helps,
Stuart Cooper
stuartc@ind.tansu.com.au
------------------------------
Date: Fri, 05 Sep 1997 01:52:36 +0200
From: Christoph Wernli <woerns@dwc.ch>
To: Bart Lateur <bart.mediamind@tornado.be>
Subject: Re: Is Perl for Win32 really as brain damaged as it seems?
Message-Id: <340F49C4.4A3BA1EF@dwc.ch>
Bart Lateur wrote:
> >no apparent reason, _it would access a:\ every time the external command
> I've seen this once before on a Win95 machine, and Perl had nothing to
> do with it.
Exactly.
> This behaviour started after he ran WinZip once from the floppy drive.
> Apparently, WinZip had installed itself in the registry.
> You need to uninstall it (or any other program that did this) properly.
I heard a mumbling of this beeing an 'option', not a bug. Unfortunately I
forgot where to turn it off.
Sorry, -werns
------------------------------
Date: Fri, 05 Sep 1997 11:11:41 +1100
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: Is Perl for Win32 really as brain damaged as it seems?
Message-Id: <340F4E3D.7016@ozemail.com.au>
Bart Lateur wrote:
>
> jdm@thetics.europa.com (Jessica) wrote:
>
> >I tried using backticks to execute the command and it would run the
> >command correctly and return the correct output to my script, but for
> >no apparent reason, _it would access a:\ every time the external command
> >was executed_.
> [snip]
I get this too, on Win95. I have WinZip, but have just installed ZipMagic (which is _much_ cleverer), and I
still get the effect.
--
PO`!1a
------------------------------
Date: Thu, 4 Sep 1997 18:13:56 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Lutz Albers <lutz@muc.de>
Subject: Re: Newbie File Locking
Message-Id: <Pine.GSO.3.96.970904180746.22463N-100000@julie.teleport.com>
On Thu, 4 Sep 1997, Lutz Albers wrote:
> Grrr. I thought that perl5.004 DOES indeed flush the file buffers before
> releasing the lock (at least that whats perldelta claims).
It tries, but there's no reason to rely upon it. Releasing the lock
explicitly before closing the file is a waste of a good line of code. :-)
> It's always a good thing to get in the habit of releasing a lock. You
> might someday use a system/language which doesn't automaticly releases
> the locks and then you might have a problem :-)
The fact that a file is locked should imply that there's a program,
somewhere, which holds the lock. If that program quits, the lock should be
released; this is a lesson which every vendor should know by now. (I keep
saying 'should' because there's no law of the universe requiring that a
vendor must be cluefull.)
In the case you describe, where the lock isn't automatically released, it
would work equally well to release the lock _after_ closing the file,
and doing so should be safe on all systems. So, if you must unlock the
file, do it after closing it, and I'll try to keep my snickers to myself.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 4 Sep 1997 21:23:12 GMT
From: Jacqui Caren <Jacqui.Caren@ig.co.uk>
Subject: Re: NT Mail Question
Message-Id: <EG062o.4wq@ig.co.uk>
In article <5ukjqh$18e@news1.infoave.net>, Ranson <ranson@infoave.net> wrote:
>
>Forgive me, but I know little about NT servers. I need to write a program that
>is going to send mail from a perl script. Having always worked in UNIX
>the code below almost always works.
>
>Thanks in advance.
>
>Q. Does NT use sendmail? Or does NT use another mail prog. ?
>
>$mailprog = '/usr/sbin/sendmail';
>
> open (MAIL, "|$mailprog $mymail") || die "Can't open $mailprog!\n";
>
> print MAIL "Reply-to: $UserMail $UserName\n";
Depending upon which version of perl
use Mail::Internet;
my $mesg = new Mail::Internet;
# snip example...
my @sent = $mesg->send_email();
As long as the modules work on your platform (and YOU have
access to an SMTP server) this would work...
Jacqui;
--
Jacqui Caren Email: Jacqui.Caren@ig.co.uk
Paul Ingram Group Fax: +44 1483 419 419
140A High Street Phone: +44 1483 424 424
Godalming GU7 1AB United Kingdom
------------------------------
Date: Thu, 4 Sep 1997 19:04:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: George Menyhert <menyhert@acm.org>
Subject: Re: Perl usage statistics
Message-Id: <Pine.GSO.3.96.970904183924.22463S-100000@julie.teleport.com>
On Thu, 4 Sep 1997, George Menyhert wrote:
> Can anyone quote some Perl usage statistics for ISP's?
Sure. 99% of the world's ISPs are already using Perl 5.004, with 70% of
them installing it the same week it came out, and 93% within the following
two weeks. These statistics have less than a 0.01% chance of being 100%
accurate, since I just made them up.
:-)
Of course, nobody has any useful figures because there's no way to tell
who is using what on the grand scale. So, my figures are as likely (or
unlikely) as the next person's!
Here's what I really think: About 98% of the time that a Perl script is
run, it's one which is compatible with Perl 5. (But this statistic is just
as fabricated as the others. :-)
> My company has opted to do some scripting in Perl 4 because they believe
> "most" ISP's have not upgraded. I am running into problems and every
> helpful (sarcasm) response has been "upgrade". Since this is a
> commercial product, I would need to prove that support for Perl 4 is not
> worth the hassle.
What kind of proof would suffice? I'd suggest that you point out to them
the security issues, since 5.004 is significantly more secure than any
previous version. In particular, it's possible to break into a server
running Perl 4 in almost every case. (This isn't Perl's fault; CGI scripts
written in C _all_ have this potential bug, which was mended in 5.004.) Do
you want to sell your customers a script which might be used to break into
their server? Eek!
Another point is that, because of modules, a good Perl script typically
takes less time to write and debug using version 5. For example, a CGI
script using the popular CGI.pm module can be debugged from the command
line, without even using a server. That's much more work in Perl 4. Saving
time means saving money.
The biggest point, to me, is that Perl 4 is dead and unsupported. There's
no prize at the bottom of the box, there's no light at the end of that
tunnel. The time has come to move on, whether they believe that "most"
ISPs have done so or not. Any ISP who wants Perl 5 can download and
install it in a few minutes, without having to give up their Perl 4
scripts - and you or your company can even make a few extra bucks by
helping them with the upgrade, if you wish.
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 4 Sep 1997 20:39:50 GMT
From: Jacqui Caren <Jacqui.Caren@ig.co.uk>
Subject: Re: shell commands
Message-Id: <EG042F.4pD@ig.co.uk>
In article <340DE5C6.FC728EC0@instinet.com>,
David Mossakowski <dmoss@instinet.com> wrote:
>Hi,
>
>I need to create a form on intranet for people to be able to change
>their UNIX passwords. Question is: even if I log in the script as a
>super user can I execute something like: system "yppasswd user_name";
>? I mean it then asks for the password and then again to retype it.
>Is there a way to type remotely? If not how else can I do this?
Use the NIS API - there is one.
There may even be a module under CPAN by now!
::NIS adcO Interface to Sun's NIS RIK
::NISPlus adcO Interface to Sun's NIS+ RIK
If one of these does not do what you are after :-
1) talk to the author.
2) read perlxstut etc...
3) modify or overload module to suit.
4) send to author or clp.modules or CPAN as appropriate
or
beg/pay someone to do it for you. :-)
Jacqui
--
Jacqui Caren Email: Jacqui.Caren@ig.co.uk
Paul Ingram Group Fax: +44 1483 419 419
140A High Street Phone: +44 1483 424 424
Godalming GU7 1AB United Kingdom
------------------------------
Date: 4 Sep 1997 16:06:00 -0700
From: klander@primenet (Kevin)
Subject: Re: Simple Perl for Win 32 Question (not in FAQ)
Message-Id: <340f3a1d.54496001@news.primenet.com>
On Thu, 04 Sep 1997 13:54:03 GMT, ron@farmworks.com (Ronald L. Parker)
wrote:
>On 3 Sep 1997 14:34:00 -0700, klander@primenet (Kevin) wrote:
>
>>On Wed, 03 Sep 1997 20:42:42 GMT, ron@farmworks.com (Ronald L. Parker)
>>wrote:
>>
>>>On 2 Sep 1997 15:23:01 -0700, klander@primenet (Kevin) wrote:
>>>
>>>>$filename =~ /^(.+\\)(.*)$/; # <-- extracts path and filename into $1
>>>> # and $2
>>>>
>>>>$fpath = $1;
>>>>$fname = $2;
>>>
>>>Doesn't work for $filename eq '\\autoexec.bat'
>>>
>>Oops. You're right. Take out the ^ anchor.
>
>Actually, you need the ^ anchor. Change the + to a *.
>
Why do I need the anchor at the beginning? The '.' matches anything,
so it will start matching at the beginning, and continue until the
backslash is reached (again, assuming there will be a backslash).
But, you're right. Taking the anchor out of my original expression
doesn't help in the case you brought up. I must've been horribly
confused...
-Kevin
------------------------------
Date: Fri, 05 Sep 1997 05:49:33 -0700
From: Paul Keller <pkeller@cisco.com>
Subject: split question
Message-Id: <340FFFDD.14FC@cisco.com>
Say i have a line to be processes which reads:
08/27/97 10:00 <username> 14252
I would be able to split by using:
($date, $time, $username, $jobid) = split(' ', $_);
But if several lines were to read:
08/27/97 10:00 <firstname middle lastname> 14252
08/27/97 10:00 <username> 14252
How would I get split to ignore the spaces occuring between
the angle braces of the first line so the 4th field is always
the integer following whatever is enclosed in '<>'?
Many thanks,
Paul
------------------------------
Date: 04 Sep 1997 21:28:19 -0400
From: Douglas McNaught <doug@ono.tc.net>
To: pkeller@cisco.com
Subject: Re: split question
Message-Id: <m290xcpn0s.fsf@ono.tc.net>
[mailed and posted]
Paul Keller <pkeller@cisco.com> writes:
> 08/27/97 10:00 <firstname middle lastname> 14252
> 08/27/97 10:00 <username> 14252
>
> How would I get split to ignore the spaces occuring between
> the angle braces of the first line so the 4th field is always
> the integer following whatever is enclosed in '<>'?
I don't think you can do it with split. Assuming that the angle
brackets are always balanced and aren't nested, this is fairly easy
with a regex:
($date, $time, $username, $jobid) =
m/
(\S+) # one or more nonspaces, save in $1
\s+ # one or more spaces
(\S+) # one or more nonspaces, save in $2
\s+ # one or more spaces
(<[^>]+>) # '<', then one or more non-'>', then '>', save in $3
\s+ # one or more spaces
(\S+) # one or more nonspaces, save in $4
/x;
-Doug
--
sub g{my$i=index$t,$_[0];($i%5,int$i/5)}sub h{substr$t,5*$_[1]+$_[0],1}sub n{(
$_[0]+4)%5}$t='encryptabdfghjklmoqsuvwxz';$c='fxmdwbcmagnyubnyquohyhny';while(
$c=~s/(.)(.)//){($w,$x)=g$1;($y,$z)=g$2;$w==$y&&($p.=h($w,n$x).h($y,n$z))or$x==
$z&&($p.=h(n$w,$x).h(n$y,$z))or($p.=h($y,$x).h($w,$z))}$p=~y/x/ /;print$p,"\n";
------------------------------
Date: Thu, 4 Sep 1997 22:43:13 GMT
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: test CGI's wwithout uploading to ISP w/Frontpage 97
Message-Id: <Pine.A41.3.95a.970905003302.69104D-100000@sp055>
On Thu, 4 Sep 1997, Gina Anderson wrote:
> I have a question, I hope I am in the right newsgroup..
The news.announce.newusers group has some FAQs that every new usenaut
should read. You'll get much better results from usenet if you first
read and understand those FAQs.
> I have also
> forwarded this question to other groups.
Oh dear. That's exactly wrong. In the rare cases when your posting
is appropriate for more than one group, you need to _crosspost_ it
to the relevant groups, as it's explained in the new user FAQs.
If the question is definitely about CGI then your _only_ relevant group
is comp.infosystems.www.authoring.cgi. If it's about the Perl language
then it'll be at home here, but if it's a CGI question about a script
that just happens to be written in Perl then it's off to the CGI group
with you.
There are basically two ways to preview a CGI script: to install a real
server and run it on that, or to simulate the server environment.
c.i.w.server.misc might be relevant, but I still think you need to be
asking on c.i.w.a.cgi primarily at that stage.
Then when you find that Perl on a Win95 platform is braindead, you'll
be welcome back here with a non-CGI question about Perl itself. I
think.
------------------------------
Date: Thu, 4 Sep 1997 18:19:49 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Gina Anderson <ginakra@one.net>
Subject: Re: test CGI's wwithout uploading to ISP w/Frontpage 97
Message-Id: <Pine.GSO.3.96.970904181857.22463P-100000@julie.teleport.com>
On Thu, 4 Sep 1997, Gina Anderson wrote:
> Subject: test CGI's wwithout uploading to ISP w/Frontpage 97
If you write a CGI script using CGI.pm, you'll be able to test it from the
command line without using a server. There are other helpful modules
available from CPAN. Hope this helps!
http://www.perl.com/CPAN/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 05 Sep 1997 01:32:27 +0200
From: Christoph Wernli <woerns@dwc.ch>
To: "M.J.T. Guy" <mjtg@cus.cam.ac.uk>
Subject: Re: Trivial(?) readdir question
Message-Id: <340F450A.E35B59B5@dwc.ch>
M.J.T. Guy wrote:
> Marc Philips <Marc.Philips@tvd.be> wrote:
> >> > How likely is readdir to NOT return '.' and '..' as the first two
> >> > directory entries when reading in a directory?
> >
> >On UNIX, a directory is created with two (sub)directory entries: "." and
> >"..".
> >
> >Given that readdir reads the directory sequentially, I'd say that they
> >will always be the first two entries returned and always in that order.
>
> That isn't defined. So only a masochist would assume it.
How about:
@tmplogs = grep !/^\./, readdir TMP;
This will leave you only with the files you were intended to see.
-werns
------------------------------
Date: Thu, 4 Sep 1997 19:20:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Terry Michael Fletcher - PCD ~ <tfletche@pcocd2.intel.com>
Subject: Re: Weighting elements of an array
Message-Id: <Pine.GSO.3.96.970904190908.22463U-100000@julie.teleport.com>
On 4 Sep 1997, Terry Michael Fletcher - PCD ~ wrote:
> i would like to be able to create an array of commands to execute, and
> then randomly execute some commands from this array a large number of
> times.
> but now, say i want ~60% of the commands to be cmd1, ~30% to be cmd2,
> and ~10% to be cmd3,
Not too hard to do...
$commands = [
# Each one is a weight followed by a coderef
[ 60 => \&cmd1 ],
[ 30 => \&cmd2 ],
[ 10 => sub { sleep 5 } ], # Inline if you wish
];
sub get_random_action {
# Given an arrayref as above, picks one action by weight.
# The total weight need not be known in advance.
my $commands = shift;
my $sum = 0;
my $act;
for (@$commands) {
$act = $_->[1] if rand($sum += $_->[0]) < $_->[0];
}
$act;
}
# Do it!
get_random_action($commands)->();
That last line will probably require 5.004, but I'm too lazy to test this
now. :-) Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 4 Sep 1997 18:33:54 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: jeff knot <jknot@hotmail.com>
Subject: Re: WIN95 server with perl?file.pl
Message-Id: <Pine.GSO.3.96.970904182027.22463Q-100000@julie.teleport.com>
On Thu, 4 Sep 1997, jeff knot wrote:
> we can replace http://www.somewhere.com/cgi-bin/prog.pl
> with http://www.somewhere.com/cgi-bin/perl.exe?prog.pl
Not if you value your hardware, software, and reputation, you can't. :-)
That's a *BIG* security hole. Don't do it that way; do it right.
ftp://info.cert.org/pub/cert_advisories/
CA-96.11.interpreters_in_cgi_bin_dir
http://www.w3.org/Security/Faq/
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 5 Sep 1997 01:32:50 GMT
From: swmcd@world.std.com (Steven W McDougall)
Subject: Re: Wrote new module, need help with system dependencies.
Message-Id: <EG0HMq.528@world.std.com>
Todd Beverly <beverly@kodak.com> writes:
>This class reads a binary file created from a scientific instrument
>called a spectrophotometer. The file consists of double floats,
>strings, characters and integers and I'm using 'read' and 'unpack'
>routines to decipher the results. The files will always be written on a
>MS Windows machine, which means, on a UNIX machine, a 'reverse' of the
>string before unpacking a float.
Beware: there's more to unpacking a float than knowing the byte order.
Different CPUs use different formats for floating point
numbers. pack() and unpack() use the native format of whatever machine
Perl is running on. This may or may not be the same as the format in
which the value was written.
A particularly perverse example is VAX, which puts the sign bit
somewhere in the middle...
- SWM
------------------------------
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 978
*************************************