[12676] in Perl-Users-Digest
Perl-Users Digest, Issue: 85 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 9 00:07:26 1999
Date: Thu, 8 Jul 1999 21:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 8 Jul 1999 Volume: 9 Number: 85
Today's topics:
Re: [1] 988?? (Abigail)
Re: [1] 988?? (Martien Verbruggen)
Re: Assocative Arrays <mjcarman@zeus.ia.net>
Re: cgi timeout <kenhirsch@myself.com>
Re: Checking if a url is valid (elephant)
Re: Checking if a url is valid <ysgan@hotmail.com>
Re: fork() in Win32 <john@dlugosz.com>
Re: help with read( ) <bbridges@seark.net>
Re: help with read( ) <uri@sysarch.com>
Re: help with read( ) (Ronald J Kimball)
Re: Help! My pingecho to Linux is going pong! (Anno Siegel)
Re: Help! My pingecho to Linux is going pong! <rwilliamson@uno.gers.com>
Re: Microsoft Word -> TXT? (Martien Verbruggen)
Re: Microsoft Word -> TXT? (Damian Conway)
Re: Microsoft Word -> TXT? <rpsavage@ozemail.com.au>
Re: Newbie assoc array question <mhc@Eng.Sun.COM>
Re: open+0 (Anno Siegel)
Re: open+0 (Michael Rubenstein)
Re: Perl - problem with 'open' <aperrin@mcmahon.qal.berkeley.edu>
Re: Perl and Microsoft access database <walton@frontiernet.net>
Re: Picture doesn't appear (Larry Rosler)
Re: single instance log file (Anno Siegel)
Sorting Hashes of Arrays <greg@hendigital.com.au>
Re: Which is better, Perl, Cold Fusion or... <mmongeau@yahoo.com>
Re: Yikes, confusion for my newbie self <rick.delaney@home.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Jul 1999 21:15:15 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: [1] 988??
Message-Id: <slrn7oamos.vka.abigail@alexandra.delanet.com>
bam bam biggie (kuryk@home.com) wrote on MMCXXXVIII September MCMXCIII in
<URL:news:vFch3.15361$UK2.11129@news.rdc1.md.home.com>:
@@ i am trying to figure out what the debug info is.
@@ i keep getting [1] 988
@@ [2] 989
@@ errors?!?!
Those are not errors. Just messages from the shell.
@@ i don't know what is wrong....my command line execution looks like
@@
@@ ./email.pl?from=joe@aol.co&subject=test&text=this is a test
So... you start up the program './email.pl?from=joe@aol.com', with any
letter on the place of the ?, and you do that in the background. Then
you start the program 'subject=test', also in the background. Next
you start 'text=this', with 3 parameters 'is', 'a' and 'test'.
I don't think you wanted to do that.
It looks like you need to read up on the manual of your shell.
@@ my code looks like the below code
@@ ###############code is below########################
@@ #!/usr/bin/perl -d
Where's the -w? Where's the 'use strict;'? Where's the -T? And why the -d?
@@ if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@@ @pairs = split(/&/, $ENV{'QUERY_STRING'});
@@ } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
@@ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@@ @pairs = split(/&/, $buffer);
@@ } else {
@@ die "Did not recognize METHOD as POST or GET!";
@@ }
Did you set your environment variables before calling the program?
@@ foreach $pair (@pairs) {
@@ ($name, $value) = split(/=/, $pair);
@@ $name =~ tr/+/ /;
@@ $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
@@ $value =~ tr/+/ /;
@@ $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
@@ $value =~ s///g;
Why is this? Is there a point in globally replacing nothing with nothing?
Why are you handrolling this stuff when there are modules doing it for
you?
@@ print "$value\n";
@@ print "$name\n";
@@ if ($Form{$name} && $value) {
@@ $Form{$name} = "$Form{$name}, $value";
@@ }elsif ($value) {
@@ push(@Field_Order,$name);
@@ $Form{$name} = $value;
@@ }
@@ }
@@
@@ print "$Form{'from'}\n";
@@ print "$Form{'subject'}\n";
@@ print "$Form{'text'}\n";
@@
@@ $from = $Form{'from'};
@@ $from =~ s/@/\@/; #change email @ to \@
Now, why do you want to do that?
@@ $subject = $Form{'subject'};
@@ $text = $Form{'text'};
@@
@@ print "$Form{'from'}\n";
@@ print "$Form{'subject'}\n";
@@ print "$Form{'text'}\n";
@@
@@ open(MAIL, '| /usr/lib/sendmail -t -oi');
What if the open fails?
@@ print MAIL <<EOF;
@@ To: myname\@mydomain.com
@@ From: $from
@@ Subject: $subject
@@ $text
@@ EOF
@@ close MAIL;
What if the close fails?
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Fri, 09 Jul 1999 02:23:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: [1] 988??
Message-Id: <O2dh3.114$J84.7937@nsw.nnrp.telstra.net>
In article <vFch3.15361$UK2.11129@news.rdc1.md.home.com>,
"bam bam biggie" <kuryk@home.com> writes:
> i am trying to figure out what the debug info is.
> i keep getting [1] 988
> [2] 989
> errors?!?!
Not errors. Your shell is putting two processes in the background, and
their pids are 988 and 989
> ./email.pl?from=joe@aol.co&subject=test&text=this is a test
Aha, that's where it happens. You can't execute stuff on the command
line with URL/CGI syntax. You will have to run it in a server, and
access it with a client. That is, if you insist using the code you
have. If you use the CGI module, you don't have to.
Those ampersands put the preceding 'command' in the background. And
since they're nonsensical, they'll fail.
> my code looks like the below code
> ###############code is below########################
> #!/usr/bin/perl -d
Why run it in the debugger?
Where is the -w?
Where is use strict?
> if ($ENV{'REQUEST_METHOD'} eq 'GET') {
> @pairs = split(/&/, $ENV{'QUERY_STRING'});
> } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> } else {
> die "Did not recognize METHOD as POST or GET!";
> }
The above [and the snipped stuff] is broken. You should use the CGI
module, which does it correctly.
> open(MAIL, '| /usr/lib/sendmail -t -oi');
You should check the return code of this open, and you should in the
case of pipe opens also check the return code of your close.
To be even more correct: You shouold catch SIGCHLD and/or SIGPIPE
# perldoc perlipc
# perldoc perlfaq
Martien
--
Martien Verbruggen |
Interactive Media Division | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd. | password?
NSW, Australia |
------------------------------
Date: Thu, 08 Jul 1999 21:46:30 -0500
From: Michael Carman <mjcarman@zeus.ia.net>
Subject: Re: Assocative Arrays
Message-Id: <37856286.697D4DD7@zeus.ia.net>
Victor Hannak wrote:
> Does Perl support triply or quadruply nested associative arrays?
Perl supports arbitrarily complex data structures via references. So yes,
you can create a hash with four seperate keys to define a value.
> How would you dereference something like this.
>
> $Level1_key{$level2_key{$level3_key{$level4_key}}}= value
Hmm. Normally one creates a multidimensional hash, that's a nested hash.
It's probably possible, but I'd have to do some serious headscratching to
figure out just what would be happening there and what sort of an
application would use such a construct. What you're probably after is
something like this:
$hash{$a}{$b}{$c}{$d} = value;
I actually use one of these, plus another key or two, in one of my programs.
In my case, each key is a parameter with two or more possible values, and I
need to determine which particular combination I'm dealing with so that I
can categorize it. I have a file which breaks down (as a table) all the
possible combinations and the category for each one. I read that into my
hash and then start making comparisons. It's much cleaner than the legacy
code I inherited: brute force nesting of conditionals!
> What would my print statement look like?
Assuming you want only a single value, it's easy:
print "$hash{$a}{$b}{$c}{$d}\n";
If you want to print the whole thing, that gets a little uglier:
foreach $a (keys %hash) {
foreach $b (keys %{$hash{$a}}) {
foreach $c (keys %{$hash{$a}{$b}}) {
foreach $d (keys %{$hash{$a}{$b}{$c}}) {
print "$hash{$a}{$b}{$c}{$d}\n";
}
}
}
}
Not difficult, just a lot of nested loops. Working with multi-dimensional
hashes is really pretty simple, just don't try visualizing anything beyond
three!
> Also, when creating a hash, can the value portion be an array of hashes?
Almost, the value can be a *reference* to an array of hash *references*.
I'll leave that one for you to puzzle out. Enjoy.
-mjc
------------------------------
Date: Thu, 8 Jul 1999 22:05:42 -0400
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: cgi timeout
Message-Id: <7m3lis$1vo$1@oak.prod.itd.earthlink.net>
Nicola <nicolabo@prof.it> wrote in message
news:7m2f5j$o51$1@serv1.iunet.it...
> I'd want to run a perl script that need 30 minutes to execute,
> but this is killed by the cgi-timeout limit of the server.
> Is there a method to avoid the timeout limit?
>
> Thank you.
> Nicola
What I would do is:
(1) create a uniquely named file
(2) write something like the following to that file
<html>
<head>
<meta http-equiv=refresh content=600>
<title>waiting</title>
</head>
<body>
check back later
</body>
</html>
(3) fork off a process that will run the perl script and write the output to
a (uniquely named) file
(4) redirect the user to that file
This does leave the small matter of cleaning up the file later.
------------------------------
Date: Fri, 9 Jul 1999 12:17:36 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: Checking if a url is valid
Message-Id: <MPG.11f006cc6eb9c703989b25@news-server>
Victor Gan writes ..
>The following works at the command line, but not as a CGI.
>Any idea what's wrong?
>It keeps returning 500 when run as a CGI script, regardless of the URL.
something server related perhaps (your code is correct) .. like the user
context that CGI scripts are executed on your server machine does not
have enable to access internet sites .. try running this script both from
the command line and via CGI (it just outputs the username of the current
context) .. I'll bet you get different results
#--begin
print "Content-type: text/plain\n\n";
print( ( getpwuid( $>))[0], "\n");
#--end
--
jason - remove all hyphens for email reply -
------------------------------
Date: Fri, 9 Jul 1999 11:36:26 +0800
From: "Victor Gan" <ysgan@hotmail.com>
Subject: Re: Checking if a url is valid
Message-Id: <37856e55.0@news.cyberway.com.sg>
The CGI script is running as nobody as expected.
elephant <e-lephant@b-igpond.com> wrote in message
news:MPG.11f006cc6eb9c703989b25@news-server...
> Victor Gan writes ..
> >The following works at the command line, but not as a CGI.
> >Any idea what's wrong?
> >It keeps returning 500 when run as a CGI script, regardless of the URL.
>
> something server related perhaps (your code is correct) .. like the user
> context that CGI scripts are executed on your server machine does not
> have enable to access internet sites .. try running this script both from
> the command line and via CGI (it just outputs the username of the current
> context) .. I'll bet you get different results
>
> #--begin
> print "Content-type: text/plain\n\n";
>
> print( ( getpwuid( $>))[0], "\n");
> #--end
>
> --
> jason - remove all hyphens for email reply -
------------------------------
Date: Thu, 8 Jul 1999 21:34:33 -0500
From: "John M. Dlugosz" <john@dlugosz.com>
Subject: Re: fork() in Win32
Message-Id: <DCE8DBA7F36AE674.5116F3484D4E9577.4F33FD8FF7673FC0@lp.airnews.net>
Question: I suppose the "indirect object" of 1 is to cause system to
directly load the program, instead of running the command-line shell to
launch the program. So, what becomes of the value? The docs say that it's
used to "lie about the name".
Since we're talking about Win32 here, one could use Win32::Process::Create
and have direct control over the "creation flags". Or, maybe someone will
add the Win32 ShellExecute API function to the standard Win32 set...
--John
David Boyce <David.Boyce@fmr.com> wrote in message
news:3784BE75.333D66FC@fmr.com...
> iqa wrote:
> >
> > Is there any way I can do like:
> > exec @command_list if (!fork());
> >
> > under Win32 environment where fork() is not suppported.
> >
> > system("@command_list") almost does it, but the problem is it waits the
> > command to complete its execution.
>
> It's not really a fork but the following construct:
>
> system 1, qw(notepad);
>
> shows how to exec a program and continue asynchronously.
>
> -David Boyce
------------------------------
Date: 9 Jul 1999 02:34:56 GMT
From: "Bob Bridges" <bbridges@seark.net>
Subject: Re: help with read( )
Message-Id: <01bec9b2$cdf500a0$5d64f5d0@bbridges.seark.net>
so, any fools out there who read the manual know how to use the read ( )
function/operator?
------------------------------
Date: 08 Jul 1999 22:42:36 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: help with read( )
Message-Id: <x73dyytug3.fsf@home.sysarch.com>
>>>>> "BB" == Bob Bridges <bbridges@seark.net> writes:
BB> so, any fools out there who read the manual know how to use the read ( )
BB> function/operator?
what is so difficult about reading the manual yourself? read is very
easy, it just reads from a file for a length, to a variable.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Thu, 8 Jul 1999 23:41:51 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: help with read( )
Message-Id: <1dundm2.1ley800n12eisN@p103.tc2.state.ma.tiac.com>
Bob Bridges <bbridges@seark.net> wrote:
> so, any fools out there who read the manual know how to use the read ( )
> function/operator?
Exactly! Any fools who read the manual know how to use the read()
function. You're starting to catching on.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 9 Jul 1999 03:20:17 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help! My pingecho to Linux is going pong!
Message-Id: <7m3pph$75q$1@lublin.zrz.tu-berlin.de>
Rusty Williamson <rwilliamson@uno.gers.com> wrote in comp.lang.perl.misc:
>Hi!
>
>I'm using pingecho to determine if a server is responding before I start
>sending commands to it and this is working great for all of my UNIX servers
>(DG/DGUX, Sequent/DYNIX, IBM/AIX, etc.) except for two Linux boxes.
>Although both respond to a ping at the UNIX prompt, the pingecho within my
>Perl script fails no matter how much I bump the timeout value. Does anyone
>know what could be going wrong or have any experience with this?
Yes, I see similar behavior here. Pingecho uses the tcp protocol
to establish accessibility, which seems to work with hosts running
anything but linux. The newer ping objects give you a choice of
the protocol, with these results: Tcp, unsurprisingly shows the
same behavior as pingecho. Udp (the default) runs into an error
in the Socket module (I haven't looked into that). Icmp, which is
what the unix ping does, works fine, but you must be root to use that.
Anno
------------------------------
Date: Thu, 8 Jul 1999 21:00:27 -0700
From: "Rusty Williamson" <rwilliamson@uno.gers.com>
Subject: Re: Help! My pingecho to Linux is going pong!
Message-Id: <Tseh3.542$VX3.25223@news.connectnet.com>
Hi Anno!
Thanks for getting back on this. Well, that's a bummer. However, for this
particular implementation users will be running as root so what 'newer ping
objects' were you referring to?
Thanks again!
Rusty
------------------------------
Date: Fri, 09 Jul 1999 02:33:02 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Microsoft Word -> TXT?
Message-Id: <ybdh3.117$J84.7937@nsw.nnrp.telstra.net>
In article <7m358l$nqu$1@nnrp1.deja.com>,
GJ <gj_at_work@my-deja.com> writes:
> Is there anyway to open a Microsoft Word document in a perl script
> and be able to get out just the text
Yep. You don't even need a perl script.
http://www.gnu.org/
Look for CatDoc. There are other tools around to do this.
> (and possibly the formating) so
If you want formatting, a plain text file will not be the right
intermediate.
> that it can be formated into HTML?
Word is supposed to be able to save HTML, isn't it?
Martien
--
Martien Verbruggen |
Interactive Media Division | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
Date: 9 Jul 1999 02:53:17 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Microsoft Word -> TXT?
Message-Id: <7m3o6t$neq$1@towncrier.cc.monash.edu.au>
mgjv@comdyn.com.au (Martien Verbruggen) writes:
>Word is supposed to be able to save HTML, isn't it?
Ever read one of those manuals that sometimes comes with cheap consumer
electronics? You know:
"You're ensured satisfaction will be the insertion from videos
to play with automatical...On dejecting the button of "Record"
your head will be erased without hesitation...For ultimate
safety and environment please deject the button named "O"
when you are no longer useful..."
Well, that's about the level of HTML that Microsoft Word produces :-(
Damian
PS: I nearly wrote "...the standard of HTML that Miscrosoft Word
produces...", but of course using the terms "standard" and
"Microsoft" together in the one sentence would be oxymoronic.
------------------------------
Date: Fri, 9 Jul 1999 12:51:41 +1000
From: "Pen and Ron Savage" <rpsavage@ozemail.com.au>
Subject: Re: Microsoft Word -> TXT?
Message-Id: <kwdh3.930$1u.6410@ozemail.com.au>
Tested:
#!perl -w
#
# Name:
# wordDemo1.pl
use strict;
use Win32::OLE;
# --------------------------------------------------------------------
my($docFile) = "C:\\Temp\\OleDemo.doc";
my($htmlFile) = "C:\\Temp\\OleDemo.html";
my($word) = Win32::OLE->new('Word.Application', 'Quit');
$word -> {Visible} = 1; # Watch what happens
my($doc) = $word -> Documents -> Open($docFile);
$word -> WordBasic -> FileSaveHTML($htmlFile);
$doc -> Close();
$word->Quit();
--
Cheers
ron@savage.net.au
pen@savage.net.au
http://savage.net.au/
GJ wrote in message <7m358l$nqu$1@nnrp1.deja.com>...
> Is there anyway to open a Microsoft Word document in a perl script
>and be able to get out just the text (and possibly the formating) so
>that it can be formated into HTML?
>Thanks.
>GJ
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
------------------------------
Date: 08 Jul 1999 20:23:50 -0700
From: Mike Coffin <mhc@Eng.Sun.COM>
Subject: Re: Newbie assoc array question
Message-Id: <8p6k8sa4ibd.fsf@Eng.Sun.COM>
Heather Wiley <heather.wiley@bentley.com> writes:
> I am familiar with awk and I know that if you test for the existence of
> an element
> in an associative array incorrectly , you actually create that "element"
> in the array
> How do you test for the existence of a key in an array?
exists $a{$key} returns true if %a contains $key.
-mike
------------------------------
Date: 9 Jul 1999 02:22:41 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: open+0
Message-Id: <7m3mdh$6vl$1@lublin.zrz.tu-berlin.de>
Andrew Allen <ada@fc.hp.com> wrote in comp.lang.perl.misc:
>Jan Egil Hagen (janha@nntp.ifi.uio.no) wrote:
>: open+0;print<0>
>
>: Does anybody have any idea why it works,
>
>Yes, because people on this newsgroup (and Perlites in general) are
>sick, twisted, perverse individuals.
>
>: and what it is happening?
>
>That's all waiting for you to discover in the
>documentation. "perlfunc", "perlop", and "perlvar" might be two places
>to start.
He forgot to mention we all start counting at zero.
Anno
------------------------------
Date: Fri, 09 Jul 1999 03:07:28 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: open+0
Message-Id: <37906746.144270219@nntp.ix.netcom.com>
On 9 Jul 1999 00:13:25 GMT, ada@fc.hp.com (Andrew Allen) wrote:
>That's all waiting for you to discover in the
>documentation. "perlfunc", "perlop", and "perlvar" might be two places
>to start.
For large values of two.
--
Michael M Rubenstein
------------------------------
Date: Thu, 08 Jul 1999 19:39:36 -0700
From: Andrew J Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: Perl - problem with 'open'
Message-Id: <378560E7.E8DF090D@mcmahon.qal.berkeley.edu>
Paul Glidden wrote:
> I am assuming the file is an executable, in which case you can not open the
> file to receive output from the file. Much like C++ the open command is to
> get the contents of a file.
Wrong! perldoc -f open:
If the filename begins with '|', the filename is interpreted as a
command to which output is to be piped, and if the filename ends with a
'|', the filename is interpreted as a command which pipes output to
us. See perlipc "Using open() for IPC" for more examples of this. (You are
not allowed to open() to a command that pipes both in and out, but see
IPC::Open2, IPC::Open3,
and perlipc/"Bidirectional Communication" for alternatives.)
--
-------------------------------------------------------------
Andrew Perrin - NT/Unix/Access Consulting - aperrin@mcmahon.qal.berkeley.edu
I'M LOOKING FOR ANOTHER EXPERIENCED ACCESS
DEVELOPER - CONTACT ME IF INTERESTED.
http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------
------------------------------
Date: Thu, 08 Jul 1999 22:14:12 -0400
From: Bob Walton <walton@frontiernet.net>
To: Jamal Mekkati <jammekk@cam.org>
Subject: Re: Perl and Microsoft access database
Message-Id: <37855AF4.F5041D06@frontiernet.net>
Jamal Mekkati wrote:
> Hi ,
>
> Do you know the procedure on how to access Microsoft Access database
> from perl ? or any link I can refer to ? or a perl sample code ?
...
Jamal, One way is:
use Win32::ODBC;
Here is a sample program that illustrates how:
# ODBC test program
# Seting up an ODBC database
#a) Click Settings/ControlPanel
#b) Click 32-Bit ODBC
#c) Select "System DSN" tab
#d) Click Add, select "Microsoft Access Driver", click Finish
#e) Enter the following properties
# Data Source Name: test_dsn (This is the most important field)
# Description: Anything
#f) Click on Create... and choose a filename, eg. c:\database\test.mdb
#g) Next time Click on Select ... and choose a filename, eg.
c:\database\test.mdb
use Win32::ODBC;
&insertData;
&getData;
exit(0);
sub insertData {
$dsn = "test_dsn";
$db = new Win32::ODBC($dsn);
die "ERROR: Failed to open database\n" if(!$db);
$sql = "CREATE TABLE test_table (";
$sql .= "id char(02), ";
$sql .= "name char(04), ";
$sql .= "city char(03) )";
$db->Sql($sql);
($ErrNum, $ErrText, $ErrConn) = $db->Error();
$sql = "DELETE FROM test_table";
$db->Sql($sql);
$sql = "INSERT INTO test_table (id, name, city) VALUES ('01', 'Jack',
'NY')";
$db->Sql($sql);
$sql = "INSERT INTO test_table (id, name, city) VALUES ('02', 'John',
'Lon')";
$db->Sql($sql);
$sql = "INSERT INTO test_table (id, name, city) VALUES ('03', 'Mike',
'HK')";
$db->Sql($sql);
$sql = "INSERT INTO test_table (id, name, city) VALUES ('04', 'Carl',
'LA')";
$db->Sql($sql);
}
sub getData {
$sql = "SELECT * from test_table order by id";
$db->Sql($sql);
while ($db->FetchRow()) {
($id, $name, $city) = $db->Data("id", "name", "city");
print $id, " - ", $name, " - ", $city, "\n";
}
$db->Close();
}
You can check out this web site: http://www.roth.net/perl/odbc/
------------------------------
Date: Thu, 8 Jul 1999 19:19:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Picture doesn't appear
Message-Id: <MPG.11eefbfd7fbaf8e989c7a@nntp.hpl.hp.com>
In article <1du8ha4.bqpyae1u629drN@p0.tc8.metro.ma.tiac.com> on Wed, 30
Jun 1999 23:08:11 -0400, Ronald J Kimball <rjk@linguist.dartmouth.edu>
says...
...
> #!/usr/local/bin/perl
>
> print "Content-type: image/gif\n\n";
>
> open(GIF, 'picture.gif') or die "Unable to open picture.gif: $!\n";
> # (error will show up in the server's log)
>
> binmode(GIF); # in case you're on a Win32 server
binmode(STDOUT); # in case you're on a Win32 server
> undef $/; # read all in one go
>
> print <GIF>; # print the gif data
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 9 Jul 1999 02:19:21 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: single instance log file
Message-Id: <7m3m79$6ut$1@lublin.zrz.tu-berlin.de>
<sskinner@cloud9.net> wrote in comp.lang.perl.misc:
>Hi!
>
>I'm writing a simple script that writes $ENV{'HTTP_USER_AGENT'} into a
>text file. The thing is, I only want to write a unique instance of each
>browser. I can't seem to figure out the boolean expression (???) that will
>check all the elements of an array ($items) for an occurance (or rather
>non-occurance) of $ENV{'HTTP_USER_AGENT'}. I tried using grep and index
>and a few other functions. Is there a way I can do this without having to
>loop through every line? Here's the script...
>
>#!/usr/local/bin/perl
Where's the -w?
>open (FILEHANDLE, "+>> $myPath"); # read/append mode
Where's the check for success?
>flock (FILEHANDLE, 2); # one thread at a time!
Where's the check for success?
>seek (FILEHANDLE, 0, 0); # start from the beginning
Why open for append and then seek to the beginning?
>@items = <FILEHANDLE>; # read the entire file;
>if (not ??? ) { # does the file contain an occurance of this
See perldoc -q contains
>HTTP_USER_AGENT?
> print FILEHANDLE "$ENV{'HTTP_USER_AGENT'}\n"; # no? then write
>this new occurance
>}
>close FILEHANDLE; # tidy up
Anno
------------------------------
Date: 9 Jul 1999 11:51:03 -0800
From: "Greg Savage" <greg@hendigital.com.au>
Subject: Sorting Hashes of Arrays
Message-Id: <01bec9bd$da310480$f34f39cb@stingray>
I have written the following block of code to read in the login name, group
ID and Real name from the
/etc/passwd file. I am using a Hash of the array so I can return all three
fields with a single key.
I then use a foreach outside of the main while loop to soft on the key.
This works fine for keys based on login name or real name but I am unable
to get a numeric sort on
the group field.
Suggestions welcomed.
John.
setpwent();
while (@list = getpwent())
{
($login,$group,$name) = @list[0,3,5];
$HoL{$group} = [ @list[0,3,5] ];
if ($group >= 500)
{
# Do stuff
}
endpwent();
foreach $group (sort keys %HoL)
{
print "@{ $HoL{$group} }\n";
}
------------------------------
Date: Thu, 8 Jul 1999 22:45:39 -0400
From: "Michael Mongeau" <mmongeau@yahoo.com>
Subject: Re: Which is better, Perl, Cold Fusion or...
Message-Id: <bndh3.3419$kL2.268270@ndnws01.ne.mediaone.net>
How long ago was did you evaluate CF ? I've been using V3 for nearly a year
and just upgraded to V4 on both Solaris and NT and I think Cold Fusion is
great for database applications. V4 has query caching, so a database result
set can be cached for a period of time to prevent unnecessary calls to the
database. For rapid development of web database applications I would highly
recommend it. V4 also supports XML - you can convert a database query
result set into an XML packet to pass to another application. I've also
found the administration interface very easy to use - it's all
browser-based.
That's not to say I don't still use Perl a lot. The combination of Perl and
FastCGI is very fast and great for certain tasks. I believe in using
whatever tools is best for the job.
Mike Mongeau
Jim Hutchison wrote in message <3784dc91.242254293@news1.cal.metronet.ca>...
>IMHO, don't use Cold Fusion. We went through a couple revs both on NT
>as well as Solaris, and they were memory pigs, unstable, etc etc etc.
>An administrative hassle.
>
>
>
>On Thu, 8 Jul 1999 10:35:08 -0400, Andrew Singer
><als48@pantheon.yale.edu> wrote:
>
>>Hey, I'm a Yalie interning for Trade Show News Network (www.tsnn.com). We
>>have to decide which language to program in to connect our database to the
>>web and make dynamic web pages, etc. Would you recommend, Perl, Cold
>>Fusion, or some other language, like Zope or PHP? We are not looking for
>>the cheapest or easiest to use language; we want the most powerful and
>>reliable. Thanks a lot for your help!
>>
>>-Andy
>>
>>___________________________________________
>>Andrew Singer
>>300 W 108 St, Apt 1A
>>NY, NY 10025
>>(212)864-3515
>>
>>
>
------------------------------
Date: Fri, 09 Jul 1999 02:12:17 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Yikes, confusion for my newbie self
Message-Id: <37855A46.F7304E52@home.com>
[posted & mailed]
Cayce Collins wrote:
>
> Here's the code:
[snip code that won't compile]
Please post your real code only. Cut and paste; don't retype.
If the width of your code lines is too long to fit in a posted message
without wrapping then it is too long to maintain. Look into the /x
modifier in perlre. It will allow you to write cleaner code like
if(
/^
($input_for{'username'})
(\s*)
First:(\w*)
(\s*)
Last:(\w*)
(\s*)
Time:(\S*)
(\s*)
Date:(\S*)
(\s*)
Problem:(\S*)
$/x
) {
> Here's the line from the txt file:
>
> jdoe First:John Last:Doe Time:8:51am Date:07/08/99 Problem:User Had to
> Re-install.
>
> How do I get the "Problem: ..." to display, it will only show up as "User"
> on the web page, how do I get the whole sentance?
Your code was garbled so I am only guessing that it should have looked
something like the above. If so, then the last \S is why you only get
"User" since that is as much non-whitespace as can be matched after
"Problem:".
To get the rest of the line you can replace the "\S" with ".".
I have already directed you to perlre twice now. Please go and read it
and it will be crystal clear what the difference is. If there is
something there you don't understand then come back and *post* exactly
what it is you don't get and I'm sure someone will be able to explain it
to you.
If you do have to post again, you will get better responses by using a
subject that is related to your question.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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 V9 Issue 85
************************************