[9103] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2721 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 26 06:07:26 1998

Date: Tue, 26 May 98 03:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 26 May 1998     Volume: 8 Number: 2721

Today's topics:
        Announce: mime+.pl, MIME multipart message assembler. (Jari Aalto+mail.perl)
    Re: Can I interpolate Perl variables in POD output? (Charlie Stross)
        defining constant $VERSION variable for RCS/Clearcase (Jari Aalto+mail.perl)
        Embedding Perl (Bavo De Ridder)
    Re: GPL documentation == unspeakable evil <rra@stanford.edu>
    Re: Handling Dates Help Please <Tony.Curtis+usenet@vcpc.univie.ac.at>
        Help! Win32::Process not run under IIS 3.0 on NT4 <galinaz@post.tau.ac.il>
    Re: Need Help: HTML- Forms + CGI + Perl (/\oo/\ the original)
    Re: Perl strangeness mjforder@my-dejanews.com
    Re: Perl under Windows (/\oo/\ the original)
    Re: Problem with Renaming a file to a new name that's s <shurik@iron.Te.NeT.UA>
        Sending Web Page Data to a File and More...a newbie met (/\oo/\ the original)
        stuck on perl <hugo@cs.uwa.edu.au>
    Re: Tom Christiansen <jbc@west.net>
    Re: Writing to a file <shurik@iron.Te.NeT.UA>
        Xor computation <gai@infogear.co.il>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 26 May 1998 12:20:21 +0300
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Announce: mime+.pl, MIME multipart message assembler.
Message-Id: <tb4sydie22.fsf@blue.sea.net>


    I you receive multipart MIME messages and you don't always have
    MUA (Mail user agent) around that can assemble the parts back 
    together, then you could check if you find this perl 5.003 
    script useful.

        % mime+.pl mailbox mailbox mailbox ...
        
    The parts van be in any order and there can be even multiple 
    part-files spread accross several mailboxes. The script will
    spit out each found complete FILE after assembling the parts.

    Note: This has only been tested with Emacs TM MIME styled
    multipart headers that are in form:

        Content-Type: message/partial; id="Mon_May_25_16:32:50_1998\@foo.bar.com"; number=2; total=16

    If you know a Content-Type header that differs from this one, please
    send me excample multipart message so that I can add support to that 
    too. The sctip tis available by sending message

        mailto: <jari.aalto@poboxes.com>
        Subject: send mail+.pl          (try also "send help")

    jari


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

Date: Tue, 26 May 1998 09:09:37 GMT
From: charlie@antipope.org (Charlie Stross)
Subject: Re: Can I interpolate Perl variables in POD output?
Message-Id: <slrn6ml1ng.l1i.charlie@cs.ed.datacash.com>

On 22 May 1998 16:40:21 -0500, Quentin  Fennessy 
<quentin@shaddam.amd.com> wrote:

>Is it possible to interpolate variables within the POD sections of a
>file?
   :
>When the program (bunyan) is run with a specific
>argument it runs itself through the pipeline
>
>  pod2man $0 | nroff -man | col -b | cat -s
>
>Is it possible to include Perl variables within the POD section (such
>as $VERSION) and have that variable evaluated and printed as 1.17 (or
>whatever)?

I haven't seen any way of doing this built into pod.

Hmm ...

>I can imagine adding another program to the pipeline to 
>expand the variable.  Perhaps like this:
>
>  pod2man $0 | bunyan --interpolate | nroff -man | col -b | cat -s

There's a possible way of achieving what you want.
What you could do is run your pipeline like this:

  bunyan --preprocess | pod2man | nroff -man |col -b |cat -s

The --preprocess option tells bunyan to 

a) Read its own source file
b) Perform macro substitution within blocks delimited by =pod and =cut
c) Print output to stdout

>This seems strange -- bunyan filters itself.  I guess bunyan
>would have to know in advance with Perl variables to interpolate.
>That is, it would look and do this:
>
>	s/$VERSION/$VERSION/e;
>	s/$log_dir/$log_dir/e;
>
>Thoughts, suggestions?

Yeah: if I were you, I would try not to use things that look like perl
variables as macros in this kind of macro substitution shtick; some
kind of non-perl-like construct would be easier to read.

For example, s/%VERSION%/$VERSION/ is maybe a bit easier to read; more
to the point, the %VERSION% bit in a pod section can't be mistaken for a
fragment of perl code or a documentation example.

A second option that may be interesting to you is SDF. I'm not certain,
but I think SDF supports some kind of macro interpolation facilities like
these. See http://www.mincom.com/mtr/sdf/ for details. (SDF is vertically
compatible with POD.)




