[7760] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1385 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 28 09:08:04 1997

Date: Fri, 28 Nov 97 06:01:03 -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           Fri, 28 Nov 1997     Volume: 8 Number: 1385

Today's topics:
     ??? $ENV ??? <foxfox@hkstar.com>
     Re: A difficult problem (Tony Bass)
     Re: A difficult problem (Tom Grydeland)
     ANNOUNCE: IndexMaker 3.1: : an index.html maker from PD <pivari@geocities.com>
     ANNOUNCE: PDFInfo 1.1 to modify some fields of the Info <pivari@geocities.com>
     Form Result to E-mail xianinfo@pub.online.xa.sn.cn
     Re: Getting file timestamp from array <jamesr@aethos.co.uk.nospam>
     Re: hash of hashes or hash? (Marek Rouchal)
     Re: Leaving HTML-Tags alone=solved. (Patrick)
     LWP, and HTTP_REFERER <webadmin@prestel.net>
     OLE WITH TRANSIT guillaume.martin@tfm.thomson.fr
     Re: pattern substituition operation question <matkin@Owein.DoCS.UU.SE>
     Re: perl shorter than csh challenge!! (Brendan O'Dea)
     Re: perl shorter than csh challenge!! <markm@nortel.ca>
     Re: perl shorter than csh challenge!! <markm@nortel.ca>
     Re: Re: Removing Files older than 14 days <jamesr@aethos.co.uk.nospam>
     Re: send mail using perl5 <erhana@libra.com.tr>
     Re: trouble with libwww & friends in nonstandard libdir <mchase@ix.netcom.com>
     Which platform ? <emehenk@rioja.ericsson.se>
     Re: Which platform ? (Bart Lateur)
     Re: Working with just part of an array. <avm@atos.be>
     Wrapping IMAP-UW c-client library <editor@gtcs.com>
     Wrapping uulib  (Converters::UULib) <editor@gtcs.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 28 Nov 1997 21:18:07 +0800
From: "joeifox" <foxfox@hkstar.com>
Subject: ??? $ENV ???
Message-Id: <65mg0j$pep3@lyra.hkstar.com>

Hello,
I have problems while executing the following pl file:

#!/usr/local/bin/perl
print "Content-type: text/html", "\n\n";
print "<HTML>", "\n";
print "<HEAD><TITLE>About this Server</TITLE></HEAD>", "\n";
print "<BODY><H1>About this Server</H1>", "\n";
print "<HR><PRE>";
print "Server Name: ", $ENV{'SERVER_NAME'}, "<BR>", "\n";
print "Running on Port: ", $ENV{'SERVER_PORT'}, "<BR>", "\n";
print "<HR></PRE>", "\n";
print "</BODY></HTML>", "\n";
exit(0);

I got the result as follow:

Content-type: text/html
<HTML>
<HEAD><TITLE>About this Server</TITLE></HEAD>
<BODY><H1>About this Server</H1>
<HR><PRE>Server Name:   <BR>
Running on Port: <BR>
<HR></PRE>
</BODY></HTML>

Would anyone tell me why I can't obtain the $ENV varible?
And why I need to run pl file by typing "perl filename.pl" at prompt to
execute instead of typing file name only?
Any idea is welcome!
Thanks,
Joeifox
:)




------------------------------

Date: 28 Nov 1997 09:54:29 -0000
From: aeb@brains.cartoon.bt.co.uk (Tony Bass)
Subject: Re: A difficult problem
Message-Id: <65m4cl$s8d$1@brains.cartoon.bt.co.uk>

>From article <65kpun$ofr@shoga.wwa.com>, by scribble@shoga.wwa.com (Tushar Samant):
[...]
> It's easier for me to write the code ab ovo than finding where
> your error is... Complex data structures are extremely easy --
> most of the time, they are "WYSIWIG" -- but it might take some
> time to get used to that. Here's the code:

>     @names = qw(this that him her);
>     @padnames = qw(pad1 pad2 pad3 pad4);
>     @data  = (0.1, 0.2, 0.3, 0.4);
>     %table = ();

>     for $name (@names) {
>         for $padname (@padnames) {
>             $table{$name}{$padname} = [@data];
>             for (@data) {$_++};
>         }
>     }

[...]


Or in another style,


 %table = map { $_ => {map { $_ => [map $_++, @data]; } @padnames}; } @names;


    Tony Bass

