[11162] in Perl-Users-Digest
Perl-Users Digest, Issue: 4762 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 27 16:07:16 1999
Date: Wed, 27 Jan 99 13:00:19 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 27 Jan 1999 Volume: 8 Number: 4762
Today's topics:
? Sessions in CGI, Perl, Apache, Unix ? <fp@DynamicNet.net>
Re: Arrays vs Hashes. (M.J.T. Guy)
Can someone give me information as to where i could fin <shivapal@hotmail.com>
Checking for flock <jeff@vpservices.com>
Compiling perl script for independent execution (Daveotlc)
Re: Compiling perl script for independent execution (Sam Holden)
Re: Compiling PERL5.005_02 on a Sun Ultra 2 w/o Solaris (Randy Kobes)
Re: Compiling PERL5.005_02 on a Sun Ultra 2 w/o Solaris <Peter.J.Messore.1@gsfc.nasa.gov>
Dereferencing and element of an array <scrosby@jacqueswhitford.com>
Re: Dereferencing and element of an array (Sam Holden)
Globbing. jambutter@my-dejanews.com
Re: Globbing. (Sam Holden)
re: golb and ARGV (with my brain on line) halxd2@my-dejanews.com
Gosh, s// faster than m// (was Re: Counting characters <jdf@pobox.com>
Re: How do I expand a variable within `'s (M.J.T. Guy)
multi column sort in perl <ryan.h.bark@boeing.com>
Re: Newbie Question <staffan@ngb.se>
Re: please help: outputting line number to display (Larry Rosler)
Re: please help: outputting line number to display (Tad McClellan)
Re: Q: CPAN on Win32 (Windows NT) Perl (Randy Kobes)
Re: Removing New Lines in Form Fields <r2-d2@REMOVEbigfoot.com>
Re: sendmail part deux (Tad McClellan)
Re: system function, Pros and Cons?? <jc@uwm-dev.gte.com>
Re: system function, Pros and Cons?? <upsetter@ziplink.net>
Re: Using a variable as a variable name <emschwar@mail.uccs.edu>
Re: WANTED: Perl Programmer (London/UK) <gellyfish@btinternet.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 27 Jan 1999 12:58:13 -0500
From: "Peter Perchansky, Microsoft FrontPage MVP" <fp@DynamicNet.net>
Subject: ? Sessions in CGI, Perl, Apache, Unix ?
Message-Id: <78nk7n$ld1$2@usenet46.supernews.com>
Greetings:
In NT you have sessions (time outs, et all) where you can keep track of each
user's session in RAM (or via a cookie).
Is there a way on Apache/Unix where you can create a session for a visitor
(aka shopping cart session), and keep track of the session time?
In NT you can do response.isClientConnected to see if a client browser is
connected to the web site; is there any equivalent in Apache/Unix via Perl
or PHP?
Reason: Shopping carts keeping track of the state of the shopper / browser
and the cart.
Note: If there are methods that can be implemented without mod_perl, please
let me know.
Thank you.
P.S. If convenient, please send a copy of your reply to email.
--
===========================================================
Peter M. Perchansky, Internet Specialist & Microsoft FrontPage MVP
Dynamic Net, Inc.
Providing Dynamic Databases, Design, & Electronic Commerce Solutions
FrontPage Web Hosting at http://DynamicNet.net/services/fpwebhosting.htm
FrontPage Support http://DynamicNet.net/support/frontpage.htm
FrontPage 98 Training CD at http://www.gosoft.com/fp98/pmpcs/
------------------------------
Date: 27 Jan 1999 18:04:54 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Arrays vs Hashes.
Message-Id: <78nkg6$r1o$1@pegasus.csx.cam.ac.uk>
In article <36ACC958.3D9F@daytonoh.ncr.com>,
Dennis Kowalski <dennis.kowalski@daytonoh.ncr.com> wrote:
>jambutter@my-dejanews.com wrote:
>>
>> Can somewhene tell me when it is best recommened to use a hash as opposed to
>> an array, and vice versa.
>
>Depends on what the search criteria is.
>
>If the search key to retrieve an element is a number (i.e. 5), an array
>will work fine.
Make that "a fairly small number". Perl isn't very happy about sparse
arrays.
But of course, 5 is a fairly small number. :-)
Mike Guy
------------------------------
Date: Wed, 27 Jan 1999 11:33:20 -0600
From: siv <shivapal@hotmail.com>
Subject: Can someone give me information as to where i could find a perl version for windows 3.1
Message-Id: <36AF4DE0.3955@hotmail.com>
Hai,
We have a very highly distributed setup and the application has a
poll process (job sheduler) which run on a windows machine 3.1
I want to write a perl script to parse the error log and send me a
message if there are error.....
I would really appretiate if someone could give me information as to
where i could find a perl version which runs on windows 3.1.........
Thanks
Siva
------------------------------
Date: 27 Jan 1999 19:24:28 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Checking for flock
Message-Id: <36AF66E7.57EB29FC@vpservices.com>
Is there a better way to check if flock is implemented on a machine than
this subroutine?
sub has_flock {
my $flock_status = 1;
open(FH,$0) || die $!;
undef $@;
eval( "flock(FH,8)" );
if ( $@ =~ /unimplemented/ ) { $flock_status = 0; }
close(FH) || die $!;
return $flock_status;
}
--
Jeff Zucker \/ mailto:jeff@vpservices.com
Co-coordinator -<>- http://www.unicef.org/voy/
UNICEF Voices of Youth /\ http://www.vpservices.com/jeff/
------------------------------
Date: 27 Jan 1999 18:43:10 GMT
From: daveotlc@aol.com (Daveotlc)
Subject: Compiling perl script for independent execution
Message-Id: <19990127134310.14595.00004818@ng142.aol.com>
I want to ship an application to some friends and use a Perl script to
install it. Since they might not have Perl on their machine, it would
be nice to be able to compile the install script. The application runs
on a 32 bit Windows platform. Can you point me to information about the
Perl compiler?
Thanks,
Dave Olson
------------------------------
Date: 27 Jan 1999 18:59:59 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Compiling perl script for independent execution
Message-Id: <slrn7auohf.j2c.sholden@pgrad.cs.usyd.edu.au>
On 27 Jan 1999 18:43:10 GMT, Daveotlc <daveotlc@aol.com> wrote:
>I want to ship an application to some friends and use a Perl script to
>install it. Since they might not have Perl on their machine, it would
>be nice to be able to compile the install script. The application runs
>on a 32 bit Windows platform. Can you point me to information about the
>Perl compiler?
FAQ.
perlfaq3 to be more specific...
'How can I compile my Perl program into byte code or C?' to be even more
specific...
There's also some windows specific packages that I know nothing about.
I think that using perl for your install script might be counter-productive
if perl is not already installed. Then again I don't know how big install
programs are usually under windows, so maybe it's not a problem.
--
Sam
Perl was designed to be a mess (though in the nicest of possible ways).
--Larry Wall
------------------------------
Date: 27 Jan 1999 18:11:01 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: Compiling PERL5.005_02 on a Sun Ultra 2 w/o Solaris 2.6 OS
Message-Id: <slrn7aum7v.ses.randy@theory.uwinnipeg.ca>
On 27 Jan 1999 16:34:19 +0100,
Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> wrote:
>Re: Compiling PERL5.005_02 on a Sun Ultra 2 w/o
>Solaris 2.6 OS, Peter
><Peter.J.Messore.1@gsfc.nasa.gov> said:
>
>Peter> utilities we've written. We've been using the
>Peter> instructions in the INSTALL file and using
>Peter> all of the defaults the configure shell
>Peter> suggests. However when it comes to issuing
>Peter> the make command we get nothing but errors.
>
>And these errors would be...what? Oh, you didn't
>tell us. I'll take a stab though: you don't have a
>C compiler on the box.
Hi,
That is annoying that Solaris doesn't normally come
with a C compiler; there are precompiled gcc-packages available.
Another mildly annoying thing is that, depending on how the installation
was chosen, make and friends may not have been installed
by default, and then when they are, they are put in a place
like /usr/ccs/bin that may not be part of your PATH.
However, wouldn't the Configure stage complain already
that a C compiler and/or various tools weren't found, and
stopped at this point? More details about the errors will
be needed ...
--
Best regards,
Randy Kobes
Physics Department Phone: (204) 786-9399
University of Winnipeg Fax: (204) 774-4134
Winnipeg, Manitoba R3B 2E9 e-mail: randy@theory.uwinnipeg.ca
Canada http://theory.uwinnipeg.ca/
------------------------------
Date: Wed, 27 Jan 1999 13:56:17 -0500
From: "Peter J. Messore" <Peter.J.Messore.1@gsfc.nasa.gov>
To: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Compiling PERL5.005_02 on a Sun Ultra 2 w/o Solaris 2.6 OS
Message-Id: <36AF6144.7B5DE163@gsfc.nasa.gov>
Tony>And these errors would be...what? Oh, you didn't
Tony>tell us. I'll take a stab though: you don't have a
Tony>C compiler on the box.
We currently have Sun WorkShop Compilers C/C++ 4.2 and they are up and
working just fine.
upon typing "make" we get:
make: Warning: Both `makefile' and `Makefile' exist
`sh cflags libperl.a miniperlmain.o` miniperlmain.c
CCCMD = cc -DPERL_CORE -c -O
"./perlvars.h", line 21: invalid token: ##
"./perlvars.h", line 21: undefined or not a type: PL_
"./perlvars.h", line 21: syntax error before or at: Gcurinterp
"./perlvars.h", line 21: warning: old-style declaration or incorrect
type for: G curinterp
And they continue on and on for perlvars.h as well as for the file
intrpvar.h and thrdvar.h
Any ideas?
Thanks.
- Peter
------------------------------
Date: Wed, 27 Jan 1999 15:22:23 -0400
From: Shawn Crosby <scrosby@jacqueswhitford.com>
Subject: Dereferencing and element of an array
Message-Id: <36AF676F.CC3CD5E3@jacqueswhitford.com>
I'm a bit of a newbie to perl, but I've been scratching my head over
this one for a few days now.
I want to pass a reference to a multi-dimensional array to a subroutine
and then compare 2 elements of the array...the end result being to only
print unique values in a list of repeated values. I've tried several
ways of writing it, but every time the sub ALWAYS behaves as if the 2
elements are equal
#!/usr/bin/perl
my @col1=(1, 1, 1, 2, 2, 2, 3, 3, 3, 4); #print only the first of each
repeated value in funct
my @col2=(6, 5, 3, 7, 5, 3, 4, 3, 6, 2);
my @data=([@col1], [@col2]);
&funct(\@data);
sub funct($) # \@data
{
my $d=shift;
for $i (0..9){
next if ($d->[0][$i]==$d->[0][$i-1]);
print "$d->[0][$i]\n";
}
}
---desired output---
1
2
3
4
There mus be some simple way of doing this....help
Shawn Crosby
scrosby@jacqueswhitford.com
------------------------------
Date: 27 Jan 1999 20:21:05 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Dereferencing and element of an array
Message-Id: <slrn7aut9h.k78.sholden@pgrad.cs.usyd.edu.au>
On Wed, 27 Jan 1999 15:22:23 -0400, Shawn Crosby <scrosby@jacqueswhitford.com>
wrote:
>I'm a bit of a newbie to perl, but I've been scratching my head over
>this one for a few days now.
>
>I want to pass a reference to a multi-dimensional array to a subroutine
>and then compare 2 elements of the array...the end result being to only
>print unique values in a list of repeated values. I've tried several
>ways of writing it, but every time the sub ALWAYS behaves as if the 2
>elements are equal
If the unique values thing is what you really want the why not try :
perlfaq4 : How can I extract just the unique elements of an array?
>
>#!/usr/bin/perl
>
>my @col1=(1, 1, 1, 2, 2, 2, 3, 3, 3, 4); #print only the first of each
>repeated value in funct
>my @col2=(6, 5, 3, 7, 5, 3, 4, 3, 6, 2);
>my @data=([@col1], [@col2]);
>
>&funct(\@data);
>
>sub funct($) # \@data
> {
> my $d=shift;
> for $i (0..9){
> next if ($d->[0][$i]==$d->[0][$i-1]);
That line is going to do probably what you don't expect if the first and last
elements of the array are the same. Remember $array[-1] gives the last element
of @array.
> print "$d->[0][$i]\n";
> }
> }
>
>---desired output---
>1
>2
>3
>4
And how does that differ from what you get ???????
And I hope you are doing all that refence dancing, and passing that second
array for a reason which you snipped to make the example simpler...
--
Sam
Of course, in Perl culture, almost nothing is prohibited. My feeling is
that the rest of the world already has plenty of perfectly good
prohibitions, so why invent more? --Larry Wall
------------------------------
Date: Wed, 27 Jan 1999 18:26:29 GMT
From: jambutter@my-dejanews.com
Subject: Globbing.
Message-Id: <78nlo8$cq0$1@nnrp1.dejanews.com>
Can someone tell me what's wrong with the following...
sub CheckForFiles
{
my $c = $_[0];
while (defined($nextfile = <${c}>))
{
print $nextfile."\n";
}
}
What gets passed to the sub routine is a path, like "/dir/*".
I've tried it using <${_[0]}>, but it doesn't like that either.
Thanks.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 27 Jan 1999 18:54:26 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Globbing.
Message-Id: <slrn7auo72.j2c.sholden@pgrad.cs.usyd.edu.au>
On Wed, 27 Jan 1999 18:26:29 GMT, jambutter@my-dejanews.com wrote:
>Can someone tell me what's wrong with the following...
>
>sub CheckForFiles
>{
> my $c = $_[0];
>
> while (defined($nextfile = <${c}>))
> {
> print $nextfile."\n";
> }
>}
>
>What gets passed to the sub routine is a path, like "/dir/*".
>
>I've tried it using <${_[0]}>, but it doesn't like that either.
It does exactly what I would expect it to...
So what do you expect it to do?
What does it actually do when you try it?
--
Sam
PC's are backwards ... throw them out! Linux is ok though.
--Rob Pike (on the subject of CR/LF etc)
------------------------------
Date: Wed, 27 Jan 1999 20:00:27 GMT
From: halxd2@my-dejanews.com
Subject: re: golb and ARGV (with my brain on line)
Message-Id: <78nr8l$htr$1@nnrp1.dejanews.com>
In article <78ljc0$m1s$1@nnrp1.dejanews.com>,
halxd2@my-dejanews.com wrote:
> passing files with wild cards like *.txt is fine. Just use
> my @file = glob "@ARGV";
OK "@ARGV" is needed in an environment that passes the golb to the
file at execute time. Linux passes all the file names matching. So
"run.pl *.txt and.more" passes "1.txt 2.txt 3.txt and.more" to run.pl
In Win32 land the same command passes "*.txt and.more". That's why
I said you needed to pass "@ARGV" and that it needed to be an array,
not just the "$ARGV[0]" that you could in Win32. Sorry. As for shift
that makes it possible to use args from the command line in Linux.
you don't need to in Win32.
hal
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 27 Jan 1999 18:10:57 +0100
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Gosh, s// faster than m// (was Re: Counting characters with tr/// (in perl))
Message-Id: <m3ognkproe.fsf_-_@joshua.panix.com>
martin@RADIOGAGA.HARZ.DE (Martin Vorlaender) writes:
> David Pratt (David_J_Pratt@sbphrd.com) wrote:
> : > eval "\$count = \$search =~ tr/$find//";
>
> I've got notice via e-mail that while this works, it's very slow (because
> of the eval). Probably the best (most performant) solution is
>
> $count = $search =~ s/$find/$find/g;
This sent me running to Benchmark, thinking that surely m/$find/g
would be faster still, but was amazed to discover the following:
#!/usr/bin/perl -w
use Benchmark;
my $foo = 'a';
my $bucket = 'jadaasddiodkadaadalklaaalajlaa';
my $c;
sub substitute { $bucket =~ s/$foo/$foo/g }
sub match_1 { scalar (() = $bucket =~ m/$foo/g) }
sub match_2 { $c=0; ++$c while $bucket =~ m/$foo/g; $c }
timethese( 200_000, {
match_1 => \&match_1,
match_2 => \&match_2,
substitute => \&substitute,
});
__END__
Benchmark: timing 200000 iterations of match_1, match_2, substitute...
match_1: 13 wallclock secs (13.39 usr + 0.01 sys = 13.40 CPU)
match_2: 10 wallclock secs ( 9.89 usr + 0.00 sys = 9.89 CPU)
substitute: 6 wallclock secs ( 7.10 usr + 0.00 sys = 7.10 CPU)
Any comments on what I consider to be starkly weird?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 27 Jan 1999 18:53:58 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: How do I expand a variable within `'s
Message-Id: <78nnc6$hg$1@pegasus.csx.cam.ac.uk>
John Morse <john.morse@symbios.com> wrote:
>What I'm trying to do is expand a command line argument within
>back-tics. Below is not my actual code but an example of what I'm
>trying to do. With supplying only one command line argument, then
>expand it within back-tics, as an argument to a command.
>
>
>if($#ARGV < 0) {
> printf ("Usage: %s <argh>\n",$0);
> exit;
>}
>
>`echo @ARGV`;
>
>
>Well, as you all know, this doesn't work.
Depends what you you mean by work. It certainly does a lot of work to
no purpose.
perldoc -q backticks may be enlightening.
Mike Guy
------------------------------
Date: Wed, 27 Jan 1999 17:41:29 GMT
From: "Ryan Bark" <ryan.h.bark@boeing.com>
Subject: multi column sort in perl
Message-Id: <F68Bt6.G5L@news.boeing.com>
Suppose I have an array with the following columns on each line:
"col1 col2 col3 col4"
Is there a way in perl, to sort this list by col3, then col2 and col4?
------------------------------
Date: Wed, 27 Jan 1999 21:37:22 +0100
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: Newbie Question
Message-Id: <36AF7902.37D668D4@ngb.se>
Hi!
Appart from the code not working for the mentioned reasons (although
@a[$count] works, since it's an array slice of one element being
evaluated in a scalar context, I think):
> if (@a[$count] = 'two') { $count++ }
you're using assignment (=) instead of comparison (==), and besides, you
should use 'eq' for string comparison. Using this code
for(@a) {
print unless /two/;
}
is perhaps the elegant way to do it --- for iterates through an array
automatically, and assigns the current value to '$_'. '$_' is the
default value to a lot of functions, among them print. /two/ is a
pattern match on the default value. But do yourself a favour: Print the
manuals and read them, over and over. Lot's of smart ideas. Also: Use
perl -w, and you'll get some warnings. Also use 'use strict'.
Staffan
------------------------------
Date: Wed, 27 Jan 1999 10:14:30 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: please help: outputting line number to display
Message-Id: <MPG.1118f75bb95346809899d3@nntp.hpl.hp.com>
In article <m3n234prkz.fsf@joshua.panix.com> on 27 Jan 1999 18:13:00
+0100, Jonathan Feinberg <jdf@pobox.com> says...
> 23_skidoo <23_skidoo@geocities.com> writes:
>
> > is there a way to get perl to output the line number it is executing
> > at any given point so i don't have to change these by hand?
>
> $ perldoc -f warn
> $ perldoc -f die
Those are fine ways to get prepackaged messages. One might also
consider using these special literals described in perldata:
Three special literals are __FILE__, __LINE__, and __PACKAGE__, which
represent the current filename, line number, and package name at that
point in your program. They may be used only as separate tokens; they
will not be interpolated into strings. If there is no current package
(due to an empty package; directive), __PACKAGE__ is the undefined
value.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 27 Jan 1999 14:29:59 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: please help: outputting line number to display
Message-Id: <70tn87.dl.ln@magna.metronet.com>
23_skidoo (23_skidoo@geocities.com) wrote:
: i'm trying to write debugging lines into a large script, to help myself
: out on open commands i'm using the following:
: open (UPDATE, ">$datafile") || print "can't open $datafile line
: 476<br>";
: this is fine until i change something higher up in the script then the
: line numbers in the printout no longer match.
: is there a way to get perl to output the line number it is executing at
: any given point so i don't have to change these by hand?
die() and warn() will both output the line number if their
argument string does not end in a newline.
So,
s/print/warn/ above will do it.
: thanks for any help or sugegstions
One suggestion would be to _say_ that you are using Perl in a
CGI environment.
Most Perl is *not* used in that environment, so we will assume
the most common case, unless you tell us that you are using
the uncommon case...
My answer above isn't going to work in that environment, unless
you redirect STDERR to STDOUT.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 27 Jan 1999 17:56:45 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: Q: CPAN on Win32 (Windows NT) Perl
Message-Id: <slrn7auld3.ses.randy@theory.uwinnipeg.ca>
On Wed, 27 Jan 1999 16:04:47 GMT,
Denis.Haskin@bigfoot.com <Denis.Haskin@bigfoot.com> wrote:
>Does anyone have recommendations on getting CPAN to work well on Win32
>(Windows NT) Perl (the standard perl, 5.005.02, not the ActiveState version)?
>
>I've got CPAN 1.47 (the latest), but the stumbling block appears to be tar
>and gzip. I've got external zip program(s) that know how to handle tar and
>gzip files (e.g. pkzip 2.50 command line) but CPAN appears to be trying to
>send only the standard options (e.g. -decompress), which pkzip doesn't grok.
>An alternative would be to have tar and gzip programs that obey the usual
>Unix command line options--anyone have any good recommendations of where to
>find such beasts for NT (yes, I suppose I could just buy them from MKS)?
Hi,
One option is to get the Win32 ports of these tools - take
a look at http://sourceware.cygnus.com/cygwin/, where you can
download a set of common unix-like tools, including tar and gzip.
Then in your configuration file for CPAN.pm make sure the
right paths to these tools are present.
--
Best regards,
Randy Kobes
Physics Department Phone: (204) 786-9399
University of Winnipeg Fax: (204) 774-4134
Winnipeg, Manitoba R3B 2E9 e-mail: randy@theory.uwinnipeg.ca
Canada http://theory.uwinnipeg.ca/
------------------------------
Date: Wed, 27 Jan 1999 18:58:30 -0000
From: "Artoo" <r2-d2@REMOVEbigfoot.com>
Subject: Re: Removing New Lines in Form Fields
Message-Id: <78nnou$fn4$1@plug.news.pipex.net>
>I could be wrong, but I think at the end of the line there is more than
just
>\n
>
>Try \n\r together or \r\n (can't remeber which way round)
>
>Chris D
Thanks for the help Chris
It's \r\n
------------------------------
Date: Wed, 27 Jan 1999 14:31:56 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: sendmail part deux
Message-Id: <s3tn87.dl.ln@magna.metronet.com>
iqbal (iqbal@orangenet.co.uk) wrote:
: I have a shell command which works fine
: `$mailprog who@ever.com <message` #where mailprog is /usr/sbin/sendmail
: Now I want to do this in perl, but am not getting very far.
Perl FAQ, part 9:
"How do I send mail?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 27 Jan 1999 14:06:19 -0500
From: John Chambers <jc@uwm-dev.gte.com>
Subject: Re: system function, Pros and Cons??
Message-Id: <36AF63AB.912A706D@uwm-dev.gte.com>
Tom Christiansen wrote:
>
> Why parse the output of netstat? Since you can obviously parse the
> contents of /proc/net or seek around in /dev/kmem all by yourself, why
> don't you? If you want to send something to the printer daemon, there's
> no reason to call lpr since you can just open /dev/printer on your own
> system and mumble the right protocol at it. And if you want to send mail,
> with MX lookups, queueing, and fallback, there's no reason to call mail
> transport agent. You can be that agent. Just do the raw socket stuff.
>
> Obviously, these are silly.
Hey, wait just a minute there! I was following this until the last bit,
and they you hit something that I find myself doing a lot. With most
email agents, for example, it's very difficult to diagnose failures.
So I just do something like:
: telnet foo.bar.urk 25
and start typing SMTP commands at it, typically by pasting in strings
from the failed message. You'd be surprised at how quickly this can
tell you what the problem was. (Or maybe you wouldn't, if you're as
silly as I am. ;-)
Similarly, I've found that a good way to impress people with your
web wizarditude (without actually needing to qualify as a wizard)
is to react to a problem by typing something like:
: telnet foo.bar.urk 80
GET /some/file.html HTTP/1.0
You have to remember the double \r, of course. I've seen a lot
of eyes grow wide as they realize what I just did. And the HTTP
headers that come back are often immensely helpful at diagnosing
those picky failures. You know, when you've carefully gone over
all the points in the Idiot's Guide, and it still doesn't work,
usually because of some strangeness in the server.
The raw socket stuff often takes a lot less wizardry than trying
to use the fancy high-level tools. Rather than doing the telnets
by hand, it's handy to have a few perl programs sitting around to
automate such things. But that's not too tricky; perlipc tells
you exactly how to do it in just a few lines of code.
(Of course, when the server just delivers up a page telling you
to get an acceptable browser, it takes a bit more wizardry to
convince the turkey that you're a browser ...)
------------------------------
Date: Wed, 27 Jan 1999 20:28:15 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: system function, Pros and Cons??
Message-Id: <zFKr2.104$q74.14693@news.shore.net>
John Chambers <jc@uwm-dev.gte.com> wrote:
: So I just do something like:
: : telnet foo.bar.urk 25
: and start typing SMTP commands at it, typically by pasting in strings
[snip]
: : telnet foo.bar.urk 80
: GET /some/file.html HTTP/1.0
These are perfectly reasonable if you're debugging, or trying to see how
the protocols work, but Tom's point is that you (probably) wouldn't want
to program your perl script to do such operations "manually".
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: 27 Jan 1999 11:23:05 -0700
From: "Eric The Read" <emschwar@mail.uccs.edu>
Subject: Re: Using a variable as a variable name
Message-Id: <xkfn234h8xi.fsf@valdemar.col.hp.com>
Bruce Hodo <bruceh@interaccess.com> writes:
> When I print $output, the contents
> of string2.$i.string2 are printed. What am I doing wrong?
I have no idea. If you post a bit of code illustrating what you just
said, it'll make a lot more sense, and we'll be able to figure out what
you're doing wrong. As it is, I don't think I really understand what it
is you're trying to do.
-=Eric
------------------------------
Date: 27 Jan 1999 14:36:53 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: WANTED: Perl Programmer (London/UK)
Message-Id: <78n8a5$1gn$1@gellyfish.btinternet.com>
On 27 Jan 1999 12:32:11 +0000 Christof Damian wrote:
> Internet Programmer (Unix, Perl, SQL) permanent London/UK
>
> Job Title: Internet Programmer (Unix, Perl, SQL)
> Location: London UK (Highgate)
> Duration: permanent
>
I have forwarded this to the London Perl Mongers mailing list which is
possibly a more appropriate forum for this stuff - we are currently
looking at our policy on Job Postings however so it might be better for
the time being to mail London jobs to :
owner-london-list@hfb.pm.org
so we can deal with them appropriately.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
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 4762
**************************************