-- Charlie

"Given two unrelated technical terms, an internet search engine
 will retrieve only resumes." -- Schachter's Hypothesis   


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

Date: 26 May 1998 10:46:34 +0300
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: defining constant $VERSION variable for RCS/Clearcase
Message-Id: <tb7m39iied.fsf@blue.sea.net>


        Hi,

        I have used the following setup to define both RCS and Clercase
        comparible $VERSION variable, but I'd like to make the $VERSION
        constant as the FILE_ID is. Why doesn't the "\" and "*" combination
        make it constant? The sprintf is needed to padd the version number
        with leading zeroes (See Exporter)

        jari

package foo;
use vars qw( $VERSION $FILE_ID );

*FILE_ID  = \q$Id: perl-style.txt,v 1.41 1998/05/23 08:39:09 jaalto Exp jaalto $;

{
        my $ver = (split ' ', $FILE_ID)[$FILE_ID =~ /@@/ ? 1: 2];
        *VERSION =  \sprintf "%d.%03d",  $ver =~ /(\d+)\.(\d+)/;
}

$VERSION = 1;
print "$VERSION";

--> 1 ????? Why was it possible to modify this variable


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

Date: 26 May 1998 09:19:05 GMT
From: bavo@ace.ulyssis.student.kuleuven.ac.be (Bavo De Ridder)
Subject: Embedding Perl
Message-Id: <896174345.712929@marvin>


Hello,

I want to do the following: I want to embed the Perl Interpreter in my
program. So far no problems, doing this is very well documented and a lot
of examples are out there... The same goes for extending perl. I was
able to write my own module in C++, compile and use it in under 15
minutes using SWIG.

But what if you want to do both? I want to embed the interpreter in my
program *and* have the perl code call some functions of my C++ program.
So the the C++ program will call some perl code and that perl code
will call some function in my C++ program... Can I have the perl code call
a C++ method?

How do I do that? Where can I find documentation? (examples are most of
the time to complicated and underdocumented to be usefull...).


Bavo De Ridder


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

Date: 26 May 1998 02:04:21 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: GPL documentation == unspeakable evil
Message-Id: <m3solxh08a.fsf@windlord.Stanford.EDU>

David Kastrup <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de> writes:
> Russ Allbery <rra@stanford.edu> writes:
>> In comp.lang.perl.misc, Tyson Richard DOWD <trd@hydra.cs.mu.oz.au> writes:

>>> This is all very well, but in the end he is asking the entire Perl
>>> community to trust him to do the right thing.

>> Yes.  Which this member of the Perl community has absolutely no qualms
>> whatsoever in doing.

> The right thing here includes never dying, never to develop any mental
> disorder, never to grow senile, never to be as busy as to not be
> effectively able to maintain the stuff

No, it includes trusting him to make arrangements for those various events
that will cause sane things to happen to his property.

> (apart from never doing something unamiable to anybody with his rights
> to the docs which I would not entirely want to guarantee seeing how
> capable of overreacting and hate tirades he is).

Judging someone solely on the basis of Usenet posts is sometimes a
mistake.  It definitely is in this case.

> Your trust is more than a single human can guarantee to deserve.

I'm sorry that you live in such a harsh, cruel, and fundamentally hostile
world.  That's not the world I choose to live in.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 26 May 1998 11:27:12 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
To: johnny99@sydney.dialix.oz.au
Subject: Re: Handling Dates Help Please
Message-Id: <7xu36d8jrj.fsf@beavis.vcpc.univie.ac.at>

Re: Handling Dates Help Please, johnny99
<johnny99@sydney.dialix.oz.au> said:

johnny99> Today is 26/5/98, so the "today" script would take
johnny99> you to a page called 98-05-26.html -- but what I'd
johnny99> like to do is enable browsers to go backward and
johnny99> forward with buttons on the pages marked "Next
johnny99> Day" and "Previous Day".

johnny99> I know how to do this by adding/subtracting from
johnny99> the 26 and making it 27 or 25 etc., but what
johnny99> happens when I get to 1 June? I'll end up with
johnny99> Previous Day being the zero of June and so on,
johnny99> won't I?

Well, first I would suggest looking at the Date::DateCalc
and Date::Manip modules, these might be useful for you.

Secondly, it is easy to subtract a day as seconds from an
absolute time (like time() returns), so you could convert to
time(), subtract (24*60*60) seconds and then convert back to
the required format, e.g. via POSIX::strftime().

    today = 1998-05-26
    y'day = today - (24*60*60);
    y'day = POSIX::strftime('%Y-%m-%d', y'day);

