[19624] in Perl-Users-Digest
Perl-Users Digest, Issue: 1819 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 26 03:05:34 2001
Date: Wed, 26 Sep 2001 00:05:08 -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: <1001487907-v10-i1819@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 26 Sep 2001 Volume: 10 Number: 1819
Today's topics:
Re: [ASK[ Perl and Windows <bwalton@rochester.rr.com>
Re: Dump raw data (Garry Williams)
Re: emailing contents of text file (Garry Williams)
Re: emailing contents of text file (Stephane TOUGARD)
Re: emailing contents of text file (Martien Verbruggen)
Excel-Graphs <christian.wanninger@toshiba-tro.de>
Re: Excel-Graphs <marc.nospam.logghe@devgen.com>
Re: How To Copy Files in Script w/Shell? (Chris Fedde)
Re: How To Copy Files in Script w/Shell? <pne-news-20010926@newton.digitalspace.net>
Re: How To Copy Files in Script w/Shell? <bwalton@rochester.rr.com>
Re: How to fetch all html files under a web directory <pne-news-20010926@newton.digitalspace.net>
Re: How to fetch all html files under a web directory <comdog@panix.com>
Re: ONE QUESTION (Martien Verbruggen)
sendmail gadget works on one server, not on another <simercer@NOSPAMhotmail.com>
Re: sendmail gadget works on one server, not on another (Martien Verbruggen)
Re: Setting max. values (cpu/ram usage) for mod_perl sc <pne-news-20010926@newton.digitalspace.net>
Re: Socket question (hugh1)
Re: Sorting Hashes <pne-news-20010926@newton.digitalspace.net>
Re: Why use Sys::Hostname instead of just $ENV{SERVER_N <comdog@panix.com>
Zoom in Excel Sheets <christian.wanninger@toshiba-tro.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 Sep 2001 05:13:14 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: [ASK[ Perl and Windows
Message-Id: <3BB162E4.F9AAEE6B@rochester.rr.com>
Sami Jarvinen wrote:
>
> Bob Walton <bwalton@rochester.rr.com> wrote
> > "¤ßÂÅ Dennis" wrote:
> > > How can a PERL script only show at tray-icon without text-console?????
...
> > would run minimized. There are probably other ways, too.
>
> Indeed there is. ActivePerl comes with a nice program called 'wperl.exe'
> which, unlike 'perl.exe', is not a console application, I.e. it won't
> create a shell window.
Thanks! Not a lot of docs on that one. How did you ever find out about
it?
--
Bob Walton
------------------------------
Date: Wed, 26 Sep 2001 04:24:05 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Dump raw data
Message-Id: <slrn9r2m34.9ff.garry@zfw.zvolve.net>
On Wed, 26 Sep 2001 09:26:49 +0800, Stephane TOUGARD
<s_tougard@hotmail.com> wrote:
> my %hash;
>
> dbmopen(%hash,'file',0500) or die $!;
^^^^
Not very nice to my umask and useless execution bit. Also, why can't
I update the file?
Unless there is a good reason otherwise, open should be passed a mask
of 0666. (The execution bit is never turned on when O_CREAT is
specified anyway.) The user's umask will turn off the permission bits
the user wants turned off. Why do you know better?
> $hash{'value'} = 'your information';
Why does this answer the OP's question?
> dbmclose(%hash);
>
>
> more information with perldoc -f dbmopen
Yes, indeed:
$ perldoc -f dbmopen
dbmopen HASH,DBNAME,MASK
[This function has been largely superseded by the
"tie" function.]
--
Garry Williams
------------------------------
Date: Wed, 26 Sep 2001 05:01:00 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: emailing contents of text file
Message-Id: <slrn9r2o8b.9ff.garry@zfw.zvolve.net>
On Wed, 26 Sep 2001 09:34:20 +0800, Stephane TOUGARD
<s_tougard@hotmail.com> wrote:
> An other solution I prefer to this one, because it's more efficient :
More efficient than what? It's wrong.
> my $from = 'your_adresse@your_domaine';
>
> open(IN,"<file_email") or die $!;
Good that you check the result of open. Bad that your error message
will be quite ambiguous. Always include the file name in an error
message about a failing open statement.
open(IN,"<file_email") or die "can't open 'file_email': $!";
> my @to = (<IN>);
^ ^
^ ^
Useless.
> close(IN);
>
> open(IN,"<text_to_send_file") or die $!;
> @text = (<IN>);
^ ^
^ ^
Useless.
> close(IN);
>
> my $sendmail = "/usr/sbin/sendmail -t";
> my $text = join(//,@text);
^^
^^
Check the manual page for the function you use:
$ perldoc -f join
join EXPR,LIST
Joins the separate strings of LIST into a single
string with fields separated by the value of EXPR,
and returns that new string.
The `//' is a useless use of the matching operator that will return a
"1" no matter what is in $_. That will be used to join the elements
of the @text array to form the $text string. Probably *not* what you
intended. Did you test this before posting?
Perhaps you meant join("", @text) instead?
But why go to that trouble in the first place? If you want the
contents of a file in a scalar variable, just use the $/ variable
as described in the perlvar manual page:
{
local($/);
$text = <IN>;
}
> my $subject = "What you want";
> my $tmp;
>
> foreach $tmp(@to)
> {
> open(OUT,"|$sendmail") or die $!;
> print OUT"From: $from\nTo: $to\nSubject: $subject\n\n";
> print OUT"$text\n";
> close(OUT);
Always check the result of a close of a pipe. Here's where most
errors will be reported.
unless ( close(OUT) ) {
die "close: $!" unless $! == 0;
die "$sendmail failed: $?";
}
> }
Others have mentioned better ways to spam.
--
Garry Williams
------------------------------
Date: Wed, 26 Sep 2001 14:03:33 +0800
From: s_tougard@hotmail.com (Stephane TOUGARD)
Subject: Re: emailing contents of text file
Message-Id: <slrn9r2rtl.26t.s_tougard@clipper.kirch>
In article <slrn9r2o8b.9ff.garry@zfw.zvolve.net>, Garry Williams wrote:
>> open(IN,"<text_to_send_file") or die $!;
>> @text = (<IN>);
> ^ ^
> ^ ^
> Useless.
What do you mean ?
>
>
>> close(IN);
>>
>> my $sendmail = "/usr/sbin/sendmail -t";
>> my $text = join(//,@text);
> ^^
> ^^
> Check the manual page for the function you use:
Sorry
my $text = join('',@text);
>>
> But why go to that trouble in the first place? If you want the
> contents of a file in a scalar variable, just use the $/ variable
> as described in the perlvar manual page:
>
> {
> local($/);
> $text = <IN>;
> }
One of my teachers said one day : " there are more people who speak the
C than Perl, always use a comprehensible way for a C coder "
Join is not a C function, but it's easyer to understand than redifine
the scalar who defines the separators of lines.
It's my point of view.
>>
> Always check the result of a close of a pipe. Here's where most
> errors will be reported.
>
> unless ( close(OUT) ) {
> die "close: $!" unless $! == 0;
> die "$sendmail failed: $?";
> }
I agree with you, it was only an exemple to show one other kind to do
and not a complete and tested code.
> Others have mentioned better ways to spam.
Sure.
------------------------------
Date: Wed, 26 Sep 2001 06:32:57 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: emailing contents of text file
Message-Id: <slrn9r2tkp.eug.mgjv@verbruggen.comdyn.com.au>
On Wed, 26 Sep 2001 14:03:33 +0800,
Stephane TOUGARD <s_tougard@hotmail.com> wrote:
> In article <slrn9r2o8b.9ff.garry@zfw.zvolve.net>, Garry Williams wrote:
>>> open(IN,"<text_to_send_file") or die $!;
>>> @text = (<IN>);
>> ^ ^
>> ^ ^
>> Useless.
>
> What do you mean ?
That those parentheses are not needed, and therefore are useless. At
least, that is what I would have meant, had I written "Useless".
> my $text = join('',@text);
>
>> But why go to that trouble in the first place? If you want the
>> contents of a file in a scalar variable, just use the $/ variable
>> as described in the perlvar manual page:
>>
>> {
>> local($/);
>> $text = <IN>;
>> }
>
> One of my teachers said one day : " there are more people who speak the
> C than Perl, always use a comprehensible way for a C coder "
Many people here, probably most, won't agree with your teacher. If you
want to write C, then use C. If you want to write Perl, then write
Perl. Do you also process all your strings character by character? And
don't you use hashes? After all, there are no hashes in C, and a C
programmer might get confused if you use one.
I must say, that comment is one of the dimmest ones I've seen in a
while, relating to how to write Perl code.
> Join is not a C function, but it's easyer to understand than redifine
> the scalar who defines the separators of lines.
>
> It's my point of view.
Fine. But where do you draw the line? No hashes? No regexes? Which of
these are easy enough to understand for aa C programmer:
grep, map, chomp, reverse, pop, push, shift, splice, pack/unpack,
binmode, die, -f and friends, continue, eval, redo, last?
And what about local, my and our? What about package, import, require
and use? What about bless? What about the lack of a switch statement?
Oh well.
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: Wed, 26 Sep 2001 07:36:45 +0200
From: "Christian Wanninger" <christian.wanninger@toshiba-tro.de>
Subject: Excel-Graphs
Message-Id: <9orphk$4fr$1@news.dtag.de>
Does anyone know how to generate Excel-graphs with perl??
Thanxx
------------------------------
Date: Wed, 26 Sep 2001 06:25:03 GMT
From: "Marc Logghe" <marc.nospam.logghe@devgen.com>
Subject: Re: Excel-Graphs
Message-Id: <3xes7.71717$6x5.15691793@afrodite.telenet-ops.be>
Hi Christian,
This should also be a possible answer to your other post about excel.
I think you can do this with the Win32::OLE module available at CPAN. If you
are familiar to creating graphs with visual basic within Excel, you can do
it with this module.
Succes.
Marc
"Christian Wanninger" <christian.wanninger@toshiba-tro.de> wrote in message
news:<9orphk$4fr$1@news.dtag.de>...
> Does anyone know how to generate Excel-graphs with perl??
>
> Thanxx
>
>
"Christian Wanninger" <christian.wanninger@toshiba-tro.de> wrote in message
news:9orphk$4fr$1@news.dtag.de...
> Does anyone know how to generate Excel-graphs with perl??
>
> Thanxx
>
>
------------------------------
Date: Wed, 26 Sep 2001 04:57:53 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: How To Copy Files in Script w/Shell?
Message-Id: <lfds7.678$Owe.311487488@news.frii.net>
In article <3bb14d67.8673524@news-server>,
Ralph Freshour <ralph@primemail.com> wrote:
>I want to run a perl script and do a backup of some of my files to
>another linux server. My test script below gives me errors when I do
>a perl -c on it Any help appreciated!
>
>
Here are my mods to your code.
Good luck
#!/usr/bin/perl -w
#backup2.pl
#
use Shell 'scp';
scp('/home/cust/*.cust', 'herring:/home/cust/');
exit(0);
--
This space intentionally left blank
------------------------------
Date: Wed, 26 Sep 2001 07:07:48 +0200
From: Philip Newton <pne-news-20010926@newton.digitalspace.net>
Subject: Re: How To Copy Files in Script w/Shell?
Message-Id: <kjo2rtkase4v0dqhqprg4f0lofvkhd5ffn@4ax.com>
On Wed, 26 Sep 2001 03:32:40 GMT, ralph@primemail.com (Ralph Freshour)
wrote:
> I want to run a perl script and do a backup of some of my files to
> another linux server. My test script below gives me errors when I do
> a perl -c on it Any help appreciated!
>
>
> #!/usr/bin/perl -w
> #backup2.pl
> #
>
> scp /home/cust/*.cust herring:/home/cust/
>
> exit(0);
Replace '/usr/bin/perl -w' with '/usr/bin/sh' and 'exit(0);' with
'exit'.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 26 Sep 2001 05:35:50 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: How To Copy Files in Script w/Shell?
Message-Id: <3BB16829.3E35589F@rochester.rr.com>
Ralph Freshour wrote:
>
> I want to run a perl script and do a backup of some of my files to
> another linux server. My test script below gives me errors when I do
> a perl -c on it Any help appreciated!
>
> #!/usr/bin/perl -w
> #backup2.pl
> #
>
> scp /home/cust/*.cust herring:/home/cust/
>
> exit(0);
Well, it looks like your single line of code isn't Perl code, but shell
script code. It would be kind of silly (because, since your program
consists of a single line of shell code, it would be much easier and
more efficient to just run it in a shell script), but if you really want
to run it from Perl, do one of:
`scp /home/cust/*.cust herring:/home/cust/`;
or
system('scp /home/cust/*.cust herring:/home/cust/');
or
exec('scp /home/cust/*.cust herring:/home/cust/');
--
Bob Walton
------------------------------
Date: Wed, 26 Sep 2001 07:27:07 +0200
From: Philip Newton <pne-news-20010926@newton.digitalspace.net>
Subject: Re: How to fetch all html files under a web directory
Message-Id: <rnp2rts7orevdreu92j89siea8bigf1evg@4ax.com>
On 25 Sep 2001 15:21:30 -0700, baobaoba@yahoo.com (baobaoba) wrote:
> Is there a wget function?
No, it's a compiled program.
> And any man page for that?
man wget, after you've installed it.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 26 Sep 2001 00:34:49 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: How to fetch all html files under a web directory
Message-Id: <comdog-FB0E3C.00344926092001@news.panix.com>
In article <25212a12.0109251013.886eff1@posting.google.com>,
baobaoba@yahoo.com (baobaoba) wrote:
> I am trying to download all html files from a website, suppose it is:
> http://www.abc.com/some_directory/
> I know there are a lot of html files under "some_directory", but I
> don't know their names and how many there are.
you have to know their names. someone can tell you what they are or
you can find some sort of page that lists links to them all.
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Wed, 26 Sep 2001 04:35:52 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: ONE QUESTION
Message-Id: <slrn9r2mp8.eug.mgjv@verbruggen.comdyn.com.au>
On 25 Sep 2001 21:04:50 -0700,
hugh1 <weiwe1@yeah.net> wrote:
> IN BOOK <<advanced programming perl >>
>
> charpe six package auto load .
This almost sounds as incomprehensible as the "Big Berta Thing" posts.
I've been looking at it for almost a whole minute now, and I still
have absolutely no clue what this is supposed to mean. Four of the
five words are recognisable, but they make no sense together... Oh
well..
> sub AUTOLOAD {
>
> .....some creat sub function.....
>
> goto &$AUTOLOAD-----------> IT will del the AUTOLOAD sub
> function's stack. WHY ???
The AUTOLOAD routine doesn't have a stack. It does have a stack frame
when it is running. What goto &name will do is substitute the call to
the current subroutine with another call. If you insist on using the
term stack: It will replace the stack frame of the current subroutine
with the called one.
Why? Because it was designed to do exactly that.
See the entry for goto in the perlfunc documentation. Also maybe have
a look at the perlsub documentation.
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Wed, 26 Sep 2001 04:32:28 GMT
From: "Fat Boy" <simercer@NOSPAMhotmail.com>
Subject: sendmail gadget works on one server, not on another
Message-Id: <wTcs7.21211$L8.4144068@news2.rdc1.bc.home.com>
Hi there
I had this part of a shopping cart working on one host (best.com) but not on
another (verio.com) and they can't help.
Check it out:
I apologixe this is so long, but really I've busted my nuts trying to find
out why it doesn't work anymore. My greatest appreciation for anyone who
could take a look and offer some suggestions.
Thanks
Jody
(see below)
#######################################################################
# Application Information #
########################################################################
# Application Name: SENDMAIL_LIB.PL
# Application Authors: Gunther Birznieks and Eric Tachibana (Selena Sol)
# Version: 1.0
# Last Modified: 17NOV98
#
# Copyright:
#
# You may use this code according to the terms specified in
# the "Artistic License" included with this distribution. The license
# can be found in the "Documentation" subdirectory as a file named
# README.LICENSE. If for some reason the license is not included, you
# may also find it at www.extropia.com.
#
# Though you are not obligated to do so, please let us know if you
# have successfully installed this application. Not only do we
# appreciate seeing the wonderful things you've done with it, but we
# will then be able to contact you in the case of bug reports or
# security announcements. To register yourself, simply send an
# email to register@extropia.com.
#
# Finally, if you have done some cool modifications to the scripts,
# please consider submitting your code back to the public domain and
# getting some community recognition by submitting your modifications
# to the Extropia Cool Hacks page. To do so, send email to
# hacks@extropia.com
#
# Description:
#
# Provides a set of library routines to send email
# over the internet.
#
# Main Procedures:
#
# real_send_mail - flexible way to send email
# send_mail - easier to use version of send_mail
#
# Special Notes:
#
# Script is UNIX Specific and ties into the
# Sendmail Program which is usually located in /usr/lib or
# /usr/bin. If you want to use this for Windows or Macintosh
# CGI scripts, you must copy the contents of smtp-mail.lib
# over this. You can get that file at www.extropia.com
#
# Also, remember to escape @ signs with a backslash (\@)
# for compatibility with PERL 5.
#
# Change the $mail_program variable to change location of your
# sendmail program
#
# Basic Usage:
#
# 1. The file should have read access but need not have write access
# nor execute access.
#
# More Information
#
# You will find more information in the Documentation sub-directory.
# We recommend opening the index.html file with your web browser to
# get a listing of supporting documentation files.
########################################################################
# Application Code #
########################################################################
# $mail_program is the mail program used to send mail
# with the full path.
#
# The -t flag tells sendmail to
# look for To:, From:, Subject: header lines in the
# mail message to determine the addresses to send to.
#
# NOTE: BY DEFAULT, I AM NOT USING -n and -f flags.
#
# -n is not supported by QMAILs sendmail replacement.
#
# -f is useful for special cases and can be added as needed.
#
# The -n flag tells sendmail not to use the alias list
# for the UNIX server. We do not want outsiders using
# the alias list of the webserver in most cases.
#
# The -f flag followed by an email address of your choice
# basically tells sendmail that this email address
# should have bounced mails forwarded. Use of this flag
# was suggested by Ignacia Bustamante.
#
$flags = "-t -n -f";
# The following code checks for versions of
# sendmail and lets the user know if one of the
# default locations does not exist.
#
# The code for this trick was donated by Scott Wimer
# with some slight modification by Gunther for command
# line flag flexibility at the end
$mailer = '/usr/lib/sendmail';
$mailer1 = '/usr/bin/sendmail';
$mailer2 = '/usr/sbin/sendmail';
if ( -e $mailer) {
$mail_program=$mailer;
} elsif( -e $mailer1){
$mail_program=$mailer1;
} elsif( -e $mailer2){
$mail_program=$mailer2;
} else {
print "Content-type: text/html\n\n";
print "I can't find sendmail, shutting down...<br>";
print "Whoever set this machine up put it someplace weird.";
exit;
}
# Add the command line flags
$mail_program = "/usr/sbin/sendmail -t -n";
############################################################
#
# subroutine: real_send_mail
# Usage:
# &send_mail("me@myhouse.com","myhouse.com","you@yourhouse.com",
# "yourhouse.com", "Mysubject", "My message");
#
# Parameters:
# $fromuser = Full Email address of sender
# $fromsmtp = Full Internet Address of sender's SMTP Server
# $touser = Full Email address of receiver
# $tosmtp = Full Internet Address of receiver's SMTP Server
# $subject = Subject of message
# $messagebody = Body of message including newlines.
#
# Output:
# None
############################################################
sub real_send_mail {
local($fromuser, $fromsmtp, $touser, $tosmtp,
$subject, $messagebody) = @_;
# First we need to start the mail program and open
# a PIPE to the program so that anything
# we print to the filehandle, goes to the running
# program.
# The path manipulation is to satisfy taint mode
#
local($old_path) = $ENV{"PATH"};
$ENV{"PATH"} = "";
open (MAIL, "|$mail_program") ||
&web_error("Could Not Open Mail Program");
$ENV{"PATH"} = $old_path;
#
# Print the mail message to the Mail Program
# using the HERE Document method
#
# Note: SOME ISPs may have a faulty
# sendmail implementation that does
# not recognize the From: header unless
# the order of these is changed from
# To: From: Subject:
# to
# Subject: To: From:
#
# This was pointed out by Paul Tate.
#
print MAIL qq!Subject: $subject
To: $touser
From: $fromuser
$messagebody
!;
close (MAIL);
} #end of real_send_mail
############################################################
#
# subroutine: send_mail
# Usage:
# &send_mail("me@myhouse.com","you@yourhouse.com",
# "Mysubject", "My message");
#
# Parameters:
# $fromuser = Full Email address of sender
# $touser = Full Email address of receiver
# $subject = Subject of message
# $messagebody = Body of message including newlines.
#
# Output:
# None
#
############################################################
sub send_mail {
local($from, $to, $subject, $messagebody) = @_;
local($fromuser, $fromsmtp, $touser, $tosmtp);
# This routine takes the simpler parameters of
# send_mail and breaks them up into the parameters
# to be sent to real_send_mail.
#
$fromuser = $from;
$touser = $to;
#
# Split is used to break the address up into
# user and hostname pairs. The hostname is the
# 2nd element of the split array, so we reference
# it with a 1 (since arrays start at 0).
#
$fromsmtp = (split(/\@/,$from))[1];
$tosmtp = (split(/\@/,$to))[1];
# Actually call the sendmail routine with the
# newly generated parameters
#
&real_send_mail($fromuser, $fromsmtp, $touser,
$tosmtp, $subject, $messagebody);
} # End of send_mail
############################################################
#
# subroutine: web_error
# Usage:
# &web_error("File xxx could not be opened");
#
# Parameters:
# $error = Description of Web Error
#
# Output:
# None
#
############################################################
sub web_error {
local ($error) = @_;
$error = "Error Occured: $error";
print "$error<p>\n";
# Die exits the program prematurely and prints an error to
# stderr
die $error;
} # end of web_error
1;
------------------------------
Date: Wed, 26 Sep 2001 04:51:58 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: sendmail gadget works on one server, not on another
Message-Id: <slrn9r2nnf.eug.mgjv@verbruggen.comdyn.com.au>
On Wed, 26 Sep 2001 04:32:28 GMT,
Fat Boy <simercer@NOSPAMhotmail.com> wrote:
> Hi there
>
> I had this part of a shopping cart working on one host (best.com) but not on
> another (verio.com) and they can't help.
They can't or won't help?
> Check it out:
No warnings, no strictures. General coding quality: crappy. CGI
program that doesn't use CGI module, nor taint checking.
I'd not even consider using this.
> # Application Name: SENDMAIL_LIB.PL
> # Application Authors: Gunther Birznieks and Eric Tachibana (Selena Sol)
Why don't you contact the authors? The Selena Sol stuff is generally
not considered to be great around here, and if this example is
representative, that's no wonder.
> # $mail_program is the mail program used to send mail
>
> # with the full path.
Why all the blank lines?
> $mailer = '/usr/lib/sendmail';
> $mailer1 = '/usr/bin/sendmail';
> $mailer2 = '/usr/sbin/sendmail';
*sigh*, how terribly clunky.
> if ( -e $mailer) {
> $mail_program=$mailer;
[snip]
> # Add the command line flags
> $mail_program = "/usr/sbin/sendmail -t -n";
Good quality code always does a lot of work first, and then discards
it all by overwriting the result of that work.
And here I stop reading.
My advice:
1 - Scrap this junk
2 - Read the Perl FAQ, section 9
3 - Use the CGI module, and one of the Mail modules available from
CPAN
4 - If you don't know how to do all that, either learn it, or hire
someone to do it for you. We don't generally write other people's
programs for them here, nor do we fix crap code like this.
5 - if you want scripts fixed, instead of writing code yourself, hire
a programmer.
If you get yourself one of the Mail modules (Mail::Sendmail comes to
mind) your program will become much more portable. If you use warnings
and strictures, it'll become much more maintainable. If you enable
taint checking it'll become safer.
Martien
--
Martien Verbruggen |
Interactive Media Division | I took an IQ test and the results
Commercial Dynamics Pty. Ltd. | were negative.
NSW, Australia |
------------------------------
Date: Wed, 26 Sep 2001 07:05:37 +0200
From: Philip Newton <pne-news-20010926@newton.digitalspace.net>
Subject: Re: Setting max. values (cpu/ram usage) for mod_perl scripts?
Message-Id: <vbo2rtc7236g59aq8b5mppcsqiarnmcl6p@4ax.com>
On Tue, 25 Sep 2001 14:33:19 +0200, EXP <nospaming@gmx.net> wrote:
> Hi
>
> I wonder, is it somehow possible to restrict the maximal cpu usage and
> ram usage for apache mod_perl scripts?
Try BSD::Resource. That lets you set cpu, filesize, data size, stack
size, ... limits on a per-process basis. So each script would have to do
its own setting.
On the other hand, Apache may also have a way of doing this, but I don't
know Apache -- try a web server group.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 25 Sep 2001 23:52:49 -0700
From: weiwe1@yeah.net (hugh1)
Subject: Re: Socket question
Message-Id: <7dcf30ba.0109252252.61eaf93c@posting.google.com>
merlyn@stonehenge.com (Randal L. Schwartz) wrote in message
> Stop using hard-to-use interfaces!
use model is easy and clearly understand .
but know the basic principle is very important.
stop using but understand it deeply!
------------------------------
Date: Wed, 26 Sep 2001 06:28:32 +0200
From: Philip Newton <pne-news-20010926@newton.digitalspace.net>
Subject: Re: Sorting Hashes
Message-Id: <iml2rt8iji7rjo9pisg028gu88k6305bod@4ax.com>
On 24 Sep 2001 08:19:46 +0100, nobull@mail.com wrote:
> "Michael J. Vincent" <mjvincent@lucent.com> writes:
>
> > $hash{172.16.5.1} = 5
>
> You probably need quotes in there. Without them 172.16.5.1 is interpreted as
> chr(172).chr(16).chr(5).chr(1) and I strongly suspect that's not what
> you wanted.
Or in older Perls, as 172.16 . 5.1 (the concatenation of two
floating-point numbers), i.e. '172.165.1', which looks the same as
172.1.65.1, for example.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 26 Sep 2001 00:40:44 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Why use Sys::Hostname instead of just $ENV{SERVER_NAME} with inet_ntoa(scalar gethostbyname($ENV{SERVER_NAME} || 'localhost'))
Message-Id: <comdog-26A14E.00404426092001@news.panix.com>
In article <19caa707.0109251006.61f51a16@posting.google.com>,
amiwebguy@yahoo.com (Justin) wrote:
> I'm concearned about speed in my script where I'm trying to find the
> IP of the web server. Can anyone please expand on why i should/not
> use Sys::Hostname instead of just $ENV{SERVER_NAME}
well, Sys::Hostname doesn't necessarily tell you the IP address of the
server if the machine has several interfaces.
if it's speed that concerns you ( if you are optimizing at this level
then you probably need to optimize away perl ), then just Benchmark the
parts that concern you. you'll probably find, however, that other more
interesting parts of the program take up more of the computer's time.
:)
brian[1473]$ cat test.pl
#!/usr/bin/perl
use Benchmark qw(countit timestr);
use Sys::Hostname;
$ENV{SERVER_NAME} = 'www.perl.org';
my $host = <<'HERE';
$hostname = hostname();
HERE
my $env = <<'HERE';
$hostname = $ENV{'SERVER_NAME'};
HERE
my $t = countit(30, $host);
my $count = $t->iters ;
print "$count loops of host took: ", timestr($t), "\n";
my $t2 = countit(30, $env);
my $count2 = $t2->iters;
print "$count2 loops of env took: ", timestr($t2), "\n";
"test.pl" 24L, 440C written
brian[1472]$ perl test.pl
6038427 loops of host took: 32 wallclock secs (31.08 usr + 0.00 sys = 31.08 CPU) @ 194298.30/s (n=6038427)
21068226 loops of env took: 32 wallclock secs (31.40 usr + 0.00 sys = 31.40 CPU) @ 670996.00/s (n=21068226)
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: Wed, 26 Sep 2001 07:47:29 +0200
From: "Christian Wanninger" <christian.wanninger@toshiba-tro.de>
Subject: Zoom in Excel Sheets
Message-Id: <9orq5p$6oi$1@news.dtag.de>
Does anyone know how to set the zoom with Perl in Excelsheets?
Thanxx
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1819
***************************************