-- 
# A E Bass                                      Tel: (01473) 645305
# MLB 3/19, BT Laboratories                     e-mail: aeb@saltfarm.bt.co.uk
# Martlesham Heath, Ipswich, Suffolk, IP5 7RE   DO NOT e-mail to From: line
#                                               Opinions are my own


------------------------------

Date: 28 Nov 1997 10:36:09 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: A difficult problem
Message-Id: <slrn67t7kp.nto.Tom.Grydeland@mitra.phys.uit.no>

On Thu, 27 Nov 1997 20:49:50 GMT,
Hans Juergen von Lengerke <lenkerWEEDS@dircon.co.uk> wrote:
> Hemant Mallapur wrote:
> >     foreach $key ( keys  %read) {
> AFAIK, you can't use 'keys' with a complex data structure. See the
> Camel book for an explanation.

AFAICT, %read is a hash, and you can use 'keys' to get the keys of a
hash.  What happens to be stored in the hash is of minor interest.


> To mail me, just pull the WEEDS!

If you *want* mail, why don't you pull them yourself?

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


------------------------------

Date: Thu, 27 Nov 1997 19:51:10 +0000
From: Fabrizio Pivari <pivari@geocities.com>
Subject: ANNOUNCE: IndexMaker 3.1: : an index.html maker from PDF, HTML and other files
Message-Id: <347DCF2E.52BF@geocities.com>

Hi,

I'm glad to announce the version 3.1 of IndexMaker a perl script to make
an index.html file from PDF, HTML and other files.
At the moment, it uses the /Author field and the first /Title field in
every matched PDF files, the <TITLE> </TITLE> field in every matched
HTML files and the name of the file in the others.
It should work with PERL 4 and 5.

What's new with version 3.1
Verbose option
Minor Bugfixes

This is the URL where you can find the tool
http://www.geocities.com/CapeCanaveral/Lab/3469

Enjoy it!

Send me your suggestions.
-- 
     _/_/_/_/ _/_/_/     Fabrizio Pivari
    _/       _/    _/   mailto:pivari@hotmail.com
   _/_/_/   _/_/_/     mailto:pivari@yahoo.com
  _/       _/         mailto:pivari@geocities.com
 _/       _/         http://www.geocities.com/CapeCanaveral/Lab/3469/


------------------------------

Date: Thu, 27 Nov 1997 19:47:07 +0000
From: Fabrizio Pivari <pivari@geocities.com>
Subject: ANNOUNCE: PDFInfo 1.1 to modify some fields of the Info dictionary in PDF files
Message-Id: <347DCE3B.6201@geocities.com>

Hi,

I'm glad to announce the version 1.1 of PDFInfo a perl script that
permits you to modify some fields of the
Info dictionary in PDF files.
At the moment, the fields are: /Author /Creator /CreationDate /ModDate
/Producer
It should work with PERL 4 and 5.

What's new with version 1.1:
New options: verbose, configure file
Added tests directory

This is the URL where you can find the tool
http://www.geocities.com/CapeCanaveral/Lab/3469

Enjoy it!

Send me your suggestions.
-- 
     _/_/_/_/ _/_/_/     Fabrizio Pivari
    _/       _/    _/   mailto:pivari@hotmail.com
   _/_/_/   _/_/_/     mailto:pivari@yahoo.com
  _/       _/         mailto:pivari@geocities.com
 _/       _/         http://www.geocities.com/CapeCanaveral/Lab/3469/


------------------------------

Date: Fri, 28 Nov 1997 07:01:35 -0600
From: xianinfo@pub.online.xa.sn.cn
Subject: Form Result to E-mail
Message-Id: <880721247.6709@dejanews.com>

Hi, Everyone, Can someone tell me how to write
a Perl Script to make the result of a form to E-mail contents
and mail to the assigned destination?
Thanks a lot!

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


------------------------------

Date: 28 Nov 1997 11:23:07 GMT
From: "James Richardson" <jamesr@aethos.co.uk.nospam>
Subject: Re: Getting file timestamp from array
Message-Id: <01bcfbf0$9952e240$26c0a4c1@kitkat.aethos.co.uk>

Robert <colte@hem.passagen.se> wrote in article
<347d711d.19902962@news.hogia.net>...
> 
> I'm having a bit of trouble getting the timestamp from a list of
> files. Here's what I've done.
> 
> # dir of files that I want the timestamp from
> $dir = "../htdocs/noje/files";
> 
> opendir (CARDDIR, $dir);
> 
> @filearray = readdir(CARDDIR);
> 
> foreach $file (@filearray) {
> $time = (stat($file))[9];
> $ltime = localtime($time);
> }
> 
> This works for the two first items in the @filearray e.g. "." and ".."
> but for the actual files in directory, stat seems to return nothing.
> 
> Anyone got a clue ?
> 
> Thanks
> 
> Robert
> 
> 

Somebody posted the answer to this the other day.

stat will stat the file in the cwd, so i reckon you'll find that that the
timestamps you are getting are not the ones you think you are.

try stat("$dir/$file")

James



------------------------------

Date: 28 Nov 1997 10:36:55 +0100
From: Marek.Rouchal@-nospam-hl.siemens.de (Marek Rouchal)
Subject: Re: hash of hashes or hash?
Message-Id: <65m3bn$pug@buffalo.HL.Siemens.DE>

In article <347E74AC.348C3DF1@sonnets.dot.com>, designky <designky@sonnets.dot.com> writes:
> I am writing a database program and is wondering which to use.  I want to be
> able to extract stat for any year, month, day, and hour easily.  Here are two of
> the models that I am thinking of using:
>         model 1 : $hash{yymmdd}[hour] = hits
>                 or
>         model 2 : $hash{yy}{mm}{dd}[hour] = hits
> 
> Which is a better model to use?  which one can provide faster performance?  This
> is going to be a cgi program, amd it might get a lot of hits.

First guess: Model 1, because of less dereferencing/hash table lookups.

> Is there an easy/fast way to extract stat for any given month and year easily
> with model one?  like given 9711, and quickly calculate the stat for the month,
> and the highest?

Sure. Use regexps:

$month = '9711';
foreach $day (grep /^$month/,keys %hash) {
	foreach $hour (@{$hash{$day}}) {
		...some code...
	}
}

Hope this helps!

Marek Rouchal

PS. If you want to reply by email, please remove -nospam- from the address.
    Thank you.

-- 
  Marek Rouchal                   Phone : +49 89/636-25849
     SIEMENS AG, HL CAD SYS       Fax   : +49 89/636-23650
     Balanstr. 73                 mailto:Marek.Rouchal@-nospam-hl.siemens.de
     81541 Muenchen               PCmail:Marek.Rouchal.PC@-nospam-hl.siemens.de


------------------------------

Date: Fri, 28 Nov 1997 19:28:16 GMT
From: Venice @ euronet.nl (Patrick)
Subject: Re: Leaving HTML-Tags alone=solved.
Message-Id: <65m6fq$f5s$1@news.NL.net>

tadmc@metronet.com (Tad McClellan) wrote:


Excuse me for my bad english, but i do my best. Still is a foreign
language to me :-)