or something...

hth,
tony
-- 
Tony Curtis, Systems Manager, VCPC,      | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | http://www.vcpc.univie.ac.at/

"You see? You see? Your stupid minds! Stupid! Stupid!" ~ Eros, Plan9 fOS.


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

Date: Tue, 26 May 1998 12:21:12 +0300
From: Galina Zuckerman <galinaz@post.tau.ac.il>
Subject: Help! Win32::Process not run under IIS 3.0 on NT4
Message-Id: <356A8988.792E0C04@post.tau.ac.il>

Hi,

I have NT 4.0 and MS IIS 3.0 on it.
When I tried to run Windows NT Process from command prompt (i.e Perl) it
run fine,
bun not run from CGI script. Somebody know where is a problem in IIS.
Another Perl commands like "system", "exec" or `` doesn't work too from
CGI scripts.
Help ne to fix it

Thanks
Slava Zuckerman <slava@kenes.com>





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

Date: Tue, 26 May 1998 09:47:03 GMT
From: WarezSpider@Warez.web/\oo/\ (/\oo/\ the original)
Subject: Re: Need Help: HTML- Forms + CGI + Perl
Message-Id: <35b06b43.37180601@news.sgi.net>

On Sun, 24 May 1998 21:39:22 +0200, Andreas Frenko
<andreas.frenko@gmx.de> wrote:

>Hello,
>
>is there anybody, who has experience in connecting HTML- Forms
>with a Perl- Script,
>so that the entries will be saved into a text- file on the
>server.
>
>If you can help me, please drop a note to:
>
>andreas.frenko@gmx.de


For the groups benefit also ...
Hi,
I may be able to help you.. i have a script to connect a form to a
text file. I am just a beginner at Perl and it is my first programming
language, so don't laugh! 

It sends a part of the order to CyberCash for proccessing; sends a
part of the order as a  receipt web page to the shopper; sends an
email to the Merchant to notify them of their order; sends the entire
order to a secure page for the Merchant  to later login to and
retrieve the secure data. 
I learned most all of this from the Book "Learning Perl on NT" by the
great wizard Randall Swartz, hope i spelled your name right Merlin,
who frequents the group. 
The crazy mixed up round about way of my script is all my demented
doing not His.

#!X:/perl/lib/perl           ## we installed Perl on NT here

# Send the html document MIME type.
print "Content-type:text/html\n\n";

require ("X:/perl/lib/cgi-lib.pl");      
## Require the grand ole parser to clean up the web input!
&ReadParse;   #get the form arguments.
use CCLib qw(SetServer sendmserver);    
 ## This is our old pay method CyberCash
%payment = ( 'host' => 'Odin.2webspinners.com',
             'port' => 8000,
             'secret' => 'XXXXXXXXXX');
&SetServer(%payment);

