[16121] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3533 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 1 18:05:31 2000

Date: Sat, 1 Jul 2000 15:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <962489109-v9-i3533@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 1 Jul 2000     Volume: 9 Number: 3533

Today's topics:
    Re: Can get perl to open doc, but how do I get it to op <jfisher@epotec.com>
        Can get perl to open doc, but how do I get it to open h <star@sonic.net>
        DBI: Error inserting into dbf file <znanie@shell5.ba.best.com>
    Re: foreach loop and sendmail .. <iltzu@sci.invalid>
        how to get text enclosed by matching () ? <ronr@my-deja.com>
    Re: how to get text enclosed by matching () ? <jfisher@epotec.com>
    Re: how to get text enclosed by matching () ? <christian@fabel.dk>
        I cant use m? <webqueen@my-deja.com>
    Re: I cant use m? (David Efflandt)
    Re: Installing modules onto Tripod <mnysurf@home.comREMOVE>
    Re: LPDEST Environment Variable <gellyfish@gellyfish.com>
    Re: Newbie question: extract colums from a file into an <jfisher@epotec.com>
    Re: Newbie question: extract colums from a file into an (Michael Budash)
        newbie with a big problem (KCMage)
        newbie..kinda... I've got a BIG problem (KCMage)
    Re: Number or string item in an array? <iltzu@sci.invalid>
        Parallel::UserAgent <hi@konstantin-schauwecker.de>
    Re: sending a password to a server. <gellyfish@gellyfish.com>
    Re: sql without win32::odbc? operating systems? <jeff@vpservices.com>
        Trying to insert into an xbase file. <znanie@shell5.ba.best.com>
    Re: Trying to insert into an xbase file. <jeff@vpservices.com>
    Re: User & Host based authentication (David Efflandt)
    Re: User & Host based authentication <flavell@mail.cern.ch>
    Re: Yet Another Abigail Admirer (WAS Re: Crazy enough t (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 01 Jul 2000 19:06:19 GMT
From: James Fisher <jfisher@epotec.com>
Subject: Re: Can get perl to open doc, but how do I get it to open html on  thefly?
Message-Id: <395E40E9.E5AC3FDA@epotec.com>

It looks to me that you have two options...

1.  Open the file and write to the std output.
2.  Redirect the user to the file.

JF

arthur wrote:

> Good Day,
>
> I have a script that can open and post to a file in my directory but how can
> I make that file (it is in html format) open on the web?
>
> #!/usr/bin/perl
>
> use CGI qw(:standard);
> use IO File;
>
> print header;
>
> print start_html('A Simple Example'),
>     h1('A Simple Example'),
>     start_form,
>     "What's your question? ",textfield('$question'),
>     p,
>     "What's the answer? ",textfield('$answer'),
>     p,
>     submit,
>     end_form,
>     hr;
>
>     if (param()) {
>     print
>  "Your question is: ",em(param('$question')),
>  p,
>  "The answer is: ",em(param('$answer')),
>  p,
>  open (HOPE, ">dat.html") || die print "cant open:";
> print (HOPE "<html>\n<head>\n<title>this is the working
> copy</title>\n<body>");
>
> print (HOPE (param('$question')));
> print (HOPE "\n");
> print (HOPE (param('$answer')));
>
> print (HOPE "\n</body>\n</html>");
> close HOPE;
>  hr;
> }
> print end_html;
>
> Thanks,
> ~arthur
> star@sonic.net



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

Date: Sat, 01 Jul 2000 19:00:54 GMT
From: arthur <star@sonic.net>
Subject: Can get perl to open doc, but how do I get it to open html on the fly?
Message-Id: <B582E44E.22DE%star@sonic.net>

Good Day,

I have a script that can open and post to a file in my directory but how can
I make that file (it is in html format) open on the web?

#!/usr/bin/perl

use CGI qw(:standard);
use IO File;

print header;


print start_html('A Simple Example'),
    h1('A Simple Example'),
    start_form,
    "What's your question? ",textfield('$question'),
    p,
    "What's the answer? ",textfield('$answer'),
    p,
    submit,
    end_form,
    hr;
    
    if (param()) {
    print 
 "Your question is: ",em(param('$question')),
 p,
 "The answer is: ",em(param('$answer')),
 p,
 open (HOPE, ">dat.html") || die print "cant open:";
print (HOPE "<html>\n<head>\n<title>this is the working
copy</title>\n<body>");

print (HOPE (param('$question')));
print (HOPE "\n");
print (HOPE (param('$answer')));

print (HOPE "\n</body>\n</html>");
close HOPE;
 hr;
}
print end_html;

Thanks,
~arthur
star@sonic.net





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

Date: Sat, 01 Jul 2000 20:04:14 GMT
From: Kirill Sapelkin  <znanie@shell5.ba.best.com>
Subject: DBI: Error inserting into dbf file
Message-Id: <29s75.996$0x.30731@nuq-read.news.verio.net>

Hello !

I am trying to load an xbase dbf file with data from a "|" delimited
text file.  I can insert specific values  like ('joe','moe') but I cannot
figure out how to load from a text file.  I tried to imitate the example in DBI
perldoc page to no avail.  Below are my efforts so far.

Grateful for any help or direction.

Kirill
********code
#!/usr/bin/perl
# This formats, recodes and writes to a text file
use DBI;
$dbh = DBI->connect("DBI:XBase:/usr/src/sbt");
$sth = $dbh->prepare("insert into ar-custo ( custno ) values ( \@fields[0] )");
 open(BOOKLIST, "fgcust.unl");
  while(<BOOKLIST>) {
  	 chop;
	 @fields = split(/\|/);
    $sth->execute(@fields[0]);
 	 }
$dbh->disconnect();

*****************error messages
Error Messages.

DBD::XBase::db prepare failed: Unknown SQL command near ` @fields[0] )' 
at ./test.pl line 7.

Can't call method "execute" on an undefined value at ./test.pl line 12,
<BOOKLIST> chunk 1.

*********************This is fgcust.unl.

CENT3|Center Unified School Distr.|K.Crane-Maggie McJ|8408 Watt Ave||Antelope|CA|95843|916/338-6400|RC|B|3|07/09/1998|1000.0|10|0.0|0.0|CA|
YARB2|Natalia Yarba||736 Lindsay Circle||North Auvora|IL|60542|708/906-0196|RO|B|2|04/25/1900|1000.0|0|0.0|0.0||
RAZD3|Razdolna Elementary School|Olga Basargin|P.O.Box 15098||Fritz Creek|AK|99603-6098|907/235-6870|RC|B|3|07/09/1998|1000.0|10|0.0|0.0||
BEST|Best Friends|Lorrain Smith|2241 140th Ave. N.E.||Bellevue|WA|98005|509/838-8213|WS|G|3|05/13/1995|1000.0|50|0.0|0.0||
VASS3|Alexei Vassilev||2333 Priscilla St  # 3||St. Paul|MN|55108|612/645-0416/H|RC|B|2|01/01/1980|1000.0|0|0.0|0.0||
GEVO2|Larisa Gevorkyan|Larisa Gevorkyan|2310 N. Fairview St. # 206||Burbank|CA|91504|818/563-9216|SU||2|03/10/1995|1000.0||0.0|0.0||
HIGH3|Highland Park Element. School|Mike Ruffell|1012 S.W. Trenton St.||Seattle|WA|98106|206/281-6408|RO|B|3|01/01/1980|1000.0|10|0.0|0.0||
JOHN6|James D. Johnson||1317 Willmar Ave. SW||Willmar|MN|56201|612/235-5763|RO|B|2|12/29/1995|1000.0|0|0.0|0.0||
UUTL2|Merrill Library||Acquisitions Dept.|Utah State University|Logan|UT|84322-3000|   /   -|RO|U|3|01/01/1980|1000.0|10|0.0|0.0||
GIZE2|Walter Gize||3540 Bryant St.||Palo Alto|CA|94306|415/494-0144|SU|S|2|12/05/1995|1000.0|0|0.0|0.0|CA|

*********************xbase dbf file structure

CUSTNO    C  6   0
COMPANY   C 35   0
CONTACT   C 20   0
TITLE     C 20   0
ADDRESS1  C 30   0
ADDRESS2  C 30   0
CITY      C 15   0
STATE     C  2   0
ZIP       C 10   0
PHONE     C 12   0
TERR      C  2   0
INDUST    C  2   0
SALESMN   C  2   0
SOURCE    C  1   0
CODE      C  1   0
TERMS     C  1   0
SVC       C  1   0
LDATE     C  8   0
LASTPAY   C  8   0
LIMIT     N  6   0
DISC      N  2   0
BALANCE   N 10   2
YTDSLS    N 10   2
ONORDER   N 10   2
CREDIT    N 10   2
TAX       N  5   3
GLLINK    C  3   0
COMMENT   C 30   0
SIGNATURE N  2   0


-- 

Kirill Sapelkin
znanie@best.com


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

Date: 1 Jul 2000 19:53:17 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: foreach loop and sendmail ..
Message-Id: <962480783.8137@itz.pp.sci.fi>

In article <39536471.37201244@attglobal.net>, Drew Simonis wrote:
>Last time I was manually crafting a message to a sendmail process, 
>a . on a line all by its self was the signal to send the message.  
>
>I'd assume that hasn't changed.

It has - probably long before you tried it, in fact - provided you use
the -oi switch, which is generally a good idea.  Even if it isn't, the
dot is still not _necessary_.  You can always simply close the pipe.

[no Perl content - followups set]

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Sat, 1 Jul 2000 21:08:57 +0200
From: RonR <ronr@my-deja.com>
Subject: how to get text enclosed by matching () ?
Message-Id: <01HW.B5840E6900263FA41267D8B0@news.planet.nl>

Hi,

a line: "blabla bla (xyz, abc(n), xyz, abc(n)) etc etc"
I want to get the list enclosed by the matching braces
giving: "( xyz, abc(n), xyz, abc(n) )" or eventually without the braces.

Is there an easy way to do this ? The braces are always in pairs (if that 
helps).

any input will be apreciated,
-- 
Ronald.    <  \_ _                     o o
                       | o  \     %-/\//_\\/\-%             
                       '(*)-'---(*)       (*)       
home: http://home.wxs.nl/~ronr/RonR.html
PGP :  http://home.wxs.nl/~ronr/ronr_pgp.key
 The best way to accelerate a computer 'running' windows is by gravitation.



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

Date: Sat, 01 Jul 2000 19:27:56 GMT
From: James Fisher <jfisher@epotec.com>
Subject: Re: how to get text enclosed by matching () ?
Message-Id: <395E45F7.A4A960CF@epotec.com>

Go to your friendly neighborhod command prompt perldoc perlre

Depending on what else could be in the string this could get complex.  So this
regex version would probably be naive, but would work.

#!/usr/bin/perl

$string = "asfasdf asdfasdf (xyz, abc(n), xyz, abc(n)) etc etc";
$string =~ /\(((.*)+)\)/;
print "The string is $string\n";
print "The inner string is $1";

You should really invest in a book called Mastering Regular Expressions.  Its
worth every penny....

JF



RonR wrote:

> Hi,
>
> a line: "blabla bla (xyz, abc(n), xyz, abc(n)) etc etc"
> I want to get the list enclosed by the matching braces
> giving: "( xyz, abc(n), xyz, abc(n) )" or eventually without the braces.
>
> Is there an easy way to do this ? The braces are always in pairs (if that
> helps).
>
> any input will be apreciated,
> --
> Ronald.    <  \_ _                     o o
>                        | o  \     %-/\//_\\/\-%   
>                        '(*)-'---(*)       (*)
> home: http://home.wxs.nl/~ronr/RonR.html
> PGP :  http://home.wxs.nl/~ronr/ronr_pgp.key
>  The best way to accelerate a computer 'running' windows is by gravitation.



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

Date: Sat, 01 Jul 2000 21:30:24 +0200
From: Christian Vandsų <christian@fabel.dk>
Subject: Re: how to get text enclosed by matching () ?
Message-Id: <lihslss4dcm1chnqjs2pvu7pds9b53dqun@4ax.com>

On Sat, 1 Jul 2000 21:08:57 +0200, RonR <ronr@my-deja.com> wrote:


>a line: "blabla bla (xyz, abc(n), xyz, abc(n)) etc etc"
>I want to get the list enclosed by the matching braces
>giving: "( xyz, abc(n), xyz, abc(n) )" or eventually without the braces.

Using that .* is greedy:

#! /usr/local/bin/perl -w

use strict;
my $line="blabla bla (xyz, abc(n), xyz, abc(n)) etc etc";
my $res = $1 if ($line=~ m/.*?(\(.*\))/g);

print "Original line: $line\n Largest section in braces: $res\n";



/Christian


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

Date: Sat, 01 Jul 2000 18:41:44 GMT
From: webqueen, queen of the web <webqueen@my-deja.com>
Subject: I cant use m?
Message-Id: <8jle16$dvp$1@nnrp1.deja.com>

I defined a package m, and in another module tried:

use strict;
use m;

   .
   .

  my %x=%{m::serveup_sumhash()};

and the Perl compiler kept complaining about a bareword on the line.
After trying various thing I finally changed m to something else like mm
and Bingo it worked.

There is no builtin "m"- the closest thing is m/// I guess. Why the
restriction?

HUG,
WQ



--
Time is nature's way of preventing everything from happening at once.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 1 Jul 2000 19:38:00 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: I cant use m?
Message-Id: <slrn8lsi3s.74b.efflandt@efflandt.xnet.com>

On Sat, 01 Jul 2000, webqueen, queen of the web <webqueen@my-deja.com> wrote:
>I defined a package m, and in another module tried:
>
>use strict;
>use m;
>
>   .
>   .
>
>  my %x=%{m::serveup_sumhash()};
>
>and the Perl compiler kept complaining about a bareword on the line.
>After trying various thing I finally changed m to something else like mm
>and Bingo it worked.
>
>There is no builtin "m"- the closest thing is m/// I guess. Why the
>restriction?

You mean m//, but you can use most any character to enclose the regex, so
Perl would have a hard time telling whether m:: is used for matching a
null string with options or something to do with your package.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Sat, 01 Jul 2000 18:28:38 GMT
From: "Thomas" <mnysurf@home.comREMOVE>
Subject: Re: Installing modules onto Tripod
Message-Id: <qLq75.3124$6y5.3401381@news2.rdc2.tx.home.com>

What is the URL for this FAQ that you are talking about?


"Clinton A. Pierce" <clintp@geeksalad.org> wrote in message
news:_1g75.15905$fR2.185211@news1.rdc1.mi.home.com...
> [Posted and mailed]
>
> In article <ELd75.2772$6y5.2788392@news2.rdc2.tx.home.com>,
> "Thomas" <mnysurf@home.comREMOVE> writes:
> > I want to use LWP.pm with a cgi script on my website that is hosted by
> > tripod.com.  Tripod has Perl, but it does not include LWP.  I obviously
do
> > not have access to the actual Perl program, so how can I install LWP.pm?
>
> Try the following FAQ answers:
>
>    (section 8)   How do I keep my own module/library directory?
>
> you'll want this too from section 8:
>
>    How do I add the directory my program lives in to the module/library
search path?
>
> Take a browse through "perldoc perlmod" too.  Good stuff in there.
>
>
> --
>     Clinton A. Pierce              Teach Yourself Perl in 24 Hours!
>   clintp@geeksalad.org         for details see http://www.geeksalad.org
> "If you rush a Miracle Man,
> you get rotten Miracles." --Miracle Max, The Princess Bride




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

Date: 1 Jul 2000 19:51:58 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: LPDEST Environment Variable
Message-Id: <8jleke$poa$1@orpheus.gellyfish.com>

On Thu, 29 Jun 2000 15:03:24 -0700 Gary Yasuda wrote:
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> 

Dont do that - if your news client cant be fixed to emit plain test
then use a different client ...

> I am using Perl 5.6.0 with HP-UX 11.0.
> I used the Env module so that I can use the LPDEST variable.
> I wrote a script so that a user can designate a printer from
> the command line.
> # print.pl PRINTER
> In my code I include:
> use Env;
> $LPDEST=$ARGV[0];
> system("echo $LPDEST");
> # PRINTER is displayed
> system("lp file");
> The message:
> "lp: no system default destination" is displayed.
> In the system("echo $LPDEST"), the PRINTER designated is
> displayed prior to executing the "lp" command.  Can someone
> help me get this to print to the printer in LPDEST?

You need to cause the Env module to tie that variable -

  use Env qw(LPDEST);

although why you cant just do use $ENV{LPDEST} in this limited case beats
me ...

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Sat, 01 Jul 2000 18:37:07 GMT
From: James Fisher <jfisher@epotec.com>
Subject: Re: Newbie question: extract colums from a file into an array
Message-Id: <395E3A0E.BD60C7F1@epotec.com>

My solution to number 1.

#!/usr/bin/perl -w

open(TEXTFILE, "data.txt");

while(<TEXTFILE>) {
    push @Values, [ (split("\t"))[2,5] ];
}

for $array_ref ( @Values ) {
    print "@$array_ref\n";
}

Number 2.
Hmmm  I am assuming you mean splitting the array above into two arrays??
Please explain.  If so, you could modify the previous sample to do it in
just a couple line changes...

JF


Clemens Hermann wrote:

> Hi,
>
> I was digging around the web quite a while but did not find a solution
> for my problem:
> A Textfile with 8 colums and several 1000 rows.
> To evaluate the file I only need 2 of the 8 rows (Nr. 3 and Nr. 6).
> How can I
>
> 1. create an array containing the two columns and any line
>
> 2 create two arrays each containing one column.
>
> The file contains no real "colums", only strings seperated by tabs.
>
> Thanks in advance for any hint.
>
> Clemens



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

Date: Sat, 01 Jul 2000 14:33:22 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Newbie question: extract colums from a file into an array
Message-Id: <mbudash-0107001433220001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>

In article <395e22dd.9600231@news.btx.dtag.de>, haribeau@gmx.net (Clemens
Hermann) wrote:

> Hi,
> 
> I was digging around the web quite a while but did not find a solution
> for my problem: 
> A Textfile with 8 colums and several 1000 rows.
> To evaluate the file I only need 2 of the 8 rows (Nr. 3 and Nr. 6).
> How can I 
> 
> 1. create an array containing the two columns and any line
> 

huh? "any line"?

> 2 create two arrays each containing one column.
> 

one way (untested):

my $filename = 'whatever';
my (@col3s, @col6s);
open (F, $filename) or die ("Can't open $filename: $!");
while (<F>) {
   chomp;
   my @cols = split (/\t/);
   push (@col3s, $cols[2]);
   push (@col6s, $cols[5]);
}
close (F);

> The file contains no real "colums", only strings seperated by tabs.
> 
> Thanks in advance for any hint.
> 
> Clemens

hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: 01 Jul 2000 21:21:52 GMT
From: kcmage@aol.com (KCMage)
Subject: newbie with a big problem
Message-Id: <20000701172152.02057.00002063@ng-md1.aol.com>

Hi, I'm KC..and I'm kind of new to CGIs, so be gentle =)
In any case, I was commissioned by my manager to write a CGI that would take 
information from a form, stick it into a generic database (pretty much a text
file with "|" in between the fields...we're going to use that and parse and
stick them in a larger database later), then write out 2 mail messages..one for
our customers, and one for us. The CGI itself runs well in UNIX from the
command line with no errors (Well, a few, but I've put #s infront of all the
trouble spots, so I'll fix those later). My main concern is the fact that the
CGI refuses to run from a browser standpoint. It keeps giving me an "Internal
Server Error" of 500, which means the script isn't running right. Below here is
the script itself, any help of any kind is appreciated. Thanks. 

P.S. Its quite large..if anyone can help me make the damn thing smaller, that'd
be appreciated also. =)

****
#!/usr/bin/perl

#check the mail
if ($FORM{'Email'}) {
        unless ($FORM{'Email'} =~ /\w+@\w+.\w+/) {
                print "Content-type: text/html\n\n";
                print "<html><head><title>Bad E-mail</title></head>\n";
                print "<body><h1>Bad E-mail</h1><br>The e-mail address that
you've\n";
                print "entered, $FORM{'Email'}, is invalid.  Please click back
and\n";
                print "try again.\n";
		print "</body></html>\n"
                exit;
        }
}

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pair) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ /s\n/ /g;
$value =~ /s\r//g;
$value =~ /s\cM//g;
$FORM{$name} = $value;
}

open(OUTF,">>main.pbs") or dienice();

flock(OUTF,2);
seek(OUTF,0,2);

#Info about person
print OUTF "$FORM{'last'}|$FORM{'first'}|$FORM{'middle'}|$FORM{'Email'}|";

#Home phone number
print OUTF "$FORM{'AreaCode'}-$FORM{'Prefix'}-$FORM{'Suffix'}|";

#Work phone number
print OUTF "$FORM{'WAreaCode'}-$FORM{'WPrefix'}-$FORM{'WSuffix'}|";

#Info about address
print OUTF "$FORM{'Address_Line1'}|$FORM{'apt'}|$FORM{'Suite'}|";

#Info about area
print OUTF "$FORM{'City'}|$FORM{'State'}|$FORM{'Prov'}|$FORM{'Zip'}|";

#switches
foreach $key (keys %boxes) {
if ($FORM{$key} == 1) {
print OUTF "$key,";
}
}

#how they found us
print OUTF "|$FORM{'found'}\n";
close(OUTF);

#finished with the DBS, now onto the mailing...

#location of our mail program
$mailprog= '/usr/sbin/sendmail';
 
#send the message to the customer
$recipient = $FORM{'Email'};

#open mail program and pipe in info
open (MAIL, "|$mailprog -t") or diemail();

print MAIL "To: $recipient\n";
print MAIL "Reply-to: $FORM{'Email'} ($FORM{'last'})\n";
print MAIL "Subject: Welcome to Local-DSL\n\n";

#We print the information that you submitted.
print MAIL "Thank you for submitting your information to us. A representative
will contact you soon.\n";
print MAIL "If at any time you need assistance with your DSL service, please
don't hesitate \n";
print MAIL "to contact us. Our E-mail address is (((((mail))))) and our phone
number is ###-###-####.\n";
print MAIL "\n\n";
print MAIL "Below we have the information you submitted, please check it for
accuracy.\n";
print MAIL "Name: $FORM{'first'} $FORM{'middle'} $FORM{'last'}\n";
print MAIL "Home Phone: $FORM{'AreaCode'}-$FORM{'Prefix'}-$FORM{'Suffix'}\n";
print MAIL "Work Phone:
$FORM{'WAreaCode'}-$FORM{'WPrefix'}-$FORM{'WSuffix'}\n";
print MAIL "Address: $FORM{'Address_Line1'}, $FORM{'apt'}, $FORM{'Suite'}\n";
print MAIL "$FORM{'City'}, $FORM{'State'} $FORM{'Prov'} $FORM{'Zip'}\n";
print MAIL "And these are the services you asked for:\n";

#switches
foreach $key (keys %boxes) {
if ($FORM{$key} == 1) {
print "$key\n";
}
}

print MAIL "\nIf any part of this mail is incorrect, please contact us
immediately so\n";
print MAIL "we can make the appropriate changes at sales\@local-dsl.com.\n";
print MAIL "On behalf of Local-DSL, we thank you.";


close(MAIL);

#sendmail to us
$recipient = 'sales\@local-dsl.com';

#open mail program and pipe in info
open (MAIL, "|$mailprog -t") or diemail();

print MAIL "To: $recipient";
print MAIL "Reply-to: $FORM{'Email'} ($FORM{'last'})\n";
print MAIL "Subject: Potential New Member\n\n";

#We print the information that you submitted.
print MAIL "Information:";
print MAIL "\n\n";
print MAIL "Below we have the information you submitted, please check it for
accuracy.\n";
print MAIL "Name: $FORM{'first'} $FORM{'middle'} $FORM{'last'}\n";
print MAIL "Home Phone: $FORM{'AreaCode'}-$FORM{'Prefix'}-$FORM{'Suffix'}\n";
print MAIL "Work Phone:
$FORM{'WAreaCode'}-$FORM{'WPrefix'}-$FORM{'WSuffix'}\n";
print MAIL "Address: $FORM{'Address_Line1'}, $FORM{'apt'}, $FORM{'Suite'}\n";
print MAIL "$FORM{'City'}, $FORM{'State'} $FORM{'Prov'} $FORM{'Zip'}\n";
print MAIL "And these are the services they asked for:\n";

#switches
foreach $key (keys %boxes) {
if ($FORM{$key} == 1) {
print "$key\n";
}
}
close(MAIL)


#sub dienice {
#print "Content-type: text/html\n\n";
#print "<html><head><title>Problem</title></head>\n";
#print "<h2>Error</h2>\n";
#print "Couldn't open main.pbs for writing!";
#print "</body></html>\n";
#exit;
#}

#sub diemail {
#print "Content-type: text/html\n\n";
#print "<html><head><title>Problem</title></head>\n";
#print "<h2>Error</h2>\n";
#print "Can't access $mailprog!<p>\n";
#print "</body></html>\n";
#exit;
#}


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

Date: 01 Jul 2000 21:13:00 GMT
From: kcmage@aol.com (KCMage)
Subject: newbie..kinda... I've got a BIG problem
Message-Id: <20000701171300.02057.00002060@ng-md1.aol.com>

Hi, I'm KC..and I'm kind of new to CGIs, so be gentle =)
In any case, I was commissioned by my manager to write a CGI that would take 
information from a form, stick it into a generic database (pretty much a text
file with "|" in between the fields...we're going to use that and parse and
stick them in a larger database later), then write out 2 mail messages..one for
our customers, and one for us. The CGI itself runs well in UNIX from the
command line with no errors (Well, a few, but I've put #s infront of all the
trouble spots, so I'll fix those later). MY main concern is the fact that the
CGI refuses to run from a browser standpoint. It keeps giving me an "Internal
Server Error" of 500, which means the script isn't running right. Below here is
the script itself, any help of any kind is appreciated. Thanks. 

P.S. Its quite large..if anyone can help me make the damn thing smaller, that'd
be appreciated also. =)

********Script******
#!/usr/bin/perl

#check the mail
if ($FORM{'Email'}) {
        unless ($FORM{'Email'} =~ /\w+@\w+.\w+/) {
                print "Content-type: text/html\n\n";
                print "<html><head><title>Bad E-mail</title></head>\n";
                print "<body><h1>Bad E-mail</h1><br>The e-mail address that
you've\n";
                print "entered, $FORM{'Email'}, is invalid.  Please click back
and\n";
                print "try again.\n";
                exit;
        }
}

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pair) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ /s\n/ /g;
$value =~ /s\r//g;
$value =~ /s\cM//g;
$FORM{$name} = $value;
}

open(OUTF,">>main.pbs") or dienice();

flock(OUTF,2);
seek(OUTF,0,2);

#Info about person
print OUTF "$FORM{'last'}|$FORM{'first'}|$FORM{'middle'}|$FORM{'Email'}|";

#Home phone number
print OUTF "$FORM{'AreaCode'}-$FORM{'Prefix'}-$FORM{'Suffix'}|";

#Work phone number
print OUTF "$FORM{'WAreaCode'}-$FORM{'WPrefix'}-$FORM{'WSuffix'}|";

#Info about address
print OUTF "$FORM{'Address_Line1'}|$FORM{'apt'}|$FORM{'Suite'}|";

#Info about area
print OUTF "$FORM{'City'}|$FORM{'State'}|$FORM{'Prov'}|$FORM{'Zip'}|";

#switches
foreach $key (keys %boxes) {
if ($FORM{$key} == 1) {
print OUTF "$key,";
}
}

#how they found us
print OUTF "|$FORM{'found'}\n";
close(OUTF);

#finished with the DBS, now onto the mailing...

#location of our mail program
$mailprog= '/usr/sbin/sendmail';
 
#send the message to the customer
$recipient = $FORM{'Email'};

#open mail program and pipe in info
open (MAIL, "|$mailprog -t") or diemail();

print MAIL "To: $recipient\n";
print MAIL "Reply-to: $FORM{'Email'} ($FORM{'last'})\n";
print MAIL "Subject: Welcome to Our Company\n\n";
print MAIL "Below we have the information you submitted, please check it for
accuracy.\n";
print MAIL "Name: $FORM{'first'} $FORM{'middle'} $FORM{'last'}\n";
print MAIL "Home Phone: $FORM{'AreaCode'}-$FORM{'Prefix'}-$FORM{'Suffix'}\n";
print MAIL "Work Phone:
$FORM{'WAreaCode'}-$FORM{'WPrefix'}-$FORM{'WSuffix'}\n";
print MAIL "Address: $FORM{'Address_Line1'}, $FORM{'apt'}, $FORM{'Suite'}\n";
print MAIL "$FORM{'City'}, $FORM{'State'} $FORM{'Prov'} $FORM{'Zip'}\n";
print MAIL "And these are the services you asked for:\n";

#switches
foreach $key (keys %boxes) {
if ($FORM{$key} == 1) {
print "$key\n";
}
}

print MAIL "\nIf any part of this mail is incorrect, please contact us
immediately so\n";
print MAIL "we can make the appropriate changes at ((EMAIL)).\n";
print MAIL "On behalf of our company, we thank you.";


close(MAIL);

#sendmail to us
$recipient = '(OURMAIL)';

#open mail program and pipe in info
open (MAIL, "|$mailprog -t") or diemail();

print MAIL "To: $recipient";
print MAIL "Reply-to: $FORM{'Email'} ($FORM{'last'})\n";
print MAIL "Subject: Potential New Member\n\n";

#We print the information that you submitted.
print MAIL "Information:";
print MAIL "\n\n";
print MAIL "Below we have the information they submitted.\n";
print MAIL "Name: $FORM{'first'} $FORM{'middle'} $FORM{'last'}\n";
print MAIL "Home Phone: $FORM{'AreaCode'}-$FORM{'Prefix'}-$FORM{'Suffix'}\n";
print MAIL "Work Phone:
$FORM{'WAreaCode'}-$FORM{'WPrefix'}-$FORM{'WSuffix'}\n";
print MAIL "Address: $FORM{'Address_Line1'}, $FORM{'apt'}, $FORM{'Suite'}\n";
print MAIL "$FORM{'City'}, $FORM{'State'} $FORM{'Prov'} $FORM{'Zip'}\n";
print MAIL "And these are the services they asked for:\n";

#switches
foreach $key (keys %boxes) {
if ($FORM{$key} == 1) {
print "$key\n";
}
}
close(MAIL)


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

Date: 1 Jul 2000 19:13:42 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Number or string item in an array?
Message-Id: <962478084.4710@itz.pp.sci.fi>

In article <3956bdfd.1998281@news.skynet.be>, Bart Lateur wrote:
>Tad McClellan wrote:
>>
>>Why do you think you need to know this?
>
>Er... because bitwise operators make the distinction?

Well, in that case, why not use them for the test?

  sub is_num ($) { ($_[0]^"0") eq ($_[0]^"0"^"0") }

(The extra xor's work around an obscure integer sign bug/misfeature in
some versions of perl.)

But I doubt if this is what the original poster wanted;  It doesn't
tell whether a variable would be considered numeric by perl -w, only
whether perl already has computed a numeric value for it.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method."  -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.



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

Date: Sat, 01 Jul 2000 20:42:15 +0200
From: Konstantin Schauwecker <hi@konstantin-schauwecker.de>
Subject: Parallel::UserAgent
Message-Id: <395E3B87.AFDC27A9@konstantin-schauwecker.de>

Hi!
I'm usig Parallel::UserAgent for a small meta-searchengine. It works
perfect, but if only one search-engine is down I have to wait a verry,
verry long time for the search result. I called
$pua->timeout   (5);
but it had no effect (5 seconds, that's an extremely short time for a
searchengine). Can anybody help me?

Konstantin Schauwecker
-- 
Free C++ Stuff at                    |
http://www.c-plus-plus-archiv.de     | My ICQ:
-------------------------------------| **********
My Homepage:                         | *68193331*
http://www.konstantin-schauwecker.de | **********


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

Date: 1 Jul 2000 19:35:43 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: sending a password to a server.
Message-Id: <8jldlv$mk6$1@orpheus.gellyfish.com>

On Fri, 30 Jun 2000 06:08:20 -0400 Andrew G. Bacchi wrote:
> Jonathan Stowe wrote:
> 
>> On Thu, 29 Jun 2000 14:08:07 -0400 Andrew Bacchi wrote:
>> > I have to send a password to a server to restart it from a Perl script.
>> > Can someone tell me where to look to do this?  A hint would be helpful.
>>
>> A hint as to what you mean by 'send' and 'server' might be of use.
>>
> 
> OK, I am stopping my Apache httpd server from a Perl script, changing the
> access log file and then restarting the server using ssl.  ssl requires a
> password to be entered at the prompt.  How can I make my script aware of the
> password prompt and submit the password when needed?  I hope I have explained
> it fully.  Thanks.
> 

Right.  You might want to look at the Expect module available from CPAN
<http://search.cpan.org>  (alternatively you might ask in the group :
comp.infosystems.www.servers.unix about how you could cause the server
to restart without an SSL passphrase).

/J\
-- 
** This space reserved for venue sponsor for yapc::Europe **
              <http://www.yapc.org/Europe/> 


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

Date: Sat, 01 Jul 2000 12:45:09 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: sql without win32::odbc? operating systems?
Message-Id: <395E4A45.DBD34E76@vpservices.com>

Bob Walton wrote:
> 
> If all you want to do is run SQL, use the DBI module and the DBD::RAM
> driver.  That way you don't have to actually mess around with a
> database. Alternatively, use the DBD::CSV driver if you want your
> "database" to hang around between executions of your program.

You must have an early version of DBD::RAM because the recent versions
support file  access/creation in a number of formats (XML; fixed-width;
CSV, pipe, tab and other "delimited" formats; user defined formats).  It
still supports the in-memory usage so it can be operated either with or
without file permanence.  Yes, I know, the name no longer reflects what
the module can do, if you have any recommendations, let me know.

DBD::RAM's file access is mostly through Jochen Wiedman's DBD::File
module which is also the basis for his DBD::CSV so the two work
similarly for most file I/O.

DBD::CSV and DBD::XBase and DBD::Sprite and (on win32) DBD::ODBC and
DBD::ADO are also other alternatives for using Perl, SQL, and DBI
without a database engine.

-- 
Jeff


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

Date: Sat, 01 Jul 2000 19:05:55 GMT
From: Kirill Sapelkin  <znanie@shell5.ba.best.com>
Subject: Trying to insert into an xbase file.
Message-Id: <nir75.991$0x.30677@nuq-read.news.verio.net>

Hello !

I am trying to load an xbase dbf file with data from a "|" delimited
text file.  I can insert specific values  like ('joe','moe') but I cannot
figure out how to load from a text file.  I tried to imitate the example in DBI
perldoc page to no avail.  Below are my efforts so far.

Grateful for any help or direction.

Kirill
********code
#!/usr/bin/perl
# This formats, recodes and writes to a text file
use DBI;
$dbh = DBI->connect("DBI:XBase:/usr/src/sbt");
$sth = $dbh->prepare("insert into ar-custo ( custno ) values ( \@fields[0] )");
 open(BOOKLIST, "fgcust.unl");
  while(<BOOKLIST>) {
  	 chop;
	 @fields = split(/\|/);
    $sth->execute(@fields[0]);
 	 }
$dbh->disconnect();

*****************error messages
Error Messages.

DBD::XBase::db prepare failed: Unknown SQL command near ` @fields[0] )' 
at ./test.pl line 7.

Can't call method "execute" on an undefined value at ./test.pl line 12,
<BOOKLIST> chunk 1.

*********************This is fgcust.unl.

CENT3|Center Unified School Distr.|K.Crane-Maggie McJ|8408 Watt Ave||Antelope|CA|95843|916/338-6400|RC|B|3|07/09/1998|1000.0|10|0.0|0.0|CA|
YARB2|Natalia Yarba||736 Lindsay Circle||North Auvora|IL|60542|708/906-0196|RO|B|2|04/25/1900|1000.0|0|0.0|0.0||
RAZD3|Razdolna Elementary School|Olga Basargin|P.O.Box 15098||Fritz Creek|AK|99603-6098|907/235-6870|RC|B|3|07/09/1998|1000.0|10|0.0|0.0||
BEST|Best Friends|Lorrain Smith|2241 140th Ave. N.E.||Bellevue|WA|98005|509/838-8213|WS|G|3|05/13/1995|1000.0|50|0.0|0.0||
VASS3|Alexei Vassilev||2333 Priscilla St  # 3||St. Paul|MN|55108|612/645-0416/H|RC|B|2|01/01/1980|1000.0|0|0.0|0.0||
GEVO2|Larisa Gevorkyan|Larisa Gevorkyan|2310 N. Fairview St. # 206||Burbank|CA|91504|818/563-9216|SU||2|03/10/1995|1000.0||0.0|0.0||
HIGH3|Highland Park Element. School|Mike Ruffell|1012 S.W. Trenton St.||Seattle|WA|98106|206/281-6408|RO|B|3|01/01/1980|1000.0|10|0.0|0.0||
JOHN6|James D. Johnson||1317 Willmar Ave. SW||Willmar|MN|56201|612/235-5763|RO|B|2|12/29/1995|1000.0|0|0.0|0.0||
UUTL2|Merrill Library||Acquisitions Dept.|Utah State University|Logan|UT|84322-3000|   /   -|RO|U|3|01/01/1980|1000.0|10|0.0|0.0||
GIZE2|Walter Gize||3540 Bryant St.||Palo Alto|CA|94306|415/494-0144|SU|S|2|12/05/1995|1000.0|0|0.0|0.0|CA|

*********************xbase dbf file structure

CUSTNO    C  6   0
COMPANY   C 35   0
CONTACT   C 20   0
TITLE     C 20   0
ADDRESS1  C 30   0
ADDRESS2  C 30   0
CITY      C 15   0
STATE     C  2   0
ZIP       C 10   0
PHONE     C 12   0
TERR      C  2   0
INDUST    C  2   0
SALESMN   C  2   0
SOURCE    C  1   0
CODE      C  1   0
TERMS     C  1   0
SVC       C  1   0
LDATE     C  8   0
LASTPAY   C  8   0
LIMIT     N  6   0
DISC      N  2   0
BALANCE   N 10   2
YTDSLS    N 10   2
ONORDER   N 10   2
CREDIT    N 10   2
TAX       N  5   3
GLLINK    C  3   0
COMMENT   C 30   0
SIGNATURE N  2   0


-- 

Kirill Sapelkin
znanie@best.com


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

Date: Sat, 01 Jul 2000 12:41:39 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Trying to insert into an xbase file.
Message-Id: <395E4973.2B39CC58@vpservices.com>

Kirill Sapelkin wrote:
> 
> I am trying to load an xbase dbf file with data from a "|" delimited
> text file.  I can insert specific values  like ('joe','moe') but I cannot
> figure out how to load from a text file.  I tried to imitate the example in DBI
> perldoc page to no avail.  Below are my efforts so far.
>
> #!/usr/bin/perl

You really should turn on warnings and strict.

> # This formats, recodes and writes to a text file
> use DBI;
> $dbh = DBI->connect("DBI:XBase:/usr/src/sbt");

You really should turn error checking on with {RaiseError=>1}

> $sth = $dbh->prepare("insert into ar-custo ( custno ) values ( \@fields[0] )");

Are you only inserting one field (custno), if so then remove \@fields[0]
and replace it with a question mark.  If you mean to insert the entire
row, then you need to either list all or none of the field names and you
need one qestion mark for each field, something like this:

my $sth = $dbh->prepare("insert into ar-custo values ( ?,?,? )");


>  open(BOOKLIST, "fgcust.unl");

You really should check for and display file open errors.

>   while(<BOOKLIST>) {
>          chop;

chomp is probably better

>          @fields = split(/\|/);
>     $sth->execute(@fields[0]);

If you really mean to insert only one field, then change that to
$fields[0] i.e. replace the @ with a $.  If you mean to insert the
entire row, then you need to feed execute the entire row here, not one
value:

     $sth->execute(@fields);

-- 
Jeff


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

Date: 1 Jul 2000 20:02:11 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: User & Host based authentication
Message-Id: <slrn8lsjh6.74b.efflandt@efflandt.xnet.com>

On Sat, 1 Jul 2000, Paul Knighton <paul.knighton@bigfoot.com> wrote:
>Could someone please tell me if relying on a user's
>$ENV{'REMOTE_HOST'}:$ENV{'REMOTE_ADDR'} returned from their web server to
>remain the same for (at least) the duration that they are connected to their
>ISP is naive ???

Yes.  So is posting the same message individually to multiple newsgroups
without crossposting.  It was answered in one of the other newsgroups you
individually posted it to.

If you are not sure where to post, you can crosspost the same message to
multiple groups by using a comma separated list of newsgroups.  Then an
answer in any of the groups will show up in all of the ones you posted to.
But use it sparingly and make sure that the groups are somewhat
appropriate.

Questions about webserver variables and internet in general (IP addresses)  
have nothing to do with Perl.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Sat, 1 Jul 2000 22:22:37 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: User & Host based authentication
Message-Id: <Pine.GHP.4.21.0007012219390.17749-100000@hpplus03.cern.ch>

On 1 Jul 2000, David Efflandt wrote:

> On Sat, 1 Jul 2000, Paul Knighton <paul.knighton@bigfoot.com> wrote:
[...]

> If you are not sure where to post, you can crosspost the same message to
> multiple groups by using a comma separated list of newsgroups.  

Yes, but the CGI group's automoderator bot does not tolerate
crossposting.

The assumption seems to be that if it's on-topic there, then it's
off-topic everywhere else.  In this instance I think that was right,
and Paul's question was off-topic here on c.l.p.misc

> Questions about webserver variables and internet in general (IP addresses)  
> have nothing to do with Perl.

Quite.

all the best



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

Date: 01 Jul 2000 14:38:16 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Yet Another Abigail Admirer (WAS Re: Crazy enough that it might just work...) :)
Message-Id: <slrn8lsfmg.3us.abigail@alexandra.delanet.com>

that's my address' Newton (nospam.newton@gmx.li) wrote on MMCDXCVI
September MCMXCIII in <URL:news:395e0f8b.93137548@news.nikoma.de>:
|| On 17 Jun 2000 12:08:21 EDT, abigail@delanet.com (Abigail) wrote:
|| 
|| > Come to YAPC and join my talk about JAPHs.
|| 
|| Will you be giving it at YAPC::Europe, as well?


No, for two reasons. First is that I've no idea on which continent
I will be living the end of September, so I'm not going to commit to
a conference at that time. Second is that I already gave the talk on
YAPC::America. Giving the same talk on multiple conferences is, in my
book, not done.



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 3533
**************************************


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