>I don't think you have "the" answer yet...
>: Thought i post it for they who are interested and they who replied to
>: me.
>: s/$search(?=(?:[^>])*(?:[<\n]))/$replace/ig;

>: This does not exclude Multi-line HTML tags...
>Nor does it work on all Multi-line HTML tags...

I said it not to clear but that IS what i ment :-)

>Your solution will (sometimes):

>1) Do the replacement inside of a tag
>2) NOT do the replacement outside of a tag

Only on Multi-liners right ?

># replaces where it should not:
>$_ = '<a href="http://www.com"
>>
>http
></a>';

Multi line


># does not replace where it should:
>$_ = '<a href="http://www.com"
>>
>http ==> the protocol
></a>';

Ahhhh...,weird stuff text :-) but a True HTML doc has &#xx; instead of
< -alikes

But indeed i do not check for a left <

>it needs a litte more work, methinks  ;-)

Indeed, but the Major problem i walked into is solved...

It would be operating much better if i read the HTML into a string and
next check it as a single line. Right ?

(except Javascipt stuff)

Patrick




------------------------------

Date: Fri, 28 Nov 1997 12:09:32 +0000
From: webadmin <webadmin@prestel.net>
Subject: LWP, and HTTP_REFERER
Message-Id: <347EB47B.760CE0F0@prestel.net>

Hi

I am trying to use LWP module to grab a html page, but the problem is
that I think they test where the query comes from, because I have built
the identical copy, on my server, but it throws up a standard error.