## That preps the order for CyberCrap! oops my opinion..
## This Generates a order ID based on the exact time..
sub GenerateOrderID {
    local($orderID);
    local($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
gmtime(time());

    $orderID =
sprintf("%02d%02d%02d%02d%02d%05d",$year,$mon+1,$mday,$hour,$min,$$);

    return $orderID;
}

##  This is where i bring the pieces into a manageble ...something ;-)
## to prepare them for sending to CyberCash register.
$orderID = &GenerateOrderID;
## This runs the subroutine above and gives it to $orderID
$amount = $in{'total'};  ## incoming Web Form Data
$pan = $in{'Card_number'};   ## incoming Web Form Data
$name = $in{'billName'};   ## incoming Web Form Data
$addr = $in{'billAdd1'};   ## incoming Web Form Data
$city = $in{'billCity'};   ## incoming Web Form Data
$state = $in{'billState'};   ## incoming Web Form Data
$zip = $in{'billZIP'};   ## incoming Web Form Data
$country = 'USA';   ## Preset value for this one!
$exp = $in{'Card_exp'};    ## incoming Web Form Data

## No we open the Data file keeping permissions(write only the
##webowner has read/delete properties and Us admin's of course)

open (DATAFILE, ">> X:/inetpub/wwwroot/_safe/NewOrder.txt");
## opens the file to write at specified location 
flock (DATAFILE, 2); 
## locks the file temporarily so no one else over writes it?!!
print DATAFILE <<RECORD_ITEM;  ## send out-put in text format
New Order       ## this is printed out as text every extra line and #
	         ## the $in stuff is not printed either it is 		
Products Selected   ##interpolated? Is that the word?
Product One: $in{'prodchosen1'}
QTY One: $in{'qty1'}
Unit Price One: $in{'unitprice1'}
TotalPrice One: $in{'extprice1'}

Product Two: $in{'prodchosen2'}
QTY Two: $in{'qty2'}
Unit Price Two: $in{'unitprice2'}
TotalPrice Two: $in{'extprice2'}

Subtotal:  ## who cares..
Sales Tax:  ## not for what we're selling(it's legal! PC services)
Grand Total:  $in{'grandtotal'} ## that's what I want!

Billing Information

Billing Total:  $in{'total'}  ## so i have good records all this
Name on Card: $in{'billName'}  
Billing Address line 1: $in{'billAdd1'}
Billing Address line 2:  $in{'billAdd2'}
Billing City: $in{'billCity'}
Billing State: $in{'billState'}
Billing ZIP: $in{'billZip'}
Credit Card Type: $in{'Card_type'}
Credit Card Number: $in{'Card_number'}
Credit Card EXP: $in{'Card_exp'}
Order ID: $orderID

Contact Information

Contact Email: $in{'email'}  ## More important info to save
Contact Phone: $in{'Phone'}

Shipping Information

Shipping Name: $in{'ShipName'}
Shipping Company:  $in{'ShipCompany'}
Shipping Address: $in{'ShipAdd1'}
Shipping Address Line 2: $in{'ShipAdd2'}
Shipping City: $in{'ShipCity'}
Shipping State: $in{'ShipState'}
Shipping ZIP: $in{'ShipZip'}
URL: $in{'URL'}

Statistic Data for Spider  ## this I use to track who was there

Remote Name: $ENV{'REMOTE_HOST'}  ## these are server side includes
Users Browser: $ENV{'HTTP_USER_AGENT'} ## and these too
Users Resolution: $ENV{'HTTP_UA_PIXELS'}
Users OS: $ENV{'HTTP_UA_OS'}
Users CPU Type: $ENV{'HTTP_UA_CPU'}
Cookie: $ENV{'HTTP_COOKIE'}
Refering page: $ENV{'HTTP_REFERER'}
End of Order.

RECORD_ITEM   ## ends the format it's writing
flock (DATAFILE, 8);   ## Unlock the file to next shopper
close DATAFILE;  ## and close it

## this just makes a new subroutine that sends the order data to 
## CyberCash for Authorization

%result = &sendmserver('mauthonly', 
                       'Order-ID', $orderID,
		       'Amount', $amount,
		       'Card-Number', $pan,
		       'Card-Name', $name,
		       'Card-Address', $addr,
		       'Card-City', $city,
		       'Card-State', $state,
		       'Card-Zip', $zip,
		       'Card-Country', $country,
		       'Card-Exp', $exp);

## now we send a receipt to the shopper as a Web-Page
## only some data gets sent back to minimize security leaks

print <<WEB_PAGE;
<html>
<head>
<meta HTTP-EQUIV="REFRESH"
CONTENT="30;URL=http://www.2webspinners.com/news.htm">
<title>PWS Order Confirmation</title>
</head>
<body background="https://www.2webspinners.com/store/images/map.gif"
bgcolor="white" text="black">
<center><h2>SECURE ORDER CONFIRMATION</h2></center>
<p>Your PWS ORDER ID is: $orderID 
Thank you<b> $in{'billName'}</b>, for placing your order of: 
<pre>
	$in{'prodchosen1'}
	$in{'prodchosen2'}
<br></pre>
with  <b><i><font face="Elephant" color="#FF0000" size="+2">Pittsburgh
Web Spinners Secure Store.</font></i></b> <BR><HR>
We will contact you at<b> $in{'email'} </b>or at<i> $in{'Phone'} </i>
with any questions or problems with your order.<br>
<center>Your Order ID# is: $orderID  </center><br>Please Keep this for
your records by printing this page or saving it as a file.
<p>
</html>
WEB_PAGE
## Part 3 of Interactive Order Form the email notification
##These paths need to be customized for your environment

$postmail = "postmail.exe";
$temp_msg = "X:\\outmail$$.txt";

$toaddress = $in{'sendto'};
$fromaddr = $in{'email'};
$desthost = "thor.2webspinners.com";
$subj = NewOrder;
$caller = $in{'CardName'};
$phone = $in{'Phone'};

## Create A temporary File to construct the e-mail
## Only to avoid a eof hang by perl...
open (MAIL, ">$temp_msg") || die "open postmail or sendmail";
## Construct the e-mail
print MAIL "To: $toaddress\r\n";
print MAIL "From: $fromaddr\r\n";
print MAIL "Subject: $subj\r\n";
print MAIL "\r\n";
print MAIL "Caller : ".$caller;
print MAIL "\r\n";
print MAIL "Phone  : ".$phone;
print MAIL "\r\n\r\n";
print MAIL "Order Total:\r\n";     ## Change Order to Message.
## Change this to incoming message or something
print MAIL $in{'total'};	
close MAIL; ## Finish writing to file
## make a system call to run emailer.. 
system ("$postmail -HThor.2webspinners.com -f$fromaddr $toaddress <
$temp_msg") || die "open postmail or sendmail";
unlink $temp_msg;  # Remove the File
exit;    # end of user script.
## Thats the end! Hope you learned a little.
## /\oo/\ spider@2webspinners.com



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

Date: Tue, 26 May 1998 07:54:37 GMT
From: mjforder@my-dejanews.com
To: rootbeer@teleport.com
Subject: Re: Perl strangeness
Message-Id: <6kdsfs$tfc$1@nnrp1.dejanews.com>

I have figured out what the problem is...

in my script, I was calling the following:

use File::Find;
use File::Basename;
use File::Copy;
require Mail::Send;

I used a require instead of a use for the Mail::Send module 'cause that's the
way it's called in the perldoc page for Mail::Send.

Anyway, to cut a long story short, I exchanged the require for a use statement
and Hey Presto! the script now works from the command line.

Thanks to all those who e-mailed helpfull suggestions  ( all 2 of you! ;-) )

Matt   ;-)

