[22359] in Perl-Users-Digest
Perl-Users Digest, Issue: 4580 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 18 14:08:04 2003
Date: Tue, 18 Feb 2003 11:05:10 -0800 (PST)
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, 18 Feb 2003 Volume: 10 Number: 4580
Today's topics:
Re: (not 1) and (!1) yield zero length string <bart.lateur@pandora.be>
Re: Copying the contents of a directory <andy@misk.co.uk>
Re: Creating PDF files that include images <mfowle@ATnavicominc.dropme.com>
Date module (Kevin)
Re: Date module <usenet@dwall.fastmail.fm>
Re: Easy filter running for Win32 GUI users (Phil Hibbs)
Re: having perl respond to key presses (Bob Dubery)
Re: having perl respond to key presses <tyrannous@o-space.com>
how to join 2 text files sql style in perl (Domenico Discepola)
Re: how to join 2 text files sql style in perl <usenet@dwall.fastmail.fm>
Re: how to join 2 text files sql style in perl <shanem@nospam.ll.mit.edu>
Re: how to join 2 text files sql style in perl (Helgi Briem)
Re: How to trim a field in a data line? <barryk2@SPAM-KILLER.mts.net>
Memory problem with persistent DBI connection <doctor.jeep-fdee88a84189fe720f268444cdf58c21-20030221@email.expiry.luchs.at>
Re: Memory problem with persistent DBI connection <spamtrap@nowhere.com>
Re: Newbie Q re form to mail script FormProcessorPro <notworking@all.com>
Newbie: Regex matching problem <thekid@overhere.com>
Re: Newbie: Regex matching problem (Helgi Briem)
Re: Newbie: Regex matching problem <nobull@mail.com>
Re: one liner in command line <noemail@nowhere.net>
Re: Perl & VB without activeperl on Windows?? <noemail@nowhere.net>
Re: Perl & VB without activeperl on Windows?? <usenet@dwall.fastmail.fm>
Re: reading excel spreadsheet with perl <ubl@schaffhausen.de>
Re: reading excel spreadsheet with perl (Bob Dubery)
Re: Regular Expression Noob <perl-dvd@darklaser.com>
Re: Regular Expression Noob <abigail@abigail.nl>
Re: Returning the field list from DBI (Sara)
Re: String Compare Help <andy@misk.co.uk>
Re: Tk::Notebook corks Expect.pm!! <phlipcpp@yahoo.com>
Re: use DBI; <bobx@linuxmail.org>
Re: use DBI; (Andrew Perrin (CLists))
Re: use DBI; (Helgi Briem)
Re: use DBI; (Helgi Briem)
Re: use DBI; <abigail@abigail.nl>
use of exit() (was Re: use DBI;) <usenet@dwall.fastmail.fm>
Re: Using Archive::Tar for in-memory tarfiles <eric.schwartz@hp.com>
Using different hashes. <spikey-wan@bigfoot.com>
Re: Using different hashes. <usenet@dwall.fastmail.fm>
Re: Using different hashes. <mjcarman@mchsi.com>
Where is DB_File in redhat 8.0? <no_email@none.abc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 18 Feb 2003 15:43:00 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: (not 1) and (!1) yield zero length string
Message-Id: <rak45v0jl3nbf45kacdsnfts7eoitnrqab@4ax.com>
parv wrote:
>I am mystified that (not 1 ...) & (!1 ...) yield _zero_length_string_
>but not the following operations...
>
> (!0 && 0) , (!0 and 0) , (not 0 && 0) , (not 0 and 0)
>
>
>...which produce 0, 0, 1, 0 respectively.
First of all, "&&" and "||" have extended functionality as compared to,
say, PHP.
$foo && $bar
is functionally equivalent to
$foo ? $bar : $foo
and
$foo || $bar
to
$foo ? $foo : $bar
except that $foo is evaluated only once (meaning its result is stored in
a temporary location, and used if it is consequently wanted). By
contrast, in PHP, "&&" returns a boolean, which is far less useful. YOu
can use the result in Perl as a boolean without any though, thus you
won't get errors because of that little extra.
See:
print 3 || 2;
-->
3
print 3 && 2;
-->
2
print 0 && 2;
-->
0
print "" && 2;
-->
print 0 || "";
-->
So "&&" and "||" return just scalars you can use as boolean.
In addition, some tests return actual booleans, which are scalars with a
value that has a dual nature: true is "1" in string and 1 in numerical
context; false is "" in string and 0 in numercial context. In practice,
this means that if you use this false as a number, you won't get a
conversion warning because the string doesn't look like a number. You
would if you tried to use a normal "" as a number.
These two things are barely related to one another.
--
Bart.
------------------------------
Date: Tue, 18 Feb 2003 17:55:07 +0000
From: Andrew McGregor <andy@misk.co.uk>
Subject: Re: Copying the contents of a directory
Message-Id: <3E52737B.9060902@misk.co.uk>
Steve wrote:
> I've been able to successfully copy individual files from one directory to
> another using
>
> use File::Copy;
> copy("$sourcedir/$filename", "$destinationdir/" . "$filename");
>
> but have had no luck copying the entire contents of the directory.
>
> I would appreciate any suggestions.
>
> Thanks,
> Steve
>
>
opendir() and readdir() will allow you to get a list of files that you
can then copy().
------------------------------
Date: Tue, 18 Feb 2003 18:11:03 GMT
From: Mark <mfowle@ATnavicominc.dropme.com>
Subject: Re: Creating PDF files that include images
Message-Id: <l1u45vcj5but8fo8ufrpdd6ahetjf0s7v1@4ax.com>
On 15 Jan 2003 18:32:19 -0800, zkent@adelphia.net (VisionHolderTech)
wrote:
>(Mike Solomon) wrote in message
>
>> I nead to create PDF files using Perl
>>
>> I have tried PDF::create which works but I can't include images using it.
>>
>> Does anyone know how to do this
>>
>
>Since the images are encoded in a PDF as ASCII codes (insert technical
>jargon here), what if you made a PDF (manually) that included the
>images and then cut the encoded parts out and stored it in an ASCII
>file or database. You could then retrieve the encoded image and and
>insert it into the PDF when needed. I have wanted to do this for a
>year now on a project, but have not gotten to it yet. But that is my
>idea on how to do it. Let me know if it works.
I've just started using PDF::API2
it works great for creating PDF's, I've not aded an image yet, but the
documentation seems to be straight forward.
If you are going to bedoing alot of this.
Perl Graphics Programing by O'Reilly, just came out it is great
ISBN 0-596-00219-x
Mark
------------------------------
Date: 18 Feb 2003 07:54:42 -0800
From: kevin_mudd@adp.com (Kevin)
Subject: Date module
Message-Id: <bf26a3a6.0302180754.69fd8fa2@posting.google.com>
Is there an existing Date module where I can get the number of days in
the current month?
Thanks,
Kevin
------------------------------
Date: Tue, 18 Feb 2003 17:23:38 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Date module
Message-Id: <Xns93267E13F4F8Edkwwashere@216.168.3.30>
Kevin <kevin_mudd@adp.com> wrote on 18 Feb 2003:
> Is there an existing Date module where I can get the number of
> days in the current month?
use Date::Calc qw/Days_in_Month/;
You might also look at some past usenet postings, such as
Message-ID: <qs9kksoqtj5s7664sfk5gv84rscm2lk77i@4ax.com>#1/1
or <avehrs8bnj413so0c8jtp4feoi5sbmv6vb@4ax.com>
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: 18 Feb 2003 08:06:59 -0800
From: gg@snark.freeserve.co.uk (Phil Hibbs)
Subject: Re: Easy filter running for Win32 GUI users
Message-Id: <a9ec249e.0302180806.51d2616c@posting.google.com>
Ingo Wichmann <w_ichmann@uni-wuppertal.de> wrote in message news:<3E4D1698.3030902@uni-wuppertal.de>...
> Why not Tk?
> use Tk;
> my $mw = MainWindow->new;
> my $infile = $mw->getOpenFile(-title=>'Input File');
> my $outfile = $mw->getOpenFile(-title=>'Output File');
That's nice, but I'd prefer a Save dialog for the second one, as
getOpenFile insists on the file existing already. I am looking at the
documentation for FileSelect
http://aspn.activestate.com/ASPN/Reference/Products/ActivePerl/site/lib/Tk/FileSelect.html
which looks similar, and it says "Please see the Populate subroutine
as the configuration list changes rapidly" - maybe there is an option
that I can select that tells it not to complain about the file not
existing. Any suggestions? I can't find this Populate subroutine
anywhere, either locally or on the internet.
Phil Hibbs.
------------------------------
Date: Tue, 18 Feb 2003 14:25:24 GMT
From: megapode@hotmail.com (Bob Dubery)
Subject: Re: having perl respond to key presses
Message-Id: <3e524222.18047968@10.100.2.1>
On Tue, 18 Feb 2003 10:59:45 -0000, <tyrannous@o-space.com> wrote:
>How do I get perl to respond to key presses?
To a press of ONE KEY? Or a user typing in something and pressing
enter?
------------------------------
Date: Tue, 18 Feb 2003 18:10:50 -0000
From: <tyrannous@o-space.com>
Subject: Re: having perl respond to key presses
Message-Id: <b2tsu5$9hs$1@newsg3.svr.pol.co.uk>
To a single key press.
"Bob Dubery" <megapode@hotmail.com> wrote in message
news:3e524222.18047968@10.100.2.1...
> On Tue, 18 Feb 2003 10:59:45 -0000, <tyrannous@o-space.com> wrote:
>
> >How do I get perl to respond to key presses?
> To a press of ONE KEY? Or a user typing in something and pressing
> enter?
>
------------------------------
Date: 18 Feb 2003 07:04:39 -0800
From: joeminga@yahoo.com (Domenico Discepola)
Subject: how to join 2 text files sql style in perl
Message-Id: <698c67f.0302180704.6417fe28@posting.google.com>
Spent many hours trying to solve my practical problem that I'm sure
would benefit others as well... I have 2 text files (.csv) with a
common column in each file:
file1: field1, field2
file2: field2, field3
I simply wish to print field1, file1.field2, field3 where file1.field2
= file2.field2. This is similar to the sql statement:
select field1, file1.field2, field3
from file1, file2
where file1.field2 = file2.field2
;
I prefer not using any external packages such as DBI, AnyData, etc. I
was surprised to find a lack of postings / documentation on this so
any help would be greatly appreciated...
------------------------------
Date: Tue, 18 Feb 2003 15:18:05 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: how to join 2 text files sql style in perl
Message-Id: <Xns932668CA6899Bdkwwashere@216.168.3.30>
Domenico Discepola <joeminga@yahoo.com> wrote on 18 Feb 2003:
> Spent many hours trying to solve my practical problem that I'm
> sure would benefit others as well... I have 2 text files (.csv)
> with a common column in each file:
[snip]
> select field1, file1.field2, field3
> from file1, file2
> where file1.field2 = file2.field2
> ;
>
> I prefer not using any external packages such as DBI, AnyData,
> etc. I was surprised to find a lack of postings / documentation
> on this so any help would be greatly appreciated...
The reason you didn't find many posts or documentation on it is
because it's easier, more efficient, and less error-prone to use an
existing module than it is to write new code. Is there a compelling
reason not to use a module? If it's only a preference, perhaps you
should reconsider the preference.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Tue, 18 Feb 2003 11:23:30 -0500
From: Shane McDaniel <shanem@nospam.ll.mit.edu>
Subject: Re: how to join 2 text files sql style in perl
Message-Id: <3E525E02.C52F005C@nospam.ll.mit.edu>
Domenico Discepola wrote:
>
> Spent many hours trying to solve my practical problem that I'm sure
> would benefit others as well... I have 2 text files (.csv) with a
> common column in each file:
>
> file1: field1, field2
> file2: field2, field3
>
> I simply wish to print field1, file1.field2, field3 where file1.field2
> = file2.field2. This is similar to the sql statement:
>
> select field1, file1.field2, field3
> from file1, file2
> where file1.field2 = file2.field2
> ;
>
> I prefer not using any external packages such as DBI, AnyData, etc. I
> was surprised to find a lack of postings / documentation on this so
> any help would be greatly appreciated...
Just read in both files, do a for loop over the length ( which should be
the same for both files I'm assuming) . split each line on ", " and do
your print.
-shane
------------------------------
Date: Tue, 18 Feb 2003 16:39:52 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: how to join 2 text files sql style in perl
Message-Id: <3e52617d.967732806@news.cis.dfn.de>
On 18 Feb 2003 07:04:39 -0800, joeminga@yahoo.com (Domenico
Discepola) wrote:
>Spent many hours trying to solve my practical problem that I'm sure
>would benefit others as well... I have 2 text files (.csv) with a
>common column in each file:
<SNIP>
>I prefer not using any external packages such as DBI, AnyData, etc. I
>was surprised to find a lack of postings / documentation on this so
>any help would be greatly appreciated...
I suggest using DBI and DBD::CSV.
"I prefer" is not a valid excuse for not doing the job
correctly.
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: Tue, 18 Feb 2003 08:12:04 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: How to trim a field in a data line?
Message-Id: <MPG.18bbfb33691074d9989701@news.mts.net>
In article <81a67b5.0302170520.369ca1a9@posting.google.com>, SYeats
(simonyeats@hotmail.com) says...
> Hi,
> this is got me beat, i was wondering if anyone could help.
> I wish to replace the 94th field in a semi-colon delimited text file
> with a modified version of the same field.
> This field can have values like A+ BB+ CCC-, and i wish to remove the
> +/-, so its just A BB CCC.
> I am trying something like
>
> #!/bin/perl
>
> while (<>) {
> @F=split/;/;
> $F[-18]=~ m/([A-Z]{1,3})/;
> print "$1\n";
> }
>
> but i cant figure out how to do the replacement, just the match.
>
> Any help much appreciated,
>
> thanks Simon
>
$F[93] =~ s/[+-]//g; # Modify 94th field
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: Tue, 18 Feb 2003 15:41:08 +0100
From: "DJ" <doctor.jeep-fdee88a84189fe720f268444cdf58c21-20030221@email.expiry.luchs.at>
Subject: Memory problem with persistent DBI connection
Message-Id: <pan.2003.02.18.14.41.07.540870@pentex.at>
Hello!
I am coding a small watchdog daemon that monitors a couple of ports. It
reads the list of hosts and the port to connect to from a Postgres
database. The daemon uses a persistent connection to the databases. There
are just two SELECTs and a couple of INSERTs and UPDATEs, depending on the
state of the monitored ports.
The problem is that the daemon process accumulates memory over time. I ran
the daemon for three days and the process got as big as 50 MB. I don't
understand where the memory is used. Although the database connection is
persistent I use finish() and commit() in order to flush the buffers. Does
anyone have any idea how to trace this problem or how to make sure that
the process doesn't grow?
The test system runs Perl 5.8.0 with recent CPAN modules.
Cheers,
dj
--
Get real! Make a pact with a demon!
------------------------------
Date: Tue, 18 Feb 2003 18:13:04 GMT
From: Andrew Lee <spamtrap@nowhere.com>
Subject: Re: Memory problem with persistent DBI connection
Message-Id: <o86j2vk3at6p8k63miajoki06p93menk04@4ax.com>
On Tue, 18 Feb 2003 15:41:08 +0100, "DJ"
<doctor.jeep-fdee88a84189fe720f268444cdf58c21-20030221@email.expiry.luchs.at>
wrote:
>Hello!
>
>I am coding a small watchdog daemon that monitors a couple of ports. It
>reads the list of hosts and the port to connect to from a Postgres
>database. The daemon uses a persistent connection to the databases. There
>are just two SELECTs and a couple of INSERTs and UPDATEs, depending on the
>state of the monitored ports.
>
>The problem is that the daemon process accumulates memory over time. I ran
>the daemon for three days and the process got as big as 50 MB. I don't
>understand where the memory is used. Although the database connection is
>persistent I use finish() and commit() in order to flush the buffers. Does
>anyone have any idea how to trace this problem or how to make sure that
>the process doesn't grow?
Are you closing your statement handles?
------------------------------
Date: Tue, 18 Feb 2003 16:13:51 -0000
From: Trilby <notworking@all.com>
Subject: Re: Newbie Q re form to mail script FormProcessorPro
Message-Id: <MPG.18bc5965704470619896d4@news.iol.ie>
While busily concocting a devastating reply tiltonj@erols.com retorted
> Trilby <notworking@all.com> wrote:
>
> : I am not a perl programmer but trying to deal with a perl script called
> : FormProcessorPro v3.2 [Mitridat.com] which takes the contents of a html
> : form and emails it to recipients in a format based on templates that the
> : user can set out in a txt file with whatever text is required and the
> : fields from the form in brackets [ ].
> :
> : I am hoping you can help me with a small matter:
>
> Was the program vendor unable or unwilling to help?
>
>
Unfortunately they don't offer a user forum and I can't find any
references to it on the web, even though I think it's a great script.
He does offer help from time to time but at great delay and at a cost.
Do I take it that there is no 'obvious' solution ?
Tks.
Trilby
------------------------------
Date: Tue, 18 Feb 2003 15:07:20 +0100
From: "TheKid" <thekid@overhere.com>
Subject: Newbie: Regex matching problem
Message-Id: <b2te4u$783$1@newstoo.ericsson.se>
Hi Guys,
I'm a newbie so forgive me if this is a bit basic but I read the FAQ,
checked perl doc etc., and this problem has still left me puzzled for the
last couple of days. I have two arrays. I want to check if one any of the
values stored in my GROUP array partially match any of the values in my
AllSTPsArray (both are srtings). If this occurs then I want to execute some
predefined commands. ( ie.if ( STP52_C1_DT3.tc =~ /STP52_C1/) ). Thanks for
any help. My attempt is included below.
for (@GROUP)
{
$STP = "$_";
for (@AllSTPsArray)
{
$STP_file = "$_";
if ( $STP_file =~ /$STP/ )
{
actioncode;
}
}
}
------------------------------
Date: Tue, 18 Feb 2003 14:22:38 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Newbie: Regex matching problem
Message-Id: <3e524125.959451918@news.cis.dfn.de>
On Tue, 18 Feb 2003 15:07:20 +0100, "TheKid"
<thekid@overhere.com> wrote:
>Hi Guys,
> I'm a newbie so forgive me if this is a bit basic but I read the FAQ,
>checked perl doc etc.,
That's good.
>and this problem has still left me puzzled for the
>last couple of days. I have two arrays. I want to check if one any of the
>values stored in my GROUP array partially match any of the values in my
>AllSTPsArray (both are srtings). If this occurs then I want to execute some
>predefined commands. ( ie.if ( STP52_C1_DT3.tc =~ /STP52_C1/) ). Thanks for
>any help. My attempt is included below.
Here is one way to do it:
use warnings;
use strict;
# faked up test data, I hope it fits your reqs
my (@AllSTPsArray) = qw/A_ B_ C_ D_/;
my @group = qw(A_32 A_45 C_56 T_54 N_18);
my $regex = join "|",@AllSTPsArray;
for (@group)
{
if (/^$regex/) { actioncode($_); }
}
sub actioncode
{
for (@_) { print "$_\n"; }
}
__END__
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: 18 Feb 2003 17:55:58 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Newbie: Regex matching problem
Message-Id: <u9smul4gnl.fsf@wcl-l.bham.ac.uk>
"TheKid" <thekid@overhere.com> writes:
> Subject: Newbie: Regex matching problem
Do not put "newbie" in your subject unless it is your intent to put
people off helping you.
> I'm a newbie so forgive me if this is a bit basic but I read the FAQ,
> checked perl doc etc., and this problem has still left me puzzled for the
> last couple of days. I have two arrays. I want to check if one any of the
> values stored in my GROUP array partially match any of the values in my
> AllSTPsArray
This looks superficially similar to FAQ: "How do I efficiently match
many regular expressions at once?"
> (both are srtings).
> If this occurs then I want to execute some predefined commands. (
> ie.if ( STP52_C1_DT3.tc =~ /STP52_C1/) ).
You appear to have contadicted yourself. Are you saying you want to know:
1) if one string contains another string
or
2) one string contains a match for a regex
> Thanks for any help.
Help with what? You haven't asked a question yet.
> My attempt is included below.
Looks like it should work fine despite the affectations.
> for (@GROUP)
> {
> $STP = "$_";
> for (@AllSTPsArray)
> {
> $STP_file = "$_";
>
> if ( $STP_file =~ /$STP/ )
> {
> actioncode;
> }
> }
> }
I can't see any reson it wouldn't work but it can be simplfied to:
for my $STP (@GROUP) {
for my $STP_file (@AllSTPsArray) {
if ( $STP_file =~ /$STP/ ) {
actioncode;
}
}
}
I'm assuming here that @GROUP is an array of regexes.
If you want the elements of @GROUP to be treated as plain strings then
you should change /$STP/ to /\Q$STP/ or use index() instead.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 18 Feb 2003 14:57:46 GMT
From: nobody <noemail@nowhere.net>
Subject: Re: one liner in command line
Message-Id: <Xns932665AB8686Aabccbaabc@129.250.170.100>
>> how can use a variable in a one line program if it's in the command
>> line?
> perl -e "my $x=99; print $x;"
Just realized, the "my" in not necessary (habit).
Same for the trailing semicolon, but I like it.
perl -e "$x=99; print $x;"
And yes, this is for Win2K. Other platforms have other
shell quoting requirements.
------------------------------
Date: 18 Feb 2003 14:53:30 GMT
From: nobody <noemail@nowhere.net>
Subject: Re: Perl & VB without activeperl on Windows??
Message-Id: <Xns932664F24D113abccbaabc@129.250.170.100>
> ... is there something I can do to allow my vb and perl
> program to work together on a windows machine without activeperl??!!
You could use ActiveState's PerlApp utility to make your Perl
script into an .exe. (It's part of their Perl Dev. Kit (PDK),
costs $).
Or you could just copy the ActivePerl files you need.
You may just need the perl executable and a few dll's and
other files.
------------------------------
Date: Tue, 18 Feb 2003 15:53:56 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Perl & VB without activeperl on Windows??
Message-Id: <Xns93266EDE9202Fdkwwashere@216.168.3.30>
nobody <noemail@nowhere.net> wrote on 18 Feb 2003:
>> ... is there something I can do to allow my vb and perl
>> program to work together on a windows machine without
>> activeperl??!!
>
> You could use ActiveState's PerlApp utility to make your Perl
> script into an .exe. (It's part of their Perl Dev. Kit (PDK),
> costs $).
Or take a look at PAR.pm on CPAN.
http://search.cpan.org/search?query=PAR&mode=all
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Tue, 18 Feb 2003 15:27:33 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: reading excel spreadsheet with perl
Message-Id: <b2tj3s$fla$1@news.dtag.de>
Richard S Beckett wrote:
> "Rory" <rory@vivid-design.com.au> wrote in message
> news:d9ba31e6.0302180041.436fb84f@posting.google.com...
>
>>I have an excel spreadsheet on a linux server. I am attempting to use
>>this spreadsheet as a datasource. It contains information about store
>>locations (name, state, country ect). I want to update this
>>spreadsheet as well.
> Have a look at Win32::OLE. This will let you load, modify, and save a
> spreadsheet with the same or a different name.
Yeah, but
1.) it won't run without a windows machine running Excel
2.) it does only support file wide locks
->malte
------------------------------
Date: Tue, 18 Feb 2003 14:26:43 GMT
From: megapode@hotmail.com (Bob Dubery)
Subject: Re: reading excel spreadsheet with perl
Message-Id: <3e52426f.18124718@10.100.2.1>
On 18 Feb 2003 00:41:32 -0800, rory@vivid-design.com.au (Rory) wrote:
>Any ideas or input would be appreciated.
Recent versions of Excel can ouput spreadsheets as XML, and you can
certainly manipulate and modify invidual elemets of an XML doc with
various modules.
------------------------------
Date: Tue, 18 Feb 2003 16:52:28 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: Regular Expression Noob
Message-Id: <gxt4a.25$F6.6438@news-west.eli.net>
"Z" <ztamir@yahoo.com> wrote in message
news:93a2d462.0302171757.77778911@posting.google.com...
> I'm new to regular expressions and need a little help. What regular
> expression do I use within the PHP function split() to create an array
> of all the substrings located between ANI="TheNumberIwantIsHere"&
>
> The string I'm trying to parse looks like the following:
>
>
ANI=1114875732&NAME=Albert&EXT=3030&LOGIN=LoggedIn&TALK=Unavailable&PRIO
RITY=2003-02-17
> 12:22:40 **==+==**ANI=222650654&NAME=Ami&EXT=3034&LOGIN=Logged
> In&TALK=Unavailable&PRIORITY=2003-02-17 12:35:08
> **==+==**ANI=3336600734&NAME=Louisa&EXT=3035&LOGIN=Logged
> In&TALK=Unavailable&PRIORITY=2003-02-17 12:37:20
> **==+==**ANI=4443830235&NAME=Roxanne&EXT=3032&LOGIN=Logged
> In&TALK=Unavailable&PRIORITY=2003-02-17 12:39:33
> **==+==**ANI=5556235414&NAME=Tia&EXT=3031&LOGIN=Logged
> In&TALK=Unavailable&PRIORITY=2003-02-17 12:38:13 **==+==**Total
> Agents=5 FINISHED
>
> So, in other words, starting from the first ANI I want to create an
> array that looks like this
>
> 1114875732
> 222650654
> 3336600734
> 4443830235
> 5556235414
How about something like this (note this is perl not PHP)
my @ani_list = $string =~ /ANI\=(\d+)/g; # untested
Regards,
David
------------------------------
Date: 18 Feb 2003 18:04:11 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Regular Expression Noob
Message-Id: <slrnb54tcr.263.abigail@alexandra.abigail.nl>
David (perl-dvd@darklaser.com) wrote on MMMCDLVIII September MCMXCIII in
<URL:news:gxt4a.25$F6.6438@news-west.eli.net>:
[]
[] my @ani_list = $string =~ /ANI\=(\d+)/g; # untested
Why did you escape the equal sign?
Abigail
--
perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'
------------------------------
Date: 18 Feb 2003 08:39:49 -0800
From: genericax@hotmail.com (Sara)
Subject: Re: Returning the field list from DBI
Message-Id: <776e0325.0302180839.b787f6d@posting.google.com>
Brian McCauley <nobull@mail.com> wrote in message news:<u9fzqmq00u.fsf@wcl-l.bham.ac.uk>...
.
.
.
> >
> > By "read position" I'm not sure what you mean. If you mean that one
> > user has multiple records, then continue to fetch until you get them
> > all.
>
> The OP means he wants to be able to get the n-th page full of
> results.
>
> perldoc DBI actually mentions the absense of support for this
> explicitly:
>
> Non-sequential record reads are not supported in this ver-
> sion of the DBI. In other words, records can only be
> fetched in the order that the database returned them, and
> once fetched they are forgotten.
Yes you're correct, I spoke to Mr Bunce at Oscon about this last year
and I don't forsee this capability anytime soon. Even at the mysql
prompt I'm not sure how you'd get the nth page?
I'm trying to recall the entire conversation, but I think Tim said
that people have the impression that the DBI fetches everything from
the DB then feeds it back in parcels, which is not how it actually
operates.
As for fieldnames, I like your approach better than my suggestion
thanks.
Gx
------------------------------
Date: Tue, 18 Feb 2003 16:47:19 +0000
From: Andrew McGregor <andy@misk.co.uk>
Subject: Re: String Compare Help
Message-Id: <3E526397.1040108@misk.co.uk>
Ryan wrote:
> What is wrong with this? The evaluation of the strings is wrong somehow?
>
> $name = "abc";
> $testdir = "zxy";
>
> if($name == $testdir)
> {
> $result = "True";
> }
> else
> {
> $result = "False";
> }
>
>
`==' is used for numerical values, try `eq' for strings.
------------------------------
Date: 18 Feb 2003 15:26:59 GMT
From: Phlip <phlipcpp@yahoo.com>
Subject: Re: Tk::Notebook corks Expect.pm!!
Message-Id: <b2tjc3$ksv@dispatch.concentric.net>
Wolfgang Hommel wrote:
> Phlip wrote:
>
>> Thanks in advance to anyone about to tell me to use Tk::IO, but it gives
>> essentially the same error, but this time without the Tk::Notebook.
>
> Does 'fork' work in your Cygwin Perl at all? Doesn't really look like a Tk
> problem to me yet, based on the error message you get. Do you get the same
> error with ActiveState Perl for Windows?
'make test' for the Expect module itself works fine. That test.pl is where I
got a snip of sample code to start with.
> I can't reproduce the error, either with FreeBSD or cygwin (I assume I
> have version 1.3.12) with perl-5.8.0 + Tk 800.024 on W2K.
>
> Regards,
> Slave
Yup. I'm running Tk 804, the development release, per a recent thread.
I forgot to try ActiveState - I will soon. But www.cygwin.com's already a
prerequesite for the project and I didn't care to confuse things.
--
Phlip
http://flea.sourceforge.net
-- Just think: Four billion people in the
world have never received Spam... --
------------------------------
Date: Tue, 18 Feb 2003 14:40:31 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: use DBI;
Message-Id: <zBr4a.17258$0L3.6483802@news2.news.adelphia.net>
"Helgi Briem" <helgi@decode.is> wrote in message
news:3e523a9b.957778142@news.cis.dfn.de...
<SNIP>
> On 18 Feb 2003 05:23:57 -0800,
> the_game_is_never_over@yahoo.co.uk (g) wrote:
>
> That last exit is completely unnecessary. Where does
> it come from? I keep seeing this sort of thing in
> cargo cult code.
>
> >exit(0);
I am a severe newbie as well. When WOULD you use exit(0) ??
------------------------------
Date: 18 Feb 2003 09:43:33 -0500
From: clists@perrin.socsci.unc.edu (Andrew Perrin (CLists))
Subject: Re: use DBI;
Message-Id: <843cmlvecq.fsf@perrin.socsci.unc.edu>
helgi@decode.is (Helgi Briem) writes:
> On 18 Feb 2003 05:23:57 -0800,
> the_game_is_never_over@yahoo.co.uk (g) wrote:
>
> >Hi I'm very new to perl so be gentle, have wrote a script to connect
> >to a mysql database (see below) but I keep getting an error Can't
> >locate DBI.pm. Other perl non dbi scripts have work, so perl is
> >installed, does any1 know why this happens (i use perl 5.6)??
>
> This may be a stupid question, but have you installed
> mysql itself, the database interface module DBI and
> the database driver module DBD::Mysql ?
If the error is "Can't locate DBI.pm" it's not MySQL or the DBD, but
DBI itself. What happens with:
perldoc DBI
If you've installed DBI, it's installed wrong. If you haven't, then
install it.
http://www.perl.com/CPAN-local/modules/by-module/DBI/
ap
--
----------------------------------------------------------------------
Andrew J Perrin - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
clists@perrin.socsci.unc.edu * andrew_perrin (at) unc.edu
------------------------------
Date: Tue, 18 Feb 2003 15:10:25 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: use DBI;
Message-Id: <3e524b78.962094769@news.cis.dfn.de>
On Tue, 18 Feb 2003 14:40:31 GMT, "Bob X"
<bobx@linuxmail.org> wrote:
>> That last exit is completely unnecessary. Where does
>> it come from? I keep seeing this sort of thing in
>> cargo cult code.
>>
>> >exit(0);
>
>I am a severe newbie as well. When WOULD you use exit(0) ??
Almost never. I can't really think of a scenario
except for the one in the docs, perldoc -f exit.
I think it's primarily something left in for the C-people
who like that sort of thing.
I had a quick look through the Perl Cookbook
and couldn't find anything that wouldn't be
better handled with a die.
Maybe one of the *real* experts can give you a
legitimate use.
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: Tue, 18 Feb 2003 15:13:31 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: use DBI;
Message-Id: <3e524cf5.962476157@news.cis.dfn.de>
On 18 Feb 2003 09:43:33 -0500, clists@perrin.socsci.unc.edu
(Andrew Perrin (CLists)) wrote:
>> This may be a stupid question, but have you installed
>> mysql itself, the database interface module DBI and
>> the database driver module DBD::Mysql ?
>
>If the error is "Can't locate DBI.pm" it's not MySQL or the DBD, but
>DBI itself. What happens with:
Yes, but if the OP has installed none of the three things,
lacking DBI will cause the fatal error before getting to
the others.
Say the OP installs DBI.
He then gets an error saying Can't locate DBD::Mysql
and writes us again.
He then gets an error saying it can't find the Mysql
client.
I was trying to kill 3 flies with one blow, seeing
as chances are, if he hasn't installed DBI; he hasn't
installed one or both of the others.
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: 18 Feb 2003 18:13:58 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: use DBI;
Message-Id: <slrnb54tv6.263.abigail@alexandra.abigail.nl>
Helgi Briem (helgi@decode.is) wrote on MMMCDLVIII September MCMXCIII in
<URL:news:3e523a9b.957778142@news.cis.dfn.de>:
))
)) That last exit is completely unnecessary. Where does
)) it come from? I keep seeing this sort of thing in
)) cargo cult code.
))
)) >exit(0);
That has nothing to do with 'cargo cult'. Cargo cult programming is
about using constructs you don't understand, but which seem vital
to your program.
I doubt the 'exit(0)' was put there without knowing what the exit()
does. Nor does it mysteriously change the behaviour of the program.
Just because it isn't "necessary" doesn't make an exit() at the end
of the program cargo cult, just like using parens where not required,
or an $_ where not required make "cargo cult".
Abigail
--
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))
------------------------------
Date: Tue, 18 Feb 2003 15:33:10 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: use of exit() (was Re: use DBI;)
Message-Id: <Xns93266B5921D8Cdkwwashere@216.168.3.30>
Helgi Briem <helgi@decode.is> wrote on 18 Feb 2003:
> On Tue, 18 Feb 2003 14:40:31 GMT, "Bob X"
><bobx@linuxmail.org> wrote:
>
[attribution lost]
>>> >exit(0);
>>
>>I am a severe newbie as well. When WOULD you use exit(0) ??
>
[snip]
> Maybe one of the *real* experts can give you a
> legitimate use.
That's certainly not me. :-)
I've occasionally tossed in exit() as an explicit marker for the end
of the "main" part of a program. I usually put all my subroutines at
the bottom of the file. The exit() isn't necessary, and could just
as well be a comment. I use a comment now, but I still have a few
old programs where I used an explicit exit(). <shrug>
The only use I can think of offhand is where you want to exit in the
middle of a program, not because something went wrong, but because
that's just the path the input takes. Instead of writing convoluted
code to satisfy the purist idea of structured programming and have
the program always exits at the bottom, just stick in an exit().
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: 18 Feb 2003 11:17:55 -0700
From: Eric Schwartz <eric.schwartz@hp.com>
Subject: Re: Using Archive::Tar for in-memory tarfiles
Message-Id: <etosmulh2r0.fsf@wormtongue.emschwar>
Chris Lowth <dont@want.spam> writes:
> After a little bit of playing, it seems Archive::Tar has a bug in this area.
> You can overcome it like this (not slick, but it works!)
<snip code snippet>
That's functionally equivalent to using
$tar->add_data($file, $data)
which is what I ended up doing. It is annoying though. Perhaps I'll
submit a patch; it doesn't appear Archive::Tar has been maintained
much since its initial release.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Tue, 18 Feb 2003 16:32:52 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Using different hashes.
Message-Id: <b2tn9c$ef3$1@newshost.mot.com>
Hello people!
I have a subroutine that does the same thing 3 times, but for different
hashes, like this...
foreach my $key (keys %ping) {
$ping{$key}{value} = $entry{ping}{$key} -> get;
if ($ping{$key}{value} eq "") {
$ping{$key}{value} = $ping_default{$key}{value};
update_value("ping", $ping{$key}{value}, $key);
}
}
So, rather than copy out this code 3 times, replacing %ping with the names
of different hashes, can I do some kind of foreach loop?
I started along these lines, but soon realised I was getting into deep dog
doo...
foreach my %which (%ping, %ftp, %popul) {
if (%which == %ping) {my $which = "ping"}
if (%which == %ftp} {my $which = "ftp"}
if (%which == %popul) {my $which = "popul"}
$which{$key}{$value} = $entry{$which}{$key} -> get;
if ($which{$key}{value} eq "") {
$which{$key}{value} = ?????? HELP! :-)
Thanks.
R.
------------------------------
Date: Tue, 18 Feb 2003 17:40:43 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Using different hashes.
Message-Id: <Xns932680F94CD38dkwwashere@216.168.3.30>
Richard S Beckett <spikey-wan@bigfoot.com> wrote on 18 Feb 2003:
> Hello people!
>
> I have a subroutine that does the same thing 3 times, but for
> different hashes, like this...
>
> foreach my $key (keys %ping) {
> $ping{$key}{value} = $entry{ping}{$key} -> get;
> if ($ping{$key}{value} eq "") {
> $ping{$key}{value} = $ping_default{$key}{value};
> update_value("ping", $ping{$key}{value}, $key);
> }
> }
>
>
> So, rather than copy out this code 3 times, replacing %ping with
> the names of different hashes, can I do some kind of foreach loop?
Here's an example that might give you an idea. See also perlreftut
and perlref.
use strict;
use warnings;
my %h1 = ( a=>1, b=>2, c=>3 );
my %h2 = ( a=>4, b=>5, c=>6 );
my %h3 = ( a=>7, b=>8, c=>9 );
foreach my $hash ( \%h1, \%h2, \%h3 ) {
foreach my $key (sort keys %{$hash}) {
print $hash->{$key};
}
}
The output should be the digits 1 through 9.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Tue, 18 Feb 2003 11:35:51 -0600
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: Using different hashes.
Message-Id: <b2tqto$gph1@onews.collins.rockwell.com>
On 2/18/2003 10:32 AM, Richard S Beckett wrote:
>
> I have a subroutine that does the same thing 3 times, but for
> different hashes, like this...
>
> foreach my $key (keys %ping) {
> $ping{$key}{value} = $entry{ping}{$key} -> get;
> if ($ping{$key}{value} eq "") {
> $ping{$key}{value} = $ping_default{$key}{value};
> update_value("ping", $ping{$key}{value}, $key);
> }
> }
>
> So, rather than copy out this code 3 times, replacing %ping with the
> names of different hashes, can I do some kind of foreach loop?
Try this (UNTESTED!):
my %stuff = (
'ping' => {data => \%ping, default => \%ping_default},
'ftp' => {data => \%ftp, default => \%ftp_default},
'popul' => {data => \%popul, default => \%popul_default},
);
while (my ($name, $store) = each %stuff) {
foreach my $key (keys %{$store->{data}}) {
$store->{data}{$key}{value} = $entry{$name}{$key}->get();
if ($store->{data}{$key}{value} eq '') {
$store->{data}{$key}{value} = $store->{default}{$key}{value};
update_value($name, $store->{data}{$key}{value}, $key);
}
}
}
Really, though, your data structures are awkward. There's probably a
better way to organize your data that would make the code much cleaner.
-mjc
------------------------------
Date: Tue, 18 Feb 2003 18:57:42 GMT
From: joe dekk <no_email@none.abc>
Subject: Where is DB_File in redhat 8.0?
Message-Id: <3E528222.4090407@none.abc>
Hi
RedHat 8.0 comes with perl 5.8.0 but DB_File
is not there. But when I looked on cpan
it apparently is in perl 5.8.0 and I cannot
locate .tar.gz file for me install it. I
find DB_File.pm but I am not sure whether
it is appropriate it install that file
Any advice would be appreciated
Thanks in advance
------------------------------
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 4580
***************************************