Is there anyway i can send through some environment variables such as 

HTTP_REFERER


Iqbal

PS its only a site with oil prices on it, I just cant be bothered to
keep going there to look them up everyday


------------------------------

Date: Fri, 28 Nov 1997 07:01:58 -0600
From: guillaume.martin@tfm.thomson.fr
Subject: OLE WITH TRANSIT
Message-Id: <880721103.6533@dejanews.com>

I have write a script to automate the application TRANSIT HTML Transit 2.0
(InfoAccess Inc.) on Windows 95 with OLE.
This script does not work! The even in Basic Visual works. I do not
arrive to understand why. Help me.

'This is perl, version 5.004_02
use Win32::OLE;
$Transit = new Win32::OLE 'TransitC.Document' or die "oops\n";
$Transit->SetLogFile('c:\temp\error');
$Transit->EnableLoggin(4);
$Transit->WriteTolLog('This is the start of a sample conversion in PERL');
$Template = $Transit->OpenTemplate('c:\temp\quikstrt.hmp');
$Template->RemoveAll();
$Template->SetOutPath('C:\TEMP\OUT');
$Template->SetGraphicPath('C:\TEMP\OUT');
$Fileitem = $Template->AddInputFile('C:\TEMP\QUICKSTART.DOC");
$Fileitem->SetOutputTitle("Test of transit");
$Template->Translate(1);

In VB :
Dim Transit As Object
Dim Template As Object
Dim Fileitem As Object
Rem Establish a connection to the Transit Application Object
Set Transit = CreateObject("TransitC.Document")
Rem Set up logging options
Transit.SetLogFile ("C:\temp\errorvb.log")
Transit.EnableLogging (4)
Transit.WriteToLog "This is the start of a sample conversion."
Rem Open the Template
Set Template = Transit.OpenTemplate("C:\temp\quikstrt.hmp")
Rem Clean up the file list in the template
Template.RemoveAll
Rem Set output directories
Template.SetOutputPath ("C:\temp\OUT")
Template.SetGraphicPath ("C:\temp\OUT")
Rem Add the first file...
Rem and set a custom title for that document
Set Fileitem = Template.AddInputFile("C:\temp\quikstrt.doc")
Fileitem.SetOutputTitle ("Test of the Transit Central Engine -
quikstrt.doc")
Rem Finally - do the translation (with progress bars enabled)
Template.Translate (1)

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


------------------------------

Date: 28 Nov 1997 13:50:28 +0100
From: Matz Kindahl <matkin@Owein.DoCS.UU.SE>
Subject: Re: pattern substituition operation question
Message-Id: <yf5k9dtp4h7.fsf@Owein.DoCS.UU.SE>

alecto <alecto@pe.BogusstrinG.net> writes:

> jlee <jlee@mdsi.bc.ca> wrote:
> >I want to delete all the white spaces from a string but do not want to
> >delete the spaces that are between quotation marks. For example, if I
> >have the following string:
> 
> >    test= "aaa aaa " bbb bbb "ccc ccc"   ddd  
> Note:	           ^
> Note:              ^ I am considering this space a typo
> Note:	           ^ on the orginal poster's part
> 
> >and want the result to be:
> 
> >    test="aaa aaa"bbbbbb"ccc ccc"ddd
> 
> >Does anyone know how to do this with the pattern substitution operation?
> >I know you can do this in sed since has pattern addressing.
> 
> one way is:
> 
> #! /usr/bin/perl -w
> foreach (<>) {
> if (/(test=\s"[^"]*")([^"]*)("[^"]*")(.*$)/) {
>  $foo = $2; $bar = $4;
>         foreach ($foo,$bar){
>         s/\s+//g;
>         }
>  print "$1$foo$3$bar\n";
>  }
> }
> 
> 