Matthew J. Forder
Unix SysOp
Seagate Technology Int'l.

+----------------------------------------------------------------------

In article <6kbnua$nhp$1@nnrp1.dejanews.com>,
  mjforder@my-dejanews.com wrote:
>
> Strange things are happening in my perl script!
>
> When I try to run this particular perl script from a Unix cmd-line, I get
> this:
>
> $ perl ./notify.pl SEND 0 < ~/isofax.out
> Can't locate object method "new" via package "Mail::Send" at ./notify.pl
line
> 70.
>
> However, if I invoke perl with the -d switch, then just do:
>
>   DB<1> c
>
> (to continue through the script), the script will excute without problems.
> I don't have this problem with any other perl script I've written using the
> Mail::Send module, and basically I'm stumped.
>
> If anyone has any suggestions as to why this is happening, or even better, a
> solution, please let me know!
>
> Thanks in advance,
>
> Matt  ;-)
>
> Matthew J. Forder
> Unix SysOp
> Seagate Technology Int'l.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Tue, 26 May 1998 09:47:01 GMT
From: WarezSpider@Warez.web/\oo/\ (/\oo/\ the original)
Subject: Re: Perl under Windows
Message-Id: <35935ace.32967010@news.sgi.net>

Tom is right but.....
Install perl to some folder we used "PERL" preferably on the same
machine as the Server so you don't have to MAP a drive later or
something else.  
Next, 1. either associate Perl files ".pl; .cgi; .plx;" etc.... with
Perl.exe which is where you installed it Usually in the LIB folder...
(this leaves some security issues...all scripts get executed! or at
least any in a cgi-bin...)
Or 2. Specify the location of perl on the first line of the script
like:
#!d:/perl/lib/perl

Hope this helps...

Get Randalls Book learning Perl on NT and/or send a contribution to
the Randal Swartz fund

Peace Love! 
/\00/\  spiders are cool... 


On Sun, 24 May 1998 19:43:57 +0200, "Johannes Kuehrer"
<Johannes@young-world.com> wrote:

>Hello !!
>
>I have a problem. I installed a web server under Windows NT.
>But i dont know how i have to install Perl.
>And what command do i have to enter in a perl script ??
>I mean the path to the per interpreter.
>In only know it on UNIX..like:  #! /usr/local/bin/perl
>
>But how is this under Windows ?? How i should enter the path ??
>I would be glad when someone could help me !!
>Thank you !!!!
>
>Johannes Kuehrer
>Johannes@young-world.com
>
>Austria
>



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

Date: 26 May 1998 08:48:41 GMT
From: Alexandr Dubovikov <shurik@iron.Te.NeT.UA>
Subject: Re: Problem with Renaming a file to a new name that's specified by a variable
Message-Id: <6kdvl9$rnd$2@toster.Te.NeT.UA>

Arthur Dardia ( ahdiii@webspan.net ) RANEE PISAL:
> In my CGI problem, I have the following code:

> rename "../htdocs/toast/matches/temp.html",
> "../htdocs/toast/matches/'.$in{filename}.'";

> Why doesn't that work?  I tried:

> rename "../htdocs/toast/matches/temp.html",
> '../htdocs/toast/matches/'.$in{filename}.'';

