[8230] in Perl-Users-Digest
Perl-Users Digest, Issue: 1848 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 10 15:07:58 1998
Date: Tue, 10 Feb 98 12:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 10 Feb 1998 Volume: 8 Number: 1848
Today's topics:
Re: "Mastering Regular Expressions" bwb@acm.org
Re: "Mastering Regular Expressions" <fnord@panix.com>
Assigning to Multidimentional arrays <Richard@rburrows.demon.co.uk>
Re: Can't locate object method "TIEHASH" <zenin@best.com>
Re: Can't locate object method "TIEHASH" <tchrist@mox.perl.com>
Re: debugging perl script (Mikael Skogstrom)
Re: defined() bug? (or feature? :) <mthurn@irnet.rest.tasc.com>
Re: defined() bug? (or feature? :) <jdporter@min.net>
Re: defined() bug? (or feature? :) <zenin@best.com>
Embending perl into c <agr30@uni-koeln.de>
Re: Fork/Threads (Bruce M Krawetz)
Re: getting perl system calls to run in different shell <vallon@pearl.fi.bear.com>
Re: Happy with Perl? (I R A Aggie)
How generate counter? (Jun Zhuang)
Re: More regular expressions <jsd@hudsucker.gamespot.com>
Re: Perl - Oracle Interface (John D Groenveld)
Re: perl/oracle7/oracle8/modules (John D Groenveld)
Re: returning the date <rmelson@pswtech.com>
Seriously Off Topic, but a Common Complaint/Problem in <camerond@mail.uca.edu>
Re: Sharing variables between scripts (Jack Ostroff)
Some Win32::ODBC sample code (list a table's fields & t (Steve Linberg)
SYSTEM command - How do you return data to the browser? <rickryan@datrixnet.com>
Re: test!! please ignore this message i am seeing if it <jdporter@min.net>
Re: test!! please ignore this message i am seeing if it (Gabor)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 10 Feb 1998 12:41:13 -0600
From: bwb@acm.org
Subject: Re: "Mastering Regular Expressions"
Message-Id: <887135909.929103873@dejanews.com>
In article <34de9a1f.28410048@news.xmission.com>,
doswald@xmission.com wrote:
>
> In my continual quest to maximize my skills so that I may more fully
> exercise laziness I'm interested in another book that will help me to
> improve my effectiveness toward those goals. I've been interested in
> ordering either "Mastering Regular Expressions" (O'Reilly & Assoc) or
> "Advanced Perl Programming" (O'Reilly & Assoc). There are no
> bookstores in my area that have either of these books, so I can't
> really look them over before buying. Thus I turn here for a
> recommendation.
The Perl section at Flat Hill Books has reviews of these two books:
http://www.flathill.com/languages/perl/
-bwb
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 10 Feb 1998 14:47:54 -0500
From: "Cliff Heller" <fnord@panix.com>
Subject: Re: "Mastering Regular Expressions"
Message-Id: <uphg6744yf.fsf@panix3.panix.com>
doswald@xmission.com (David Oswald) writes:
>
> 'Advanced' sounds very interesting to me, but I read another post here
> mentioning that it is rather error-ridden. I'd be surprised if this
> is true, coming from a publisher like O'Reilly, but I would rather not
> buy it and find out that it is indeed troublsome. Would this
> respected Usenet community recommend 'Advanced'?
There are a bunch of typos in the code.
Personally, I felt personally validated that I was able to see the errors
even during discussions of things I was pretty unfamiliar with.
The explanations of the underlying concepts are very very good. The code
still illustrates what he's talking about even with the occasional mistake.
------------------------------
Date: Tue, 10 Feb 1998 19:05:11 +0000
From: Richard Burrows <Richard@rburrows.demon.co.uk>
Subject: Assigning to Multidimentional arrays
Message-Id: <8lb4ZDAnTK40EwtM@rburrows.demon.co.uk>
I have the following bit of code to assign $record and $date to two
columns of a multidimentional array, it used to work fine to sort the
records into reverse date order but I now get an error, the interpreter
does not like the [$PS][0].
Can anyone tell me where I am going wrong.
foreach $date (reverse (sort values %dateorder))
{
foreach $record (keys %dateorder)
{
if ($date eq $dateorder{$record})
{
$filedetails[$PS][0]=$record;
$filedetails[$PS][1]=$date;
$PS++;
}
}
}
--
Richard Burrows
------------------------------
Date: 10 Feb 1998 19:27:49 GMT
From: Zenin <zenin@best.com>
Subject: Re: Can't locate object method "TIEHASH"
Message-Id: <887139138.831609@thrush.omix.com>
Ned Schumann <ned@olympus.net> wrote:
: (tie %_db, "DB_File", "/h/services/data/usageSummary", O_RDONLY, 0660, $DB_HASH)
: I get this error...
: Can't locate object method "TIEHASH" via package "DB_File" at
: /h/services/modules/userTime.pm line 98, <STDIN> chunk 14.
use DB_File;
tie %_db, "DB_File", "/h/services/data/usageSummary", O_RDONLY, 0660, $DB_HASH
or die "dbfile error: $!";
--
-Zenin
zenin@best.com
------------------------------
Date: 10 Feb 1998 19:46:38 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Can't locate object method "TIEHASH"
Message-Id: <6bqaqu$fh8$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
:use DB_File;
:tie %_db, "DB_File", "/h/services/data/usageSummary", O_RDONLY, 0660, $DB_HASH
: or die "dbfile error: $!";
Why are you supplying a creation mask when it's a read-only open?
And don't you think 0666 a better mask, thus leaving these matters
up to the user's umask?
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Remember though that
THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR.
--Larry Wall in the perl man page
------------------------------
Date: Tue, 10 Feb 1998 19:45:12 +0100
From: mikael@techtalk.se (Mikael Skogstrom)
Subject: Re: debugging perl script
Message-Id: <B1065EC896683A53D@du82-1.ppp.algonet.se>
In article <6bp8fi$1mkq@ludwig.HSRC.ac.za>,
"Ian Samson" <IDSamson@Beauty.HSRC.ac.za> wrote:
>"The server
>returned an invalid or unrecognized response". How do I find out which line
>is causing the error?
Usually this happens when there's a syntax error in the script (the server
only gets a bunch of interpretation errors in return). Try:
perl -wc script.pl
to check which line is causing the problem.
Mikael
------------------------------
Date: 10 Feb 1998 13:21:43 -0500
From: Kingpin <mthurn@irnet.rest.tasc.com>
Subject: Re: defined() bug? (or feature? :)
Message-Id: <eu3ehruxqg.fsf@irnet.rest.tasc.com>
Mark Morgan <morganm@qualcomm.com> writes:
>
> I have a module named CONFIG.pm, who's job is to read in a configfile and
> load the entries of that file into global variables. So the line:
>
> FOO = somevalue
Is it unacceptable to add some dollar signs, quotes, and semicolons
to your config file, so you can just require it?
$FOO = 'somevalue';
--
- - Martin "Kingpin" Thurn mthurn@tasc.com
Research Software Engineer (703) 834-5000 x2926
The Information Refinery http://tir.tasc.com
TASC, Inc. http://www.tasc.com
Don't give in to hate; that leads to the dark side. -- Ben, The Empire Strikes Back
------------------------------
Date: Tue, 10 Feb 1998 13:20:44 -0500
From: John Porter <jdporter@min.net>
Subject: Re: defined() bug? (or feature? :)
Message-Id: <34E09A7C.613D@min.net>
Mark Morgan wrote:
>
> The original method of setting up the variable
> consisted of:
>
> ${ $key } = $value;
>
> Cool deal. But now that it's in its own module, I still want to
> set the global variable, so I have to reference the main symbol
> table like so:
>
> $::{ $key } = $value;
>
> Unfortunately, that doesn't work, because it expects a reference, not a
> value, so I'm have to do the following:
>
> $::{ $key } = \eval{ $value };
You are misunderstanding why (and where) it wants a reference.
Are you using perl -w ???
A correct way to access a variable by name in the main namespace
is
${ '::'.$key } = $value;
since $key is the unqualified name, and you want a qualified name.
You asked for advice; mine is to not twaddle the name space of
another package more than absolutely necessary. Use a hash.
$main::config_data{ $key } = $value;
This only twaddles one entry in the main namespace: %config_data.
Even then, you might prefer to create the variable in the current
package, and let the caller access it via a method.
$config_data{ $key } = $value; # in "this" namespace
sub get_config_data {
return \%config_data; # return handle to the hash
}
Once you've gotten used to this idea, they maybe you want to
make a "record" of config info into a real object:
package CONFIG;
sub new {
my $class = shift;
my $self = bless {}, $class;
for (
. . .
$self->{$key} = $val;
}
$self;
}
# so that $obj->attrib() gets $obj->{attrib}
# and $obj->attrib($val) sets $obj->{attrib} = $val;
sub AUTOLOAD {
my $self = shift;
my $val = shift; # possibly not present
my $attrib = $AUTOLOAD;
$attrib =~ s/.*:://; # strip qualification
if ( defined $val && exists $self->{$attrib} ) {
# given an arg, set the attribute to that value
$self->{$attrib} = $val;
}
$self->{$attrib}; # possibly undef
}
hth,
John Porter
------------------------------
Date: 10 Feb 1998 19:37:57 GMT
From: Zenin <zenin@best.com>
Subject: Re: defined() bug? (or feature? :)
Message-Id: <887139746.915709@thrush.omix.com>
Mark Morgan <morganm@qualcomm.com> wrote:
: I have a module named CONFIG.pm
Bad idea already; There is already a Config.pm module in the
standard dist. Something like Getopt::ConfigFile might be
better.
: , who's job is to read in a configfile and
: load the entries of that file into global variables. So the line:
Globals? Why globals? Couldn't it simply return a hash or
similar?
: Cool deal. But now that it's in it's own module, I still want to set the
: global variable, so I have to reference the main symbol table like so:
:
: $::{ $key } = $value;
Ack! Not only are you using globals, you're assuming the package
main:: is calling you??? Ack! So much for reusable code.. :-/
: exit "Error, $var not defined.\n";
You sure you weren't thinking of die() here? I don't think this
statement does what you think it does.
--
-Zenin
zenin@best.com
------------------------------
Date: 10 Feb 1998 16:47:38 +0100
From: Martin Bialasinski <agr30@uni-koeln.de>
Subject: Embending perl into c
Message-Id: <87yazj5un9.fsf@haitech.internet-treff.de>
Hi,
I have found a ISDN voicebox application which when called starts a tcl
script. Well, tcl and me, we are no friends somehow, so I want to use Perl
instead. (Minor Problem: I can't do c as well :-)
The programm (vbox.c) does:
a) create a tcl interpreter
b) make a connection between some variables defined in vbox.c and the tcl
interpreter
c) make a connection between some functions defined in vbox.c and the tcl
interpreter
d) calls a script in the generated interpreter
So the script can use and alter some variables in vbox.c and it can call
some functions defined in vbox.c
Thanks to Advanced Perl Programming, creating a perl interpreter and
calling a script in it looks easy.
But I have no clue how to do b) and c).
The explanations in perlxs, perlxstut, perlguts and the panther book seem
only to deal with creating a glue between a C library and a perl script,
not with the problem I have.
Could someone give me a short example how to accomplish this?
Ciao,
Martin
------------------------------
Date: 10 Feb 1998 18:01:21 GMT
From: bmk@wdl.lmco.com (Bruce M Krawetz)
Subject: Re: Fork/Threads
Message-Id: <6bq4lh$73p@wdl1.wdl.lmco.com>
In article <Eo56A3.M7M@world.std.com>, aml@world.std.com (Andrew M. Langmead) writes:
|> patrick@cre8tivegroup.com writes:
|>
[.....]
|>
|> I don't quite know what is wrong, (since there is no code to check.)
|> but here are some ideas.
|>
|> 1. Do you print the "intro" before forking the children?
Was the "intro" flushed before the fork?
[.....]
--
------------------------------------------- bmk@wdl.lmco.com
We must learn from our mistakes, so we can make bigger and better ones.
------------------------------
Date: 10 Feb 1998 14:35:11 -0500
From: Justin Vallon <vallon@pearl.fi.bear.com>
Subject: Re: getting perl system calls to run in different shells
Message-Id: <x6eoh0fmexc.fsf@pearl.fi.bear.com>
I missed the original msg.
Carey Pembroke <carey@tippett.com> writes:
> Sharyl_griffith@ftw.paging.mot.com wrote:
>
> > I'm trying to get my perl scripts with system calls to run regardless of
> > which shell a user is running. Is there an easy way to do this?
> >
> > -------------------==== Posted via Deja News ====-----------------------
> > http://www.dejanews.com/ Search, Read, Post to Usenet
C's system() always uses sh. Also, exec (which is what system uses) says
that it uses '/bin/sh -c' to run a shell command. Otherwise, it execs it.
Are you seeing something different?
--
-Justin
vallon@bear.com
------------------------------
Date: Tue, 10 Feb 1998 14:04:51 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Happy with Perl?
Message-Id: <fl_aggie-1002981404510001@aggie.coaps.fsu.edu>
In article <01bd3613$2e469ca0$ea3670c2@lwnvf>, "nwi-tech"
<nwi-tech@dircon.net> wrote:
+ > > >is perl stable? would it be a good idea to risk millions of pounds on
+ > > >something that is unsupported? what do you think?
+ > > >
+ > >
+ > > Unsupported ? UNSUPPORTED ??? What the @##@!% do you think the
+ people in
+ > > this newsgroup are doing ? Sheesh, the nerve of some people... :-)
+
+ if i wrote a program in perl which backed up $100 million worth of dealing
+ information, and that program failed because of a bug in the perl source,
+ my company would not be able to sue anyone,
Right. Like they can sue Microsquid. You _have_ read their license
agreements, yes? you know the part where they decline liability for
any damages done because of errors in their programs??
At least with perl, you HAVE THE SOURCE AND YOU CAN FIX IT YOURSELF
instead of HAVING TO WAIT FOR MICROSQUID TO a) acknowledge a problem
exists, b) that its their problem, c) to work on the problem, and d)
deliver a solution to you.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: 10 Feb 1998 18:07:45 GMT
From: jzhuang@ringer.cs.utsa.edu (Jun Zhuang)
Subject: How generate counter?
Message-Id: <6bq51h$4s3@ringer.cs.utsa.edu>
I try to generate a counter by calling: counter.cgi
<br>You are the <img src="/cgi-bin/counter.cgi" height=24 width=130> visitor since Jan, 1st, 1998<br>
>From my web page.
I want to "counter.cgi" write out a .gif file
Is there any perl module or sample cod eto do this ?
thanks.
------------------------------
Date: 10 Feb 1998 19:26:26 GMT
From: Jon Drukman <jsd@hudsucker.gamespot.com>
Subject: Re: More regular expressions
Message-Id: <6bq9l2$g54$1@its.hooked.net>
Mikael Skogstrom <mikael@techtalk.se> wrote:
: This should do it:
: s/(^:)=/$1 = /
you need square brackets...
s/([^:])=/$1 = /
: Explaination: If the character preceding the = sign _is not_ a colon, then
: do the substitution by first putting the preceding character in the memory,
: then recall it on the substitution side, also adding a space on each side
: of the = sign.
now your explanation matches the regexp.
-j-
------------------------------
Date: 10 Feb 1998 13:24:40 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: Perl - Oracle Interface
Message-Id: <6bq618$euq$1@tholian.cse.psu.edu>
In article <mward-ya023580000702980945450001@news.slip.net>,
Michael Ward <mward@veelos.com> wrote:
>Oraperl/DBI is the better way to go, but they require that PRO-C libraries
>be available on your host. If PRO-C is not available and sqlplus is, this
>will work (don't expect great performance):
OCI and the SQLNet client are sufficient. I believe these have been made to
work under Linux and IBCS.
BTW: comp.lang.perl is dead,dead,dead.
John
groenveld@acm.org
------------------------------
Date: 10 Feb 1998 13:33:47 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: perl/oracle7/oracle8/modules
Message-Id: <6bq6ib$evk$1@tholian.cse.psu.edu>
In article <34DED804.EA07CDBD@renault.com>,
Laurent Deperthes <Laurent.Deperthes@renault.com> wrote:
>hello , is there a way to access oracle databases
>directly in perl with a module or not like :
Yes.
http://www.perl.org/CPAN/modules/00modlist.long.html#7)DatabaseInter
John
groenvel@cse.psu.edu
------------------------------
Date: Tue, 10 Feb 1998 12:10:56 -0600
From: Robert Melson <rmelson@pswtech.com>
Subject: Re: returning the date
Message-Id: <34E09830.1BCE@pswtech.com>
Tom Christiansen wrote:
>
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, jdporter@min.net writes:
> :Then there's the U.S. military's Date Time Group (DTG) format:
> : YYYYMMDDHHMMSS.HH
> :all parts optional, from the outside in (to seconds) (as I recall).
>
> What's the trailing HH after the dot?
Presumably hundredths.
>
> --tom
> --
> Tom Christiansen tchrist@jhereg.perl.com
> "I'll put an end to the idea that a woman's body belongs to her . . . the
> practice of abortion shall be exterminated with a strong hand."
> --Adolf Hitler, _Mein Kampf_
--
_____________________________________________________________________
Bob Melson Hell hath no fury like a woman suborned.
PSWTechnologies, Inc -- Anonymous --
Austin, TX
512-342-3511 rmelson@pswtech.com bmelson@swbell.net
------------------------------
Date: Tue, 10 Feb 1998 13:45:09 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Seriously Off Topic, but a Common Complaint/Problem in this NG
Message-Id: <34E0AE45.B4094E9D@mail.uca.edu>
My apologies for an off-topic message, but the answer might help relieve
tension around here.
Oft we read this complaint (or variations thereof):
"Fix your word wrapping, or I _will_ killfile you."
This often comes directed toward a response to a question/comment, when
the responder is using NS Communicator or MS IExplorer. Yes, the
wordwrapping from these programs is often really ugly, and can seriously
get in the way of the message.
I use NS for convenience, I know it's not perfect, and the only way I
know of to fix the wordwrap in a response is to do it manually, since I
have set the max length at 72 chars, and often that leaves a word for
the next line. (no, this is not just a whine session, please read on)
So, I ask you, fellow readers/responders, what to do? Is there a good
newsreader out there that would be infinitely preferable to NS,
hopefully freeware (OK, I'm cheap, but I do stuff for free, too)?
[Please don't suggest WinVN for Windows, the last time I used it, after
upgrading my version to the newest, it seemed seriously broken.]
Is there a feature of NS that I'm missing (surely some of you use NS,
maybe even some of the real programmers)?
Is there a way that I can incorporate a perl script into the program,
now that the source is out there, so I can fix it, w/o being a master
programmer? I'm still new at this whole thing, so I would rather not
attack the problem of writing my own newsreader.
Any advice is appreciated by me, and, I'm sure, many others here.
NOTE: I did NOT ask about the HTML/multipart MIME stuff, that was real
easy to fix once I knew what was being broadcasted.
Cameron Dorey
camerond@mail.uca.edu
------------------------------
Date: 10 Feb 1998 18:56:03 GMT
From: jack_h_ostroff@groton.pfizer.com (Jack Ostroff)
To: tchrist@mox.perl.com (Tom Christiansen)
Subject: Re: Sharing variables between scripts
Message-Id: <6bq7s3$8uu3@mascagni.pfizer.com>
[courtesy cc of this posting sent to cited author via email]
I think part of the confusion here is that the original request was
not really clear. If the variable assignments were to be needed in
several places - was this assure that they were set an any of several
places in a multi-file program or so that they were the same when
used in several different scripts/programs? Am I correct in assuming
that these should (or at least might) probably be handled differently?
I asked if "require" would work. Tom said
> require doesn't import.
I think part of my (and others?) confusion is from some terminology
issues. What exactly does the above statement mean? It's not as
obvious as it ought to be to those of us not particularly proficient
with modules yet. The docs say that require does an include (same
as eval). What's the difference? I've played around some more, and
I think Toms separate reply to this thread has the key to what has
been misleading me here. Require would, indeed, do pretty much what
I expected, except for the namespace control. Rereading the docs on
"my" clued me in. If the "my" is in the library file (more on this
below) with the variables, they aren't known in the script.
Tom's other post also refers to the confusion between scripts and
libraries. I think the problem is that there isn't any inherent
difference. There isn't any code which can't be used in one or the
other. The difference is in how they SHOULD be used - and there are
lots of things which shouldn't be done in one or the other. (Yes,
I'm clearly getting in over my head here - but I haven't found
any single piece of documentation which lays this all out clearly.)
> And before you go trying to write a function,
Where did that come from? I don't think I said anything about
writing functions.
> find at least three bugs
> in the following, and fully explain them.
>
> getmod("Foo::Bar");
> sub getmod {
> require $_[0];
> import $_[0];
> }
> func 3; # really Foo::Bar::func()
>
Tom, I promise I'll do my homework before I go out and play.
Jack
jack_h_ostroff@groton.pfizer.com
------------------------------
Date: Tue, 10 Feb 1998 14:31:47 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Some Win32::ODBC sample code (list a table's fields & their types)
Message-Id: <linberg-1002981431470001@projdirc.literacy.upenn.edu>
(Posted to comp.lang.perl.modules and comp.lang.perl.misc; doesn't
strictly belong in c.l.p.misc, but people who are lost often post here,
and perhaps this will answer someone's question.)
Folks,
While looking for info about how to use the Win32::ODBC ColAttributes()
function to get properties of fields in a given table, my deja news search
showed a lot of people asking the same question, but nobody posted any
answers. However, by studying the questions and (gasp!) reading ODBC.pm,
I came up with some code I feel satisified with. So, for anybody "live"
or searching deja news for how to do this, here's some sample code.
This is a single function called from a CGI that lists available DSNs.
Each DSN is listed on a constructed web page with its name and type, a box
for login and password, and an "open" button that calls a module which
calls this function at its core. It generates an HTML page (string,
really) that lists the table's fields, and some of its SQL properties.
There are more properties than I chose to display here; this is just a
sample.
This particular function may be called like this:
$err = &buildOutput ($pathToHTMLTemplate, \$returnText, \%inputHash);
where
$err is a predefined error code; 1 means no error, 0 means error occurred
& stored.
$pathToHTMLTemplate is the pathname of an HTML template to insert the
constructed HTML into before returning it. Define $kTxtDataAnchor as the
text to look for and replace in the HTML file - error checking is not
particularly robust here. I use "<!-- Data -->" in the position where I
want the information inserted.
$returnText is a reference to a storage string to return the page in.
%inputHash is the hash of input from the form. The following parameters
are passed:
dsn (hidden on form): the name of the dsn to open.
table (hidden on form): the name of the table to open.
login: the login string for the dsn. May be left blank.
pass: the password for the dsn. May be left blank.
Although this code is web-specific, you can of course extract pieces for
use elsewhere. It just shows one way to get at the field data. It
references an ErrorHandler module, which is something I wrote, but you can
ignore it - just a way to present errors to web users fairly politely.
If this helps anybody, great! And if anybody finds anything broken,
backwards, inefficient or stylistically egregious, I'd be happy to hear
about it.
Steve Linberg
NCAL Tech Monkey
######################################################################
# Sub: buildOutput
# Input: (1) HTML page template
# (2) Reference to text var to store generated text
# (3) Reference to handle of input parameters
# Output: boolean error state
# Uses: $kTxtDataAnchor: string in template to replace with constructed HTML
# Sets: nothing
#
# Build the page with the list of tables from the specified DSN, assuming
# we get in OK. If not, be nice and descriptive.
######################################################################
sub buildOutput {
my ($pTxtFNTemp, $prTxtOutput, $prHshInput) = @_;
if (!defined (open (HTML, $pTxtFNTemp))) {
&ErrorHandler::setError($ErrorHandler::kErrFatal, $kTxtErrCantOpen,
"Error: the HTML file $pTxtFNTemp could not be opened (Perl error
code: $!).");
return $ErrorHandler::kBlnError;
}
my (@lArrTxtTemp) = <HTML>;
close (HTML);
my ($lTxtTemp) = join ("", @lArrTxtTemp);
my ($lTxtHTML) = "";
if (!exists($prHshInput->{"dsn"})) {
$lTxtHTML = "<h2>Error: no DSN specified</h2>\n" .
"<p>You must specify a DSN to open.</p>\n";
goto my_exit;
}
if (!exists($prHshInput->{"table"})) {
$lTxtHTML = "<h2>Error: no table specified</h2>\n" .
"<p>You must specify a table to open.</p>\n";
goto my_exit;
}
undef $lDSN;
my ($lDSN) = new
Win32::ODBC("DSN=$prHshInput->{'dsn'};UID=$prHshInput->{'login'};" .
"PWD=$prHshInput->{'pass'}");
if (!defined($lDSN)) {
$lTxtHTML = "<h2>Error: Can't open DSN</h2>\n" .
"<p>The ODBC driver couldn't open the dsn \"$prHshInput->{'dsn'}\"." .
" The OBDC error description is: </p>\n<p><b>" .
Win32::ODBC::Error() . "</b></p>\n";
goto my_exit;
}
if ($lDSN->Sql("SELECT * FROM $prHshInput->{'table'}")) {
$lTxtHTML = "<h2>Error: SQL SELECT failed</h2>\n" .
"<p>The SQL statement to open the table
\"$prHshInput->{'table'}\" failed." .
" The OBDC error description is: </p>\n<p><b>" .
Win32::ODBC::Error() . "</b></p>\n";
goto my_exit;
}
$lTxtHTML = "<h2>Table \"$prHshInput->{'table'}\" from datasource
\"$prHshInput->{'dsn'}\"</h2>\n";
my (@lArrFieldNames) = $lDSN->FieldNames();
$lTxtHTML .= "<table width=100%>\n" .
"<tr>\n" .
"<td width=25%><b>Field</b></td>" .
"<td width=15%><b>Type</b></td>" .
"<td width=20%><b>Length</b></td>" .
"<td width=20%><b>Auto-Inc?</b></td>" .
"<td width=20%><b>Updatable?</b></td>" .
"</tr>\n";
my ($lTxtFieldName) = "";
foreach $lTxtFieldName (@lArrFieldNames) {
$lTxtHTML .= "<tr>\n";
my (%lHshAttrs) = ();
%lHshAttrs = $lDSN->ColAttributes(SQL_COLUMN_NAME, $lTxtFieldName);
$lTxtHTML .= "<td>$lHshAttrs{$lTxtFieldName}</td>\n";
%lHshAttrs = $lDSN->ColAttributes(SQL_COLUMN_TYPE_NAME, $lTxtFieldName);
my ($lTxtFieldType) = $lHshAttrs{$lTxtFieldName};
$lTxtHTML .= "<td>$lHshAttrs{$lTxtFieldName}</td>\n";
%lHshAttrs = $lDSN->ColAttributes(SQL_COLUMN_LENGTH, $lTxtFieldName);
if ($lTxtFieldType =~ /TEXT/) {
$lTxtHTML .= "<td>$lHshAttrs{$lTxtFieldName}</td>\n";
} else {
$lTxtHTML .= "<td></td>\n";
}
%lHshAttrs = $lDSN->ColAttributes(SQL_COLUMN_AUTO_INCREMENT,
$lTxtFieldName);
my ($lIntAutoInc) = $lHshAttrs{$lTxtFieldName};
my (@lArrTxtValues) = ("No", "Yes");
$lTxtHTML .= "<td>$lArrTxtValues[$lIntAutoInc]</td>\n";
%lHshAttrs = $lDSN->ColAttributes(SQL_COLUMN_UPDATABLE, $lTxtFieldName);
my ($lIntUpdatable) = $lHshAttrs{$lTxtFieldName};
@lArrTxtValues = ("No", "Yes", "?");
$lTxtHTML .= "<td>$lArrTxtValues[$lIntUpdatable]</td>\n";
$lTxtHTML .= "</tr>\n";
}
$lTxtHTML .= "</table>\n\n";
$lDSN->Close();
my_exit:
my ($start) = index($lTxtTemp, $kTxtDataAnchor);
my ($end) = $start + length($kTxtDataAnchor);
substr($lTxtTemp, $start, $end-$start) = $lTxtHTML;
$$prTxtOutput = $lTxtTemp;
return $ErrorHandler::kBlnNoError;
}
--
Steve Linberg | National Center on Adult Literacy
Systems Programmer etc. | University of Pennsylvania
linberg@literacy.upenn.edu | http://www.literacyonline.org
------------------------------
Date: Tue, 10 Feb 1998 12:12:36 -0600
From: "Rick Ryan" <rickryan@datrixnet.com>
Subject: SYSTEM command - How do you return data to the browser?
Message-Id: <6bq4gp$iqn@camel19.mindspring.com>
I'm using the SYSTEM command to run an external .exe file on my NT server.
Is there any way to have the output of the called program return directly to
the browser or back to my perl script? I've tried it several different ways
and the only thing I can get to work is to write the information back to a
file, then use the perl script to open and read the contents of that file.
Any help is appreciated.
--
Rick Ryan Web page : www.datrixnet.com
Datrix Voice : 615-822-7829
P.O. Box 2975 FAX : 615-824-0943
Hendersonville, TN 37077 E-mail : rickryan@datrixnet.com
------------------------------
Date: Tue, 10 Feb 1998 13:27:13 -0500
From: John Porter <jdporter@min.net>
Subject: Re: test!! please ignore this message i am seeing if it works!
Message-Id: <34E09C01.58DB@min.net>
Brandon Blum wrote:
>
> never done a newsgroup before, trying to learn perl and i want
> to post,
> hopefully this works, just ignore it!
Certainly never read a FAQ.
Never heard of netiquette.
First thing he does is spam our newsgroup!
John Porter
------------------------------
Date: 10 Feb 1998 19:25:29 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: test!! please ignore this message i am seeing if it works!
Message-Id: <slrn6e1a7m.1dp.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Brandon Blum <bblum@earthlink.net> wrote :
# never done a newsgroup before, trying to learn perl and i want to post,
# hopefully this works, just ignore it!
# Brandon
#
Did you know there was a news.test group? Posting stuff like this is
bound to put you into the killfile of exactly the people whose help
you might later seek! :-)
gabor.
--
We all agree on the necessity of compromise. We just can't agree
on when it's necessary to compromise.
-- Larry Wall in <1991Nov13.194420.28091@netlabs.com>
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 1848
**************************************