Another way of doing it , which I consider more "natural" (whatever
that is), is the following:

    #!/usr/sup/gnu/bin/perl -w

    while (<>) {
	my @L = split(/(\".*?\")/);
	foreach (@L) { tr/ //d unless /^\"/ }
	$_ = join('',@L);
    } continue {
	print;
    }

The benefit is that it does not assume any structure at all on the
input string; it simply splits and keeps the quoted substring. Of
course it can be compressed to something like:

    #!/usr/sup/gnu/bin/perl -wp

    $_ = join('', map { tr/ //d unless /\"/ } split(/(\".*?\")/))

But that would be slightly less readable. The above code(s) *does*
assume that you are using balanced quotes, so please don't try to us
it for something like:

	o ne "two space"  th ree"

Correcting the code to handle the case of unbalanced quotes is left as
an exercise to the reader. :)

Another way would be to insert a space at the beginning of the string,
split is as above and then perform the tr/// only at elements of @L
with even indices. I belive that is would be slower though, since
Perl's "foreach" is very fast on lists.

Just my few vres worth,

-- 
Mats Kindahl                    ! matkin@docs.uu.se
Department of Computer Systems  ! 
Box 325                         ! Tel  +46 18 18 10 66
S-751 05 Uppsala                ! Fax  +46 18 55 02 25
SWEDEN                          ! URL  http://www.docs.uu.se/~matkin/

PGP Key fingerprint =  92 5C FC 39 32 A8 7F 91  01 56 A0 D3 9C A9 6C 81 
PGP key available under finger matkin@kay.docs.uu.se

"People do strange things when you give them money."
        -- Simple Minds


------------------------------

Date: 28 Nov 1997 10:07:28 GMT
From: bod@compusol.com.au (Brendan O'Dea)
Subject: Re: perl shorter than csh challenge!!
Message-Id: <65m550$td$1@diablo.compusol.com.au>

In article <65lnf8$f2a$1@nnrp.cs.ubc.ca>,
William Wei Liong Young <i0l1@ugrad.cs.ubc.ca> wrote:
>
>:    # Easy to read version...
>:    use FileHandle;
>:    ($cvalue) = map {/^c = (.*)$/} new FileHandle("filename")->getlines();
>
>:    # Minimal version (unnecessary characters stripped)
>:    use FileHandle;
>:    ($cvalue)=map/^c = (.*)/,new FileHandle("filename")->getlines;
>
>I like it...i'm impressed :).  but....part of the challenge was:
>
>> I can't seem to write in 2 lines of perl code (using currently 'built-in'
>> perl, not extra modules).

@ARGV='filename';($cvalue)=map/^c = (.*)/,<>;

Regards,
-- 
Brendan O'Dea                                        bod@compusol.com.au
Compusol Pty. Limited                  (NSW, Australia)  +61 2 9809 0133


------------------------------

Date: 28 Nov 1997 05:51:20 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: perl shorter than csh challenge!!
Message-Id: <lq1u3cxcmvr.fsf@bmers2e5.nortel.ca>

bod@compusol.com.au (Brendan O'Dea) writes:
> In article <65lnf8$f2a$1@nnrp.cs.ubc.ca>,
> William Wei Liong Young <i0l1@ugrad.cs.ubc.ca> wrote:
> >:    # Easy to read version...
> >:    use FileHandle;
> >:    ($cvalue) = map {/^c = (.*)$/} new FileHandle("filename")->getlines();
> >
> >:    # Minimal version (unnecessary characters stripped)
> >:    use FileHandle;
> >:    ($cvalue)=map/^c = (.*)/,new FileHandle("filename")->getlines;
> >I like it...i'm impressed :).  but....part of the challenge was:
> >> I can't seem to write in 2 lines of perl code (using currently 'built-in'
> >> perl, not extra modules).
> 
> @ARGV='filename';($cvalue)=map/^c = (.*)/,<>;

hehehe cheater :-)

Well... i'd accept this one if it was:

   {local @ARGV='filename';($cvalue)=map/^c = (.*)/,<>}

this is all very intriguing though :-) Oh well... back to real perl
coding. :-)

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


------------------------------

Date: 28 Nov 1997 06:03:10 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: perl shorter than csh challenge!!
Message-Id: <lq1ra81cmc1.fsf@bmers2e5.nortel.ca>

i0l1@ugrad.cs.ubc.ca (William Wei Liong Young) writes:
> :    # Easy to read version...
> :    use FileHandle;
> :    ($cvalue) = map {/^c = (.*)$/} new FileHandle("filename")->getlines();
> 
> :    # Minimal version (unnecessary characters stripped)
> :    use FileHandle;
> :    ($cvalue)=map/^c = (.*)/,new FileHandle("filename")->getlines;
> 
> I like it...i'm impressed :).  but....part of the challenge was:
> > I can't seem to write in 2 lines of perl code (using currently 'built-in'
> > perl, not extra modules).
> So what do you think Mark, think you can do it without 'use'ing anything?
> but if you can't...don't worry, i'm still impressed :)