Because it's wrong !

You must to do it

rename ("../htdocs/toast/matches/temp.html",
"../htdocs/toast/matches/.$in{filename}");


> also, and neither statement works...please help me.

>                     Severely stumped,
>                     Arthur Dardia



 Alexandr Dubovikov * +380 (0482) 219093  
  baron@iRC RusNet  *  shurik@te.net.ua 


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

Date: Tue, 26 May 1998 09:47:04 GMT
From: WarezSpider@Warez.web/\oo/\ (/\oo/\ the original)
Subject: Sending Web Page Data to a File and More...a newbie method
Message-Id: <35b56d50.37705616@news.sgi.net>

Hi,
I may be able to help you.. i have a script to connect a form to a
text file. I am just a beginner at Perl and it is my first programming
language, so don't laugh!

It sends a part of the order to CyberCash for proccessing; sends a
part of the order as a  receipt web page to the shopper; sends an
email to the Merchant to notify them of their order; sends the entire
order to a secure page for the Merchant  to later login to and
retrieve the secure data. 
I learned most all of this from the Book "Learning Perl on NT" by the
great wizard Randall Swartz, hope i spelled your name right Merlin,
who frequents the group. 
The crazy mixed up round about way of my script is all my demented
doing not His.

#!X:/perl/lib/perl           ## we installed Perl on NT here

# Send the html document MIME type.
print "Content-type:text/html\n\n";

require ("X:/perl/lib/cgi-lib.pl");      
## Require the grand ole parser to clean up the web input!
&ReadParse;   #get the form arguments.
use CCLib qw(SetServer sendmserver);    
 ## This is our old pay method CyberCash
%payment = ( 'host' => 'Odin.2webspinners.com',
             'port' => 8000,
             'secret' => 'XXXXXXXXXX');
&SetServer(%payment);

