[19753] in Perl-Users-Digest
Perl-Users Digest, Issue: 1948 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 17 18:05:50 2001
Date: Wed, 17 Oct 2001 15:05:14 -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: <1003356314-v10-i1948@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 17 Oct 2001 Volume: 10 Number: 1948
Today's topics:
Creating a hash from a sub that parses XML <jemptyg@rwmc.net>
DBI::ProxyServer error on WindowsNT (Keith Clay)
Re: Entering Name-Value pairs - Still Confused <wsegrave@mindspring.com>
Re: Entering Name-Value pairs - Still Confused <jimbo@soundimages.co.uk>
Re: Entering Name-Value pairs - Still Confused <mjcarman@home.com>
Re: Glob limitations. <ilya@martynov.org>
Re: Glob limitations. nobull@mail.com
How can I send an html formatted email, preferably usin <jonf@rgb.com>
Re: how to find memory leaks in perl 5.004_04 (Jim Anderson)
Re: how to find memory leaks in perl 5.004_04 <jimbo@soundimages.co.uk>
how to get the user logon name with getlogin(). <webbat@btinternet.com>
how to kill the child process ? <gfu@gscmail.gsfc.nasa.gov>
Re: How to Ping to an IP (Martien Verbruggen)
Re: Lightweight Languages Workshop, Cambridge MA 11/17/ <kumo@bellsouth.net>
lwp-request and load-balancing (MeNe)
Re: Manipulating Strings Within A Text File (Garry Williams)
Matching & Merging two text files <lmoran@wtsg.com>
Re: Matching & Merging two text files <jimbo@soundimages.co.uk>
Re: Matching & Merging two text files <jeff@vpservices.com>
Re: Matching & Merging two text files (Chris Fedde)
Need help to find a regexp <mschur@web.de>
Re: Objects: Setting defaults and calling themselves?? nobull@mail.com
Re: Oracle PL/SQL from Perl? <ekulis@apple.com>
Re: Oracle PL/SQL from Perl? (John J. Trammell)
Re: pcl printer codes (Garry Williams)
Re: pcl printer codes <mwinter@nrel.nrel.gov>
Re: pcl printer codes (Garry Williams)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 17 Oct 2001 18:40:20 GMT
From: "George Jempty" <jemptyg@rwmc.net>
Subject: Creating a hash from a sub that parses XML
Message-Id: <1003343700.601828@airwave-sb.scottsbluff.net>
I'm looking for advice as to creating a hash from a sub that parses XML.
Here is my working subroutine:
sub getHashFromXml
{
my $keyTag = shift;
my $valueTag = shift;
my $xmlFile = shift;
my $keyMatch = "";
my $valueMatch = "";
my $isKey = 0;
my $isValue = 0;
my $gotPair = 0;
my %hashFromXml;
use XML::Parser;
my $parser = new XML::Parser
(
Handlers =>
{
Char => \&char_handler,
End => \&end_handler,
Start => \&start_handler
}
);
$parser->parsefile($xmlFile);
return %hashFromXml;
sub char_handler
{
$keyMatch = $_[1] if ($isKey);
$valueMatch = $_[1] if ($isValue);
$gotPair++ if ($keyMatch && $valueMatch);
$hashFromXml{$keyMatch} = $valueMatch if ($gotPair);
}
sub end_handler
{
$isKey-- if ($isKey);
$isValue-- if ($isValue);
if ($gotPair)
{
$keyMatch = "";
$valueMatch = "";
$gotPair--;
}
}
sub start_handler
{
$isKey++ if ($_[1] eq $keyTag);
$isValue++ if ($_[1] eq $valueTag);
}
}
I know it's not perfect, especially from the standpoint of "Perl idiom", but
it was quick, especially considering I'm just getting back into Perl in a
serious way after over a year off. I tested the output by printing the hash
first, instead of returning it as above.
So I know it "works", but from searching the archives of this newsgroup I
get the definite impression there might be a more efficient way to do this?!
For instance I read that the hash will remain in memory after it is returned
(maybe I misunderstood). Plus I understand that it will get returned as a
list, so maybe I should just send it back that way to begin with?!
Any and all help will be appreciated. It would be ideal if someone could
point out where to modify what the sub returns, and then how to call the sub
so as to create the desired hash. Hope this isn't asking too much, that's
why I provided my working code, perhaps it can help somebody else.
Also welcome would be hints as to how to improve my "Perl idiom" within the
subroutine.
Thanks in advance. It's hard being the only developer, and my brain is
fried right now....
George
------------------------------
Date: 17 Oct 2001 14:13:43 -0700
From: clayk@acu.edu (Keith Clay)
Subject: DBI::ProxyServer error on WindowsNT
Message-Id: <8947fc5.0110171313.117d6684@posting.google.com>
Folks,
When we configure dbiproxy with 'mode'=>'thread', we get the following
error. We just installed activestate perl 5.6 on the machine along
with the appropriate DBI/DBD modules. It works find in single
connection mode.
ERROR:
Can't call method "tid" on an undefined value at
D:/Perl/site/lib/Net/Daemon/Log.pm line 75.
Thanks,
keith
------------------------------
Date: Wed, 17 Oct 2001 14:32:13 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Entering Name-Value pairs - Still Confused
Message-Id: <9qkn1h$cj5$1@slb4.atl.mindspring.net>
"Michael Carman" <mjcarman@home.com> wrote in message
news:3BCD7F64.D6915165@home.com...
> William Alexander Segraves wrote:
> >
> > Finally, YOUR query is off-topic for this newsgroup.
>
-mjc exclaimed, among other things,
> No, it is not.
O.K. You win. I withdraw my statement about "off-topic". Perhaps I should
have sent my response to Dr. K. directly to him, rather than to clpm.
> His question was about using CGI.pm (a Perl module) not
> about a CGI action (like setting a cookie). As such, it is on-topic
> here.
See subject of the post. I rest my case and will henceforth leave the
"on-topic/off-topic" police duties to those with more time to waste than I
have.
AFAIK, the OP was having trouble entering name=value pairs manually. IMO, he
would have had the same problem with "Entering Name-Value pairs - Still
Confused" regardless of whether or not he had used CGI.pm in his Perl
script.
Bill Segraves
Auburn, AL
------------------------------
Date: Wed, 17 Oct 2001 20:49:17 +0100
From: "jimbo" <jimbo@soundimages.co.uk>
Subject: Re: Entering Name-Value pairs - Still Confused
Message-Id: <1hlz7.2897$M15.24737@NewsReader>
"Steve Grazzini" <s_grazzini@hotmail.com> wrote
> http://www.perldoc.com/perl5.6.1/lib/CGI.html
Better still, use the docs stariaght from the horses mouth
http://stein.cshl.org/WWW/CGI/
jimbo
;-)
------------------------------
Date: Wed, 17 Oct 2001 15:20:51 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Entering Name-Value pairs - Still Confused
Message-Id: <3BCDE823.F6E150F5@home.com>
William Alexander Segraves wrote:
>
> "Michael Carman" <mjcarman@home.com> wrote in message
> news:3BCD7F64.D6915165@home.com...
> > William Alexander Segraves wrote:
> > >
> > > Finally, YOUR query is off-topic for this newsgroup.
> >
> > No, it is not.
>
> AFAIK, the OP was having trouble entering name=value pairs manually.
> IMO, he would have had the same problem with "Entering Name-Value
> pairs - Still Confused" regardless of whether or not he had used
> CGI.pm in his Perl script.
Ah, you must be using a different version of PSI::ESP than I am. :) The
thread got fragmented, which makes it harder to follow. My
interpretation was that the OP didn't understand how to use the offline
mode of CGI.pm. (For the unfamiliar, this feature allows you to supply
data to a CGI script without running through a webserver -- useful for
debugging.) You seem to have interpreted it as him not understanding how
data is supplied to a CGI script. Correct? I agree that the post was
off-topic under the latter interpretation.
-mjc
------------------------------
Date: 17 Oct 2001 23:05:46 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Glob limitations.
Message-Id: <87snci13zp.fsf@abra.ru>
>>>>> On Wed, 17 Oct 2001 17:50:52 +0100, "Godfrey Guinan" <godfrey@nexus-soft.com> said:
GG> Hi all,
GG> I'm having trouble using the glob comand when trying to process a few
GG> thousand files.
GG> I'm using version Perl 5.005_03 under Solaris 2.6 on a Sun Ultra.
GG> A sample of the code looks like this :-
GG> while (glob("*.html"))
GG> {
GG> $file = $_;
GG> blah blah blah.....
GG> }
GG> The error I get is :-
GG> glob failed (child exited with status 1) at file_exist.pl line 71, <_GEN_0>
GG> chunk 193696.
GG> Any ideas?
glob in Perl < 5.6.0 uses csh shell to expand pattern. Obviously it
just cant hanlde so many files.
You can use opendir to read directory and manually find files that
match your pattern.
Or if you lazy :) take File::BSDGlob from CPAN which replaces glob
with another sub which internally does something close to described
above.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) TIV.net (http://tiv.net/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: 17 Oct 2001 20:33:58 +0100
From: nobull@mail.com
Subject: Re: Glob limitations.
Message-Id: <u9zo6qoyc9.fsf@wcl-l.bham.ac.uk>
"Godfrey Guinan" <godfrey@nexus-soft.com> writes:
> I'm having trouble using the glob comand when trying to process a few
> thousand files.
Patent: Doctor, doctor it hurts when I do this!
Doctor: Then don't do it.
> I'm using version Perl 5.005_03 under Solaris 2.6 on a Sun Ultra.
>
> A sample of the code looks like this :-
>
> while (glob("*.html"))
> Any ideas?
Ditch glob and use readir() or File::Find
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 17 Oct 2001 20:16:36 GMT
From: "Jon Feldhammer" <jonf@rgb.com>
Subject: How can I send an html formatted email, preferably using Net::SMTP?
Message-Id: <9qkov4$7kk@dispatch.concentric.net>
I'm having a very hard time sending an email that a html enabled mail
program will read as html. I assume it has to do with the header line
Content-Type: text/plain which needs to be Content-Type: text/html ... I
can't seem to figure out how to change that line, or maybe that isnt' the
problem.
I've tried using the Mail::Header module but it is poorly documented and
have had no luck. I'd prefer to use SMTP rather than a direct open
(SENDMAIL, "| sendmail -t") type thing to keep this script platform
independent.
Thank you.
Jon
------------------------------
Date: 17 Oct 2001 11:22:18 -0700
From: james.h.anderson@ssmb.com (Jim Anderson)
Subject: Re: how to find memory leaks in perl 5.004_04
Message-Id: <2cfb060a.0110171022.510cb0c8@posting.google.com>
Dave Tweed <dtweed@acm.org> wrote in message news:<3BCD8AE0.95DC3913@acm.org>...
> Jim Anderson wrote:
> > 1. It's not my code.
> > 2. It's very big.
> > 3. It's proprietary.
> >
> > I'm just asking for some general guidelines.
>
> The general guideline is this: If the person who wrote your code
> isn't going to support it, and you can't show it to anyone else,
> either dump it and find another solution, or learn enough Perl so
> that you can debug it yourself. It's up to you.
>
> -- Dave Tweed
Well Dave, I know it's a waste of my time, not to mention network
bandwidth, but I can't resist thanking you for one of the most truly
useless replies I've ever received. It's no wonder there's a moderated
list... Clearly you don't understand that I'm asking whether there's a
general tool or method for tracking this sort of thing. I'm also
asking if there is a set of known memory leaks in this version of the
perl interpreter.
------------------------------
Date: Wed, 17 Oct 2001 21:16:07 +0100
From: "jimbo" <jimbo@soundimages.co.uk>
Subject: Re: how to find memory leaks in perl 5.004_04
Message-Id: <eGlz7.2483$qZ5.22687@NewsReader>
"Jim Anderson" <james.h.anderson@ssmb.com> wrote
> Well Dave, I know it's a waste of my time, not to mention network
> bandwidth, but I can't resist thanking you for one of the most truly
> useless replies I've ever received. It's no wonder there's a moderated
> list...
Your original premise was a waste of time, a waste of bandwidth and,
yet, you couldn't resist posting anyway. Might as well be a common,
substance obsessed, junkie.
Go on you tosser, post this question to comp.lang.perl.moderated. You
won't *EVER* see it there. Why, because Dave was spot on. If it's to
big to post (even the potentially offending fragments), you can't show
it to anyone, and the person or persons who wrote it won't support it
with you, then why, in God's very great name, do **YOU** expect anyone
else to be able, let alone willing, to help?
> list... Clearly you don't understand that I'm asking whether there's a
> general tool or method for tracking this sort of thing. I'm also
The sure as hell is, it's often referred to as the Perl Debugger. If
your **REALLY** interested you'll find heaps and heaps of details, if
you can be bothered to look. If you can understand what you find.
> asking if there is a set of known memory leaks in this version of the
> perl interpreter.
There may very well be. Have **YOU** bothered to look on www.perl.com
for such a thing? Have you bothered to search any one of the many well
know news archives for such a thing. You lazy, parochial git.
Lose the twisted sense of righteousness you seem to revel in. Mature.
Find personally rewarding pastimes. Leave coding to the professionals.
jimbo
;-)
------------------------------
Date: Wed, 17 Oct 2001 22:39:09 +0100
From: "WebBat" <webbat@btinternet.com>
Subject: how to get the user logon name with getlogin().
Message-Id: <9qktju$4on$1@plutonium.btinternet.com>
All,
I need to find the user logon name. but each time i try using getlogin, it
returns the user name on the server not the client.
e.g.
user Person1 logs on to a website and the name that is captured and stored
in a DB is ServerPerson1.
How can I determine the actual users name and not the server user name ?
Any ideas would be a great for a newbie.
Cheers
------------------------------
Date: Wed, 17 Oct 2001 16:12:01 -0400
From: Gary Fu <gfu@gscmail.gsfc.nasa.gov>
Subject: how to kill the child process ?
Message-Id: <3BCDE611.E43FBEE8@gscmail.gsfc.nasa.gov>
Hi all,
How can I kill the child process (before it finishs) by killing its
parent process ?
In the following parent-child examples, I tried to kill the parent's
pid (will kill command) before the child finish. However, the output
file always got created completed. When I monitored the pids with (ps
-ef),
after I kill the parent, I can see the parent pid was gone, but the
child pid still
there (until it finished) with its parent id set to 1.
Thanks.
Gary
**************** parent.pl *****************
#!/usr/local/bin/perl
use strict;
my $detected_SIGINT = 0;
my $exe = "child.pl";
system($exe);
exit;
************** child.pl ********************
#!/usr/local/bin/perl
use strict;
$| = 1;
open(OUT, ">out.txt") || die "Failed to open output file";
for (my $i=1; $i<40; $i++)
{
print OUT "********$i\n";
sleep 1;
}
exit;
------------------------------
Date: Thu, 18 Oct 2001 07:46:29 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: How to Ping to an IP
Message-Id: <slrn9srv1l.di2.mgjv@martien.heliotrope.home>
On Wed, 17 Oct 2001 18:10:52 +0200,
Sasha <sasha_lui@yahoo.com> wrote:
> Thank you guys,
>
> Is it also posible to see if an IP adress is valid ?
First, you'll have to define what that means: A valid IP address. Then,
you might want to have a look at inet_aton in the Socket module,
although I doubt that that is what you want. It is almost always what I
want, when I need to check that an IP address is 'valid'.
Martien
--
|
Martien Verbruggen | System Administration is a dirty job,
| but someone said I had to do it.
|
------------------------------
Date: 17 Oct 2001 21:16:04 +0100
From: David Rush <kumo@bellsouth.net>
Subject: Re: Lightweight Languages Workshop, Cambridge MA 11/17/01
Message-Id: <okfelo22faz.fsf@bellsouth.net>
Arjen Markus <Arjen.Markus@wldelft.nl> writes:
> The other day larry Virden mentioned a poster and paper about a
> "data mining" application in Tcl. Actually, it turned out to be
> an application of a pseudo natural language processor in Tcl.
This just shows to go that Turing was right. It doesn't mean that this
sort of thing is a good idea.
> "De Clarke did a poster at the 1998 Tcl conference on DataMynah, the
> system she developed that dealt with data visualization of the massive
> amounts of data that an orbiting satellite was retrieving.
Presumably the guts were written in something mundane, like C?
david rush
--
With guns, we are citizens. Without them, we are subjects.
-- YZGuy, IPL
------------------------------
Date: 17 Oct 2001 13:29:30 -0700
From: mhrtst@free.fr (MeNe)
Subject: lwp-request and load-balancing
Message-Id: <b5b3718c.0110171229.343504e2@posting.google.com>
Hi,
I have a perl prog which retrieves pages from a web site. It works
fine. The site grows so we added servers and a load-balancing
solution. Since then my scripts failed.
Here is an abstract of the code.
|use strict; ## On declare les variables
OBLIGATOIREMENT
|use LWP::UserAgent; ## Librairie WWW
|my $ua = LWP::UserAgent->new;
|my $req = HTTP::Request->new(GET => 'http://www.cpan.org');
|print $ua->request($req)->as_string;
fails with this error
|500 (Internal Server Error) Can't connect to www.cpan.org:80
(Timeout)
|Client-Date: Wed, 17 Oct 2001 20:03:15 GMT
using simple_request fails too.
The same code calling www.microsoft.com (for example) works just fine.
What am i doing wrong and what should i do ?
------------------------------
Date: Wed, 17 Oct 2001 20:04:15 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Manipulating Strings Within A Text File
Message-Id: <slrn9srp1v.kr9.garry@zfw.zvolve.net>
On 17 Oct 2001 10:47:54 -0700, Mua Bao <muabao@hotmail.com> wrote:
[ post re-ordered ]
>> perl -wpe 's/^(#define BUILD_VERSION )(\d+)/$1.($2+1)/e' filename
>>
> Thank you for helping me out. I'm embarassed to say that I'm a
> complete beginner to Perl.
No problem.
> Your line of code works on the command line, I take it?
Yes. Did you try it? If not, why not? I did before I posted it.
> So if I'm to put that into a .pl file, what would the syntax be like?
Of course the file can be named anything -- it doesn't have to end in
.pl, but here's what you would put in the file:
#!/usr/bin/perl -wp
s/^(#define BUILD_VERSION )(\d+)/$1.($2+1)/e;
Do you see why?
> How do I open the .txt file, read the value, & write the
> newly-incremented value to that file?
Name the file above `increment', then
$ perl increment old.txt > new.txt
$ mv new.txt old.txt
See the perlrun manual page for an explanation of the -p option.
While you're there, check out the -i option; you might find it useful,
too.
--
Garry Williams
------------------------------
Date: Wed, 17 Oct 2001 14:57:05 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Matching & Merging two text files
Message-Id: <i0jrstcidkja73qofd8vclj3rears2i8cr@4ax.com>
I have two Lotus Notes DBs that contain various information about
employees.
One contains things like Name, Hire Date, etc.. The other contains
Name, Address, etc.. Now they'd like them to be one. They'd also
like them to be in CSV format. OK. I made a Notes view that is
exportable in CSV and I exported them... so far so good.
The format is:
"Last Name, First Name" , "DOB" , "SSN" , etc. " "," "
^^^^^^^
blank fields
Here are the Perl questions:
I need to read both files and match the Name and merge all the info
together so that it all falls in under the Name. I know how to open
and read in a file but I'm a little fuzzy on how to read in two files
and get them to be one file. Would I read the file in a line at a
time or all at once?
I am a lot fuzzy (I'm absolutely furry actually) on how to get the
names to match up and then get rid of one of them.
For the matching should I strip the quotes? I don't think I actually
need them.
Are there modules that do just this sort of thing?
(I am not asking anyone to write the code out for me I just don't
understand what I supposed to be doing to make this happen. I think
the two files and the matching are what's making it hard for me to get
this around my head. I mostly use Perl to read log files and move
things around.)
any ideas?
Thanks!
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
Date: Wed, 17 Oct 2001 20:28:07 +0100
From: "jimbo" <jimbo@soundimages.co.uk>
Subject: Re: Matching & Merging two text files
Message-Id: <cZkz7.2856$M15.24262@NewsReader>
"Lou Moran" <lmoran@wtsg.com> wrote
> I have two Lotus Notes DBs that contain various information about
> employees.
Lucky guy.
> "Last Name, First Name" , "DOB" , "SSN" , etc. " "," "
> ^^^^^^^
> blank fields
> I need to read both files and match the Name and merge all the info
> together so that it all falls in under the Name. I know how to open
You don't want the name, you want the SSN.
> and read in a file but I'm a little fuzzy on how to read in two files
Open each file separately and read each file a csv line at a time.
Process each line and add it to your hash. You don't have to read them
in any sychronized fashion because you post indicates the SSN is in both
files. This is good. You've got your 'primary key' all taken care of.
> and get them to be one file.
When you've finished processing both files, dump the hash to disk.
Voila, one file.
What you need is to create a hash of hashes. For example,
my %emps;
$emp{SSN_GOES_HERE} = {};
$emp{SSN_GOES_HERE}->{Last Name} = ""
$emp{SSN_GOES_HERE}->{First Name} = ""
$emp{SSN_GOES_HERE}->{DOB} = ""
etc...
$emp{SSN_2_GOES_HERE} = {};
$emp{SSN_2_GOES_HERE}->{Last Name} = ""
$emp{SSN_2_GOES_HERE}->{First Name} = ""
$emp{SSN_2_GOES_HERE}->{DOB} = ""
etc...
> I am a lot fuzzy (I'm absolutely furry actually) on how to get the
> names to match up and then get rid of one of them.
Forget the names, man, the SSN is guarnteed to be unique (unless
somebody's been nicking identities).
> For the matching should I strip the quotes? I don't think I actually
> need them.
>
> Are there modules that do just this sort of thing?
Use Text::CSV;
Get it, install it, read the documentation. You won't be sorry.
> (I am not asking anyone to write the code out for me I just don't
That's good. Everybody seems real busy these days, anyway.
> I think
> the two files and the matching are what's making it hard for me to get
> this around my head.
If you've got this far, it won't be too hard.
> I mostly use Perl to read log files and move
> things around.)
Hey, don't we all.
jimbo
;-)
------------------------------
Date: Wed, 17 Oct 2001 12:35:18 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Matching & Merging two text files
Message-Id: <3BCDDD76.FD3C63FF@vpservices.com>
Lou Moran wrote:
>
> I have two Lotus Notes DBs that contain various information about
> employees.
I don't know what Lotus Notes supports, but check the documentation to
see if it supports "joins". If it does, you're probably better off
using it to combine the tables and then export the result to CSV. If
not, see below.
>
> One contains things like Name, Hire Date, etc.. The other contains
> Name, Address, etc.. Now they'd like them to be one. They'd also
> like them to be in CSV format.
> ...
> I need to read both files and match the Name and merge all the info
> together so that it all falls in under the Name.
>
> Are there modules that do just this sort of thing?
There are a number of modules to work with CSV data. At the moment, the
easiest way to join data from multiple tables (which is the database way
of talking about what you call "merging") is probably the ad_import()
method of DBD::AnyData. It allows you to import the two tables into
memory, creating a third table using a field (in your case "Name") as a
key to join the columns from the two. See the section "simulating
joins" in the POD. If you prefer real database joins, I'll mail you the
development version of SQL::Statement which now allows DBD::AnyData to
support real SQL joins. If you aren't a database kind of guy or don't
want to mess with DBI, then there is a tied hash interface in AnyData.pm
that will let you use the Name field from one table as a key to a hash
of rows in the second table. Write me if you need an example of how
that would work.
--
Jeff
------------------------------
Date: Wed, 17 Oct 2001 20:42:03 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Matching & Merging two text files
Message-Id: <v2mz7.140$1L8.204689408@news.frii.net>
In article <i0jrstcidkja73qofd8vclj3rears2i8cr@4ax.com>,
Lou Moran <lmoran@wtsg.com> wrote:
>
>I need to read both files and match the Name and merge all the info
>together so that it all falls in under the Name. I know how to open
>and read in a file but I'm a little fuzzy on how to read in two files
>and get them to be one file. Would I read the file in a line at a
>time or all at once?
>
For this kind of stuff on moderate size files I've taken to using jdb
http://www.isi.edu/~johnh/SOFTWARE/JDB/
It's a set of Perl scripts that manipulate flat tab delimited files.
They work quite well for problems that are too big for an off the cuff
command line solution but too small for a real relational database.
Good luck
--
This space intentionally left blank
------------------------------
Date: Wed, 17 Oct 2001 20:14:59 +0200
From: Mirko Schur <mschur@web.de>
Subject: Need help to find a regexp
Message-Id: <3BCDCAA3.DB1B0F93@web.de>
Hi,
I try to find a regexp for the following task:
In the following string for example
"<b>Important</b> Note: {<i>}The Note{</i>}"
I try to delete the html tags with a regular expression, however
those enclosed by { and } should not be deleted.
Can anybody find a regexp for that task?
Thanks
Mirko
--
Mirko Schur
http://www.mirkoschur.de
info@mirkoschur.de
------------------------------
Date: 17 Oct 2001 20:37:44 +0100
From: nobull@mail.com
Subject: Re: Objects: Setting defaults and calling themselves??
Message-Id: <u9u1wyoy5z.fsf@wcl-l.bham.ac.uk>
peter@PSDT.com (Peter Scott) writes:
> In article <86669fd63w.fsf@jon_ericson.jpl.nasa.gov>,
> Jon Ericson <Jon.Ericson@jpl.nasa.gov> writes:
> >Ed Kulis <ekulis@apple.com> writes:
> >
> >> use lib ".";
> Not to mention that it is in @INC by default unless you're root...
Yes, it would be good not to mention that. Mostly because it's not
(in general) true.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 17 Oct 2001 12:16:52 -0700
From: Ed Kulis <ekulis@apple.com>
Subject: Re: Oracle PL/SQL from Perl?
Message-Id: <3BCDD924.1D169629@apple.com>
The best way is to use Oracle::DBD as Ron Reidy said:
Sometimes I've had Oracle::DBD and sometimes I haven't had it.
Below is a quick and dirty demo of techniques that I've used in Unix.
One of the main problems with this is that you've got to kludge up quoting, handle embedded spaces, field parsing and error
detection by yourself.
The techniques also provide a kludgey "Dynamic SQL" where you build in Perl and SQL or PL/SQL text that you then submit with
sqlplus.
Oracle::DBD does a far,far superior job in all respects but if you haven't got it or can't get it then this might suffice on an
individual case basis.
== Begin Perl/Oracle Demo ========================================
#!/usr/bin/perl -w
use strict;
use diagnostics;
my $tns_access_string = qx( default.acn );
#
# returns a string like "scott/tiger@zoodb";
# this keeps passwords out of the code and the Unix "ps -ef" list.
chomp $tns_access_string;
# no chomp causes SQL Plus error: SP2-0223: No lines in SQL buffer.
my $datatag = '<dataline>'; # Used to build a query so datalines
# can be extracted from junk in the
# sqlplus output stream
# Start Sqlplus invocation ----------------------------------------------
#
open SQLPLUS ,qq{ sqlplus -s /nolog <<EOB
connect $tns_access_string ;
set serveroutput on size 1000000
describe user_users;
create procedure demoekulis
is
cursor demo
is
select
'$datatag' datatoken
,'ACCTSTAT: ' || account_status account_field
from
user_users
;
begin
for r in demo
loop
dbms_output.put_line(r.datatoken||r.account_field);
end loop;
end;
/
show errors
exec demoekulis;
drop procedure demoekulis; -- tidy up
EOB
|}; # Output to pipe
# End Sqlplus invocation ----------------------------------------------
while (<SQLPLUS>)
{
print $_;
if (s/$datatag//)
{
# Do something special if data tag matches
#
my $datafields = $' ; # postmatch
print join ""
,"Removed datatag from line: "
,$datafields
;
};
};
== End Perl/Oracle Demo ========================================
Stefan Bauer wrote:
> I have a (rather complex) piece of PL/Sql (That cannot be easily
> converted into a package)that has been tested, and is functioning.
>
> What is the best way (hopefully other than a system call to plsql) to
> execute an already written piece of PL/SQL from with in perl?
------------------------------
Date: Wed, 17 Oct 2001 14:38:37 -0500
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Oracle PL/SQL from Perl?
Message-Id: <slrn9srnht.9os.trammell@haqq.hypersloth.net>
On Wed, 17 Oct 2001 12:16:52 -0700, Ed Kulis <ekulis@apple.com> wrote:
> The best way is to use Oracle::DBD as Ron Reidy said:
ITYM DBD::Oracle. HTH, HAND.
------------------------------
Date: Wed, 17 Oct 2001 20:20:40 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: pcl printer codes
Message-Id: <slrn9srq0o.kr9.garry@zfw.zvolve.net>
On Wed, 17 Oct 2001 11:48:27 -0600, Mark Winter
<mwinter@nrel.nrel.gov> wrote:
> I am trying to write a perl program that embeds a HP printer code in the
> file useing something
> like this:
>
> print(OUT"ord(027) ord(038) ord(108) ord(054) ord(103) \n");
That probably won't result in what you want. Maybe a closer
approximation would be:
print OUT ord(027), ord(038), ord(108), ord(054), ord(103), "\n";
--
Garry Williams
------------------------------
Date: Wed, 17 Oct 2001 14:57:12 -0600
From: Mark Winter <mwinter@nrel.nrel.gov>
Subject: Re: pcl printer codes
Message-Id: <3BCDF0A8.2ECCAA6E@nrel.nrel.gov>
Sorry,
that doesn't even run.
>
>
> That probably won't result in what you want. Maybe a closer
> approximation would be:
>
> print OUT ord(027), ord(038), ord(108), ord(054), ord(103), "\n";
>
> --
> Garry Williams
------------------------------
Date: Wed, 17 Oct 2001 21:27:00 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: pcl printer codes
Message-Id: <slrn9srtt5.kr9.garry@zfw.zvolve.net>
On Wed, 17 Oct 2001 14:57:12 -0600, Mark Winter
<mwinter@nrel.nrel.gov> wrote:
[ post re-ordered ]
>> That probably won't result in what you want. Maybe a closer
>> approximation would be:
>>
>> print OUT ord(027), ord(038), ord(108), ord(054), ord(103), "\n";
>>
> Sorry,
>
> that doesn't even run.
Yup. I cut and pasted what you wrote. Try
chr(27), chr(38), chr(108), chr(54), chr(103)
--
Garry Williams
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1948
***************************************