Hey... i thought it was without using other than "basic" perl. FileHandle
is "built-in" to perl in 5.004. (I don't even see a FileHandle.pm in the lib/
directory... cool :-) ) In fact, i could have cut a few characters down...

   use IO::File;($cvalue)=map/^c = (.*)/,new IO::File("filename")->getlines;

There we go :-) And points go for "Brendan" for taking my example and
making it even lighter... *clap* *clap* *clap* :-)

   {local @ARGV="filename";($cvalue)=map/^c = (.*)/,<>}

*yawn*
mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


------------------------------

Date: 28 Nov 1997 11:18:18 GMT
From: "James Richardson" <jamesr@aethos.co.uk.nospam>
Subject: Re: Re: Removing Files older than 14 days
Message-Id: <01bcfbef$eb6bd740$26c0a4c1@kitkat.aethos.co.uk>

sysadmin <nobody@nowhere.com> wrote in article
<65kplf$st4@newsserver.trl.OZ.AU>...
> >>#!/bin/sh
> >>
> >>TOP_DIR=/home/hugh/temp_files
> >>
> >>find $TOP_DIR -name '*.ABC' -mtime +14 -print | perl -nle 'unlink;'
> >>
> >>
> 
> In response, why use perl at all (other than this is a perl newsgroup). 
>  Replace the -print, etc with -exec rm {} \;
> 

Well, the question was to find the most 'effective' method... The -exec rm
{} \; bit will fork() for each file, the perl one wont... but yeah i agree,
theres not much point in reinventing the wheel.

James



------------------------------

Date: Fri, 28 Nov 1997 12:08:19 +0200
From: "Erhan Aslanturk" <erhana@libra.com.tr>
Subject: Re: send mail using perl5
Message-Id: <65mtmp$es5$1@ds5500.cc.boun.edu.tr>

>  I'm  writing a perl script using cgi.pm modules (on Windows NT) to
interface
>with web for user entry form. I need to know how I could send an automated
>mail to receipients with the user input as the message to send?.


Try to use this code below. It works with NT.
Erhan Aslanturk
WebAdmin
http://www.libra.com.tr

# Simple SendMail code (NT based mailer).
# Its easy to use.
# Usage : sendresult = send_mail(from_adr, reply_adr, to_adr, smtp, subject,
message)

use secket;
$smtp = "your.smtp.server.name_or_IP";
$reply = "default\@reply.email.";
$from = "from\@email.here";

sub send_mail {
my ($from, $reply, $to, $smtp, $subject, $message) = @_;
my ($fromaddr) = $from;
my ($replyaddr) = $reply;
$to =~ s/[ \t]+/, /g;
$to =~ s/^\s+//g;
$to =~ s/\s+$//g;
$fromaddr =~ s/.*<([^\s]*?)>/$1/;
$replyaddr =~ s/.*<([^\s]*?)>/$1/;
$replyaddr =~ s/^([^\s]+).*/$1/;
$message =~ s/^\./\.\./gm;
$message =~ s/\r\n/\n/g;
$message =~ s/\n/\r\n/g;
$smtp =~ s/^\s+//g;
$smtp =~ s/\s+$//g;
if (!$to) { return -8; }
my($proto) = (getprotobyname('tcp'))[2];
my($port) = (getservbyname('smtp', 'tcp'))[2];
my($smtpaddr) = ($smtp =~
/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
? pack('C4',$1,$2,$3,$4)
: (gethostbyname($smtp))[4];
if (!defined($smtpaddr)) { return -1; }
if (!socket(S, AF_INET, SOCK_STREAM, $proto))

  return -2; }
if (!connect(S, pack('Sna4x8', AF_INET, $port, $smtpaddr)))

  return -3; }
my($oldfh) = select(S); $| = 1; select($oldfh);
$_ = <S>; if (/^[45]/) { close S; return -4; }
print S "helo localhost\r\n";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "mail from: <$fromaddr>\r\n";
$_ = <S>; if (/^[45]/) { close S; return -5; }
foreach (split(/, /, $to)) {
  print S "rcpt to: <$_>\r\n";
  $_ = <S>; if (/^[45]/) { close S; return -6; }
  }