## That preps the order for CyberCrap! oops my opinion..
## This Generates a order ID based on the exact time..
sub GenerateOrderID {
    local($orderID);
    local($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
gmtime(time());

    $orderID =
sprintf("%02d%02d%02d%02d%02d%05d",$year,$mon+1,$mday,$hour,$min,$$);

    return $orderID;
}

##  This is where i bring the pieces into a manageble ...something ;-)
## to prepare them for sending to CyberCash register.
$orderID = &GenerateOrderID;
## This runs the subroutine above and gives it to $orderID
$amount = $in{'total'};  ## incoming Web Form Data
$pan = $in{'Card_number'};   ## incoming Web Form Data
$name = $in{'billName'};   ## incoming Web Form Data
$addr = $in{'billAdd1'};   ## incoming Web Form Data
$city = $in{'billCity'};   ## incoming Web Form Data
$state = $in{'billState'};   ## incoming Web Form Data
$zip = $in{'billZIP'};   ## incoming Web Form Data
$country = 'USA';   ## Preset value for this one!
$exp = $in{'Card_exp'};    ## incoming Web Form Data

## No we open the Data file keeping permissions(write only the
##webowner has read/delete properties and Us admin's of course)

open (DATAFILE, ">> X:/inetpub/wwwroot/_safe/NewOrder.txt");
## opens the file to write at specified location 
flock (DATAFILE, 2); 
## locks the file temporarily so no one else over writes it?!!
print DATAFILE <<RECORD_ITEM;  ## send out-put in text format
New Order       ## this is printed out as text every extra line and #
	         ## the $in stuff is not printed either it is 		
Products Selected   ##interpolated? Is that the word?
Product One: $in{'prodchosen1'}
QTY One: $in{'qty1'}
Unit Price One: $in{'unitprice1'}
TotalPrice One: $in{'extprice1'}

Product Two: $in{'prodchosen2'}
QTY Two: $in{'qty2'}
Unit Price Two: $in{'unitprice2'}
TotalPrice Two: $in{'extprice2'}

Subtotal:  ## who cares..
Sales Tax:  ## not for what we're selling(it's legal! PC services)
Grand Total:  $in{'grandtotal'} ## that's what I want!

Billing Information

Billing Total:  $in{'total'}  ## so i have good records all this
Name on Card: $in{'billName'}  
Billing Address line 1: $in{'billAdd1'}
Billing Address line 2:  $in{'billAdd2'}
Billing City: $in{'billCity'}
Billing State: $in{'billState'}
Billing ZIP: $in{'billZip'}
Credit Card Type: $in{'Card_type'}
Credit Card Number: $in{'Card_number'}
Credit Card EXP: $in{'Card_exp'}
Order ID: $orderID

Contact Information

Contact Email: $in{'email'}  ## More important info to save
Contact Phone: $in{'Phone'}

Shipping Information

Shipping Name: $in{'ShipName'}
Shipping Company:  $in{'ShipCompany'}
Shipping Address: $in{'ShipAdd1'}
Shipping Address Line 2: $in{'ShipAdd2'}
Shipping City: $in{'ShipCity'}
Shipping State: $in{'ShipState'}
Shipping ZIP: $in{'ShipZip'}
URL: $in{'URL'}

Statistic Data for Spider  ## this I use to track who was there

Remote Name: $ENV{'REMOTE_HOST'}  ## these are server side includes
Users Browser: $ENV{'HTTP_USER_AGENT'} ## and these too
Users Resolution: $ENV{'HTTP_UA_PIXELS'}
Users OS: $ENV{'HTTP_UA_OS'}
Users CPU Type: $ENV{'HTTP_UA_CPU'}
Cookie: $ENV{'HTTP_COOKIE'}
Refering page: $ENV{'HTTP_REFERER'}
End of Order.

RECORD_ITEM   ## ends the format it's writing
flock (DATAFILE, 8);   ## Unlock the file to next shopper
close DATAFILE;  ## and close it

## this just makes a new subroutine that sends the order data to 
## CyberCash for Authorization

%result = &sendmserver('mauthonly', 
                       'Order-ID', $orderID,
		       'Amount', $amount,
		       'Card-Number', $pan,
		       'Card-Name', $name,
		       'Card-Address', $addr,
		       'Card-City', $city,
		       'Card-State', $state,
		       'Card-Zip', $zip,
		       'Card-Country', $country,
		       'Card-Exp', $exp);

## now we send a receipt to the shopper as a Web-Page
## only some data gets sent back to minimize security leaks

print <<WEB_PAGE;
<html>
<head>
<meta HTTP-EQUIV="REFRESH"
CONTENT="30;URL=http://www.2webspinners.com/news.htm">
<title>PWS Order Confirmation</title>
</head>
<body background="https://www.2webspinners.com/store/images/map.gif"
bgcolor="white" text="black">
<center><h2>SECURE ORDER CONFIRMATION</h2></center>
<p>Your PWS ORDER ID is: $orderID 
Thank you<b> $in{'billName'}</b>, for placing your order of: 
<pre>
	$in{'prodchosen1'}
	$in{'prodchosen2'}
<br></pre>
with  <b><i><font face="Elephant" color="#FF0000" size="+2">Pittsburgh
Web Spinners Secure Store.</font></i></b> <BR><HR>
We will contact you at<b> $in{'email'} </b>or at<i> $in{'Phone'} </i>
with any questions or problems with your order.<br>
<center>Your Order ID# is: $orderID  </center><br>Please Keep this for
your records by printing this page or saving it as a file.
<p>
</html>
WEB_PAGE
## Part 3 of Interactive Order Form the email notification
##These paths need to be customized for your environment

$postmail = "postmail.exe";
$temp_msg = "X:\\outmail$$.txt";

$toaddress = $in{'sendto'};
$fromaddr = $in{'email'};
$desthost = "thor.2webspinners.com";
$subj = NewOrder;
$caller = $in{'CardName'};
$phone = $in{'Phone'};

## Create A temporary File to construct the e-mail
## Only to avoid a eof hang by perl...
open (MAIL, ">$temp_msg") || die "open postmail or sendmail";
## Construct the e-mail
print MAIL "To: $toaddress\r\n";
print MAIL "From: $fromaddr\r\n";
print MAIL "Subject: $subj\r\n";
print MAIL "\r\n";
print MAIL "Caller : ".$caller;
print MAIL "\r\n";
print MAIL "Phone  : ".$phone;
print MAIL "\r\n\r\n";
print MAIL "Order Total:\r\n";     ## Change Order to Message.
## Change this to incoming message or something
print MAIL $in{'total'};	
close MAIL; ## Finish writing to file
## make a system call to run emailer.. 
system ("$postmail -HThor.2webspinners.com -f$fromaddr $toaddress <
$temp_msg") || die "open postmail or sendmail";
unlink $temp_msg;  # Remove the File
exit;    # end of user script.
## Thats the end! Hope you learned a little.
## /\oo/\ spider@2webspinners.com



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

Date: Tue, 26 May 1998 17:36:15 +0800
From: Hugo Bouckaert <hugo@cs.uwa.edu.au>
Subject: stuck on perl
Message-Id: <356A8D0F.C3F9B268@cs.uwa.edu.au>

Hi All

I hope this question is appropriate:  I am a real beginner in using
perland I am doing a tutorial which can be found at:

http://www.uni-hohenheim.de/institute/rz/app/prg/perl/perl/start.html

The problem is that the tutorial gives some excercises to do, but these
excersises build on one another: if you can't do the first one, the
others can't be done either. This sounds stupid, but I have been trying
for the last four hours to do one of the first excersises, and I can't
get past it to do the subsequent ones (stupid indeed, I know, I know).
Could someone please put me out of my misery and help me out?  I am
after the solution to the excersise at the following site:

http://www.uni-hohenheim.de/institute/rz/app/prg/perl/perl/filehandling.html#exercise

so I can get on with the rest of the tutorial.

Thank you very much

Hugo Bouckaert



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

Date: Tue, 26 May 1998 08:56:20 GMT
From: John Callender <jbc@west.net>
Subject: Re: Tom Christiansen
Message-Id: <356A857A.5CEBC9F@west.net>

Tina Marie Holmboe wrote:
> 
>   That was *horrid*. How on *Earth* can you manage to squeeze out
> something
>   like that ?

[snip]

>   Its... pointless. Its disgusting.

And yet, human nature being what it is, it continues to fascinate.

This, I guess, is why soap operas are so popular. Seeing someone else
get really, really pissed off can be way entertaining.

Everybody has their own reasons for participating in the way that they
do in these discussions. Tom C. clearly gets a lot of... something...
out of this, or he wouldn't keep doing it. Same goes for those who rise
to his bait. And the same goes for those who offer scandalized
admonishments about how it all flies in the face of human decency.

I'm sure all the participants think they're doing something very
important in terms of one or more larger issues; Truth, Justice, or
whatever slippery concept provides the most convenient excuse 
("Freedom," maybe, in this case). But I can't help but think that it's
all just monkeys beating each other over the heads with sticks, while
other monkeys carry on excitedly in the treetops.

Yes, it's pointless -- no one's mind is ever changed. And yes, it's
disgusting. But something about the mediation of the computer, the
distancing it offers, makes it into a dirty pleasure we can't ignore.
The stats confirm it: For all the above-the-fray posturing that goes on,
we're no different from the viewers who make freeway-suicide coverage a
sure ratings winner for the local TV stations. These off-topic
flamefests are the most popular thing in the group.

I don't know that I had any particular point to make. You all are
welcome to bash me, now, for my irrelevant monkey behavior.

--
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: 26 May 1998 08:35:59 GMT
From: Alexandr Dubovikov <shurik@iron.Te.NeT.UA>
Subject: Re: Writing to a file
Message-Id: <6kdutf$rnd$1@toster.Te.NeT.UA>

Lance Hetlet ( hetlet@ptialaska.net ) RANEE PISAL:
> I'm just learning Perl and have run into a problem with writing to a
> file.
> The book I'm working from shows two examples, one which doesn't
> work, and the other is confusing.

> The example that I'm trying is:

> open(DATABASE, ">>/data/records.dat");
> select (DATABASE);
> print $_;
> print "\n";
> select (STDOUT);

 Hi!
  Please , try it.
  open(DATABASE, ">>records.dat"); 
  print DATABASE "$_\n";

 or if you want introduce data from STDIN and see it 

select (STDOUT);
$|=1;
open (DATABASE ,">>records.dat");
while (<STDIN>) {
	print DATABASE $_;
	print $_;                                                               
}    

And don't forget permision on your writing file or directory..

> The example that confuses me is:

> format printf(FILE-TO-WRITE-TO FORMAT-STATEMENTS, DATA);

> I am unsure of the "Format-Statements" paramater.  There is no example
> in
> the book, and I don't know what the format-statements might be.

> Any help would be greatly appreciated.
> TIA

> Lance Hetlet
> http://www.ptialaska.net/~hetlet




 Alexandr Dubovikov * +380 (0482) 219093  
  baron@iRC RusNet  *  shurik@te.net.ua 


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

Date: Tue, 26 May 1998 11:33:49 +0300
From: "Gai Hetzroni" <gai@infogear.co.il>
Subject: Xor computation
Message-Id: <6kduns$ncc$1@news.ibm.net.il>

I have a perl program that needs to Xor all bytes in an array (which is very
large one)
The problem is that this operation takes too much of the CPU time:

Following is the code, does anyone have a suggestion of how to improve it ?

The input file is made of lines with the following format:

0xHH, 0xHH, 0xHH ...

where H is a hexadecimal digit.

    $Xor =~ s/,/^/g;
    $result = eval $Xor;


   Thank You.





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

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

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