print S "data\r\n";
$_ = <S>; if (/^[45]/) { close S; return -5; }
print S "To: $to\r\n";
print S "From: $from\r\n";
print S "Reply-to: $replyaddr\r\n" if $replyaddr;
print S "X-Mailer:Mailer 2.0 by Erhan Aslanturk\r\n";
print S "Subject: $subject\r\n\r\n";
print S "$message";
print S "\r\n.\r\n";
$_ = <S>; if (/^[45]/) { close S; return -7; }
print S "quit\r\n";
$_ = <S>;
close S;
return 1;
}





------------------------------

Date: Thu, 27 Nov 1997 18:09:19 -0800
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: trouble with libwww & friends in nonstandard libdir. alternatives to libwww ?
Message-Id: <65md2m$ent@sjx-ixn1.ix.netcom.com>

You should put your private library directory in $PERL5LIB.  I'm not sure
if the architecture subdirectory needs to be there too.

--
Mac :})   mchase@ix.netcom.com

> . . .
>Hmm, that does give me a clue however:
>
>$ perl5 -I/mypath/lib -I/mypath/lib/sun4-solaris/5.003 -we 'use
>IO::Socket'
>$
>
>So that's it perhaps, but it sure is unwieldy. Isn't there a
>more elegant way to do this ?
>
>I got libnet to install now: I edited the Configure script to
>include:
>
>use lib '/mypath/lib';
>use lib '/mypath/lib/sun4-solaris/5.003';
>
>_And_ I still had to do:
>
>perl5 -I/mypath/lib -I/mypath/lib/sun4-solaris/5.003 Makefile.PL
>PREFIX=/mypath
>
>So I guess my question boils down to: Do I have to add '/mypath/lib'
>to the @INC list AS WELL AS it's 'sun4-solaris/5.003' subdir? I
>would think that that information should be configured into IO.pm
>when it was installed in '/mypath/lib'.  Or am I asking too much ?





------------------------------

Date: Fri, 28 Nov 1997 13:25:11 +0100
From: Henrik Soderstrom <emehenk@rioja.ericsson.se>
Subject: Which platform ?
Message-Id: <347EB827.1E93@rioja.ericsson.se>

Hi, 
I am writing a few little things in perl that I want to use
both under W95 and unix (linux and solaris).

Can anyone recommend a way to detect, from within a
perl program, which platform it's running on.

TIA /Henrik


------------------------------

Date: Fri, 28 Nov 1997 11:55:57 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Which platform ?
Message-Id: <3480b101.9311160@news.tornado.be>

Henrik Soderstrom <emehenk@rioja.ericsson.se> wrote:

>I am writing a few little things in perl that I want to use
>both under W95 and unix (linux and solaris).
>
>Can anyone recommend a way to detect, from within a
>perl program, which platform it's running on.

I think you should test the $^O special variable.

Although this tells me I'm on OS/2, while I'm only using the OS/2 port
on a DOS/Win3.1 PC. Hmm.

	Bart.


------------------------------

Date: Fri, 28 Nov 1997 10:43:41 +0100
From: Arnauld Van Muysewinkel <avm@atos.be>
To: Kevin Cheramie <kevinc@mobiletel.com>
Subject: Re: Working with just part of an array.
Message-Id: <347E924C.68CB6142@atos.be>

This is a multi-part message in MIME format.
--------------22D411FA1B316DC9B6F48EB5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

$y = (reverse(split("/", $x[0])))[0];

Kevin Cheramie wrote:

> Say I have a variable @x where
>
> @x = ("/dir1/dir2/filename1")
>
> So that if I print @x, my output is
>
> /dir1/dir2/filename1
>
> I would like to extract, if you will, just the filename1 part and assign it
> to $y so that
>
> $y = ("filename1")
>
> Any help with this would be appreciated.



--
  -- Ir. Arnauld Van Muysewinkel, Atos (Brussels)

PS :
Sligos and Axime have merged to create a new company, Atos.
MARBEN is a member of the Sligos Group, and will be using the Atos name from
now on.


--------------22D411FA1B316DC9B6F48EB5
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Arnauld Van Muysewinkel
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Arnauld Van Muysewinkel
n:              Van Muysewinkel;Arnauld
org:            Atos
email;internet: avm@atos.be
tel;work:       +32.2/663.11.42
tel;fax:        +32.2/663.11.99
tel;home:       +32.2/779.52.90, +32.75/62.70.16P'C
note;quoted-printable:http://www.atos.be/=0D=0A=
	http://users.skynet.be/sky40798/
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard


--------------22D411FA1B316DC9B6F48EB5--



------------------------------

Date: 28 Nov 1997 09:11:26 GMT
From: Commercial E-Mail Editing Service ONLY <editor@gtcs.com>
Subject: Wrapping IMAP-UW c-client library
Message-Id: <65m1ru$bmj@horn.wyoming.com>

I'm in the process of XSUB wrapping the IMAP-UW c-client library for Perl5.
If anyone has already started on this and made progress, any collaboration
is welcome.  Tentative name is CMesg as it handles *so* much in the way of
message handling, and crosses various already extant module hierarchies.

Comments welcome, but please ungrunge E-mail address below for personal
responses.  The above *is* real.  Responses here are fine, and easier.

Also welcome are comments regarding SWIG vs not using it for this effort.
I'm *not* far along with this, yet.  Tentative plans are to have several sub-
classes which allow partial-use of the c-client library with reduced
overhead, and common filtering functions.

Mark Crispin's C-Client itself duplicates some announced-but-unreleased and
released modules, but also provides extras:

   1.  IMAP4.1 full access
   2.  POP3    access
   3.  Local   full BSD/mbox, mh, PC-Pine/mtx and tenex format mailboxes
   4.  MIME    Base64 and QuotedPrintable handling
   5.  MIME    multipart parsing and (recursive) extraction
   6.  NNTP    for both POST and reader-mode accesses
   7.  Local   news-directory hierarchy access (read-only)
   8.  .newsrc manipulations
   9.  SMTP    via directed server - not sure about ESMTP+DSN, yet.
               TkRat has it (mentioned below).
  10.  Mailbox searching on content and headers.  Both seqnum
               and header-borne message UIDs for many manipulations.
  11.  Its own memory management for local storage of mail chunks,
               and library administrative data.
  12.  Call-backs for various functions.

It's already been wrapped for tcl and tcl/tk in several variations
including the "sift-mail" filter distribution and TkRat MUA for X, both
of which build specialty "wish" versions, instead of dynaloaders.

-- 
  Do not respond to the above E-Mail address unless you are subscribing
  for editing services disclosed in the Reply-To: line.  For a personal
  response, delete the spaces and dashes from: b gingery@g-t-c-s.com



------------------------------

Date: 28 Nov 1997 09:30:27 GMT
From: Commercial E-Mail Editing Service ONLY <editor@gtcs.com>
Subject: Wrapping uulib  (Converters::UULib)
Message-Id: <65m2vj$bmj@horn.wyoming.com>

In preparation of XSUB wrapping IMAP-UW c-client, I'm tackling 
Frank Pilhofer's uulib, first, for experience.  Perl of course already can
easily handle uuencoding, xxencoding (alternate charset for uuencode)
and Base64, but the uulib adds multiple-message decodes and auto-split
output directly.   Also, I figure it would make a number of tools
easier to create in conjunction with CMesg.pm .  UUlib already has
massively cross-platform ports.  I'm only dealing with FreeBSD use at
this juncture, so if someone wants to take it to work with the .dll,
that'd be fine, as soon as I get it to the point that there's any
reason to sign up for CPAN posting and put it there, or privately
before that.

Tentative name is Converters::UULib, as Converters::UU already exists.

I'm using SWIG in the first stage of wrapping this.  Any comments, tips
complaints, suggestions, are welcome.  E-Mail should be directed to
an ungrunged address as below.  Posting here in response would be easier.

UULib is already wrapped in the base distribution for Tcl/Tk with xdeview
a GUI front-end, but creates its own version of wish (uuwish) instead of
any kind of dynaloader.

I've not seen anything posted which would take the doc output of SWIG and
generate a skeleton pod containing the info.  If that's available, I'd like
to know about it, too.  Thanks.

-- 
  Do not respond to the above E-Mail address unless you are subscribing
  for editing services disclosed in the Reply-To: line.  For a personal
  response, delete the spaces and dashes from: b gingery@g-t-c-s.com



------------------------------

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 1385
**************************************

home help back first fref pref prev next nref lref last post