[23758] in Perl-Users-Digest
Perl-Users Digest, Issue: 5962 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 20 09:05:34 2003
Date: Sat, 20 Dec 2003 06:05:05 -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 Sat, 20 Dec 2003 Volume: 10 Number: 5962
Today's topics:
Re: [HELP] code modification <paul.sellis@alussinan.org>
Re: Adding Header to a database/csv <kuujinbo@hotmail.com>
Re: Adding Header to a database/csv <paul@not.a.chance.ie>
Re: Is mysql.pm part of DBI? <pilsl_usenet@goldfisch.at>
ModuleA calls ModuleB which calls ModuleA (Midas)
Re: ModuleA calls ModuleB which calls ModuleA <calle@cyberpomo.com>
Re: perl golf techniques <krahnj@acm.org>
Re: Please critique this short script that scans a log <perl@my-header.org>
Re: Problem with DBI MySQL (UPDATE command) (Steve)
Re: ticks and FreeBSD <jwillmore@remove.adelphia.net>
Re: When closing DOS window... <bart.lateur@pandora.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 Dec 2003 10:56:06 +0100
From: Paul Sellis <paul.sellis@alussinan.org>
Subject: Re: [HELP] code modification
Message-Id: <paul.sellis-B3911D.10560620122003@news3-1.free.fr>
In article (Dans l'article)
<%EKEb.22637$CK3.2273293@news20.bellglobal.com>,
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote (écrivait) :
> > But if this script send mails, unfortunatly it doesn't also write to a
> > text file the form datas.
> There is an option to log the form data to a file in the TFMail script. Is
> that not good enough?
Well I must say that I am quite confused with all these text files to be
configured. Perhaps I'd prefer one Perl file with hidden form fields.
Yes I am a newbieŠ
Anyway, my other problem is that I must include this form in a Flash
fileŠ So I can't redirect to an html fileŠ
I have found "Flash Form Submission With CGI".
It is quite evident and simple. So it was the first time I made a
working form with Flash !
€ I tried to upgrade the ezformml.cgi with Version 1.3 because there
are tests to prevent script from being used by spammers. Unfortunatly I
can't make it work. Perhaps because of the Redirect code wrongly deleted
by myself ?
€ the second thing is that I still need to have the form datas writen in
a text file. And I don't know how I can do itŠ
The original 3rd Coast Technologies code can be found there :
http://3rdcoast.com/free_scripts.html
I don't know if you recommand it to me Š
------------------------------
Date: Sat, 20 Dec 2003 19:20:50 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Adding Header to a database/csv
Message-Id: <bs181s$7jl$1@pin3.tky.plala.or.jp>
Public Interest wrote:
> i have something like:
> aaa, 11.11, 123456
> bbb, 22.22, 122432
> in a csv file
>
> but i want it to look like
> stock symbol, price, volume,
> aaa, 11.11, 123456
> bbb, 22.22, 122432
>
> can i access to the csv file without reading the first line?
One way is to use the special $. variable. From the perlvar documentation:
"When a line is read from a filehandle (via readline() or <>), or when
tell() or seek() is called on it, $. becomes an alias to the line
counter for that filehandle."
HTH - keith
------------------------------
Date: Sat, 20 Dec 2003 12:05:59 -0000
From: Paul <paul@not.a.chance.ie>
Subject: Re: Adding Header to a database/csv
Message-Id: <MPG.1a4e4b828efdc7398984d@news1.eircom.net>
test@test.com says...
> i have something like:
> aaa, 11.11, 123456
> bbb, 22.22, 122432
> in a csv file
> but i want it to look like
> stock symbol, price, volume,
> aaa, 11.11, 123456
> bbb, 22.22, 122432
> can i access to the csv file without reading the first line?
And this has what, exactly, to do with databases?
Paul...
--
plinehan x__AT__x yahoo x__DOT__x com
C++ Builder 5 SP1, Interbase 6.0.1.6 IBX 5.04 W2K Pro
Please do not top-post.
------------------------------
Date: Sat, 20 Dec 2003 12:37:40 +0100
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: Re: Is mysql.pm part of DBI?
Message-Id: <3fe435af$1@e-post.inode.at>
Social Liberal-Fiscal Conservative wrote:
>
> How do I know I have DBD::mysql installed? If I have DBI, do I have to
> install DBD::mysql?
>
Think of DBI as the global module to connect to various databases.
Additionally you need a DBD::xxx-module to connect to database-system xxx.
This DBD-module works as layer between the DBI and the database.
Good thing with it: you can write a program using only DBI-proposed
commands and easily switch to a different database later by just exchanging
the undelying DBD-Module.
(Unfortunately its not that easy, cause each DBD-module has some
specialities as have all databasesystems)
to make it short
i) install DBI
ii) install DBD::mysql
thats all you need.
To check if you have the latter installed, you just try to access a
mysql-database (as proposed in DBI and DBD::mysql)
use DBI;
...
....DBI->connect('dbi:mysql:dbname=mydb'....
for a faster check, just try to locate mysql.pm on your system. mysql.pm is
the actual modulefile for DBD::mysql and it should be stored in a path like
<whatever but it should have perl in it>/DBD/mysql.pm
best,
peter
--
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: Sat, 20 Dec 2003 11:12:25 GMT
From: buffysmith02@hotmail.nospam.com (Midas)
Subject: ModuleA calls ModuleB which calls ModuleA
Message-Id: <3fe42b14.122598981@news.iprimus.ca>
Hello everyone,
I'm trying to have code in moduleA ... call
code in moduleB ... which in turn calls code
in moduleA. I don't want moduleB to have
hardcoded calls to moduleA. I would like
moduleB code to call back whichever module
has called it.
I've searched through several books and have
spent a couple of hours searching the web.
I'm running Perl v5.6.1 for
MSWin32-x86-multi-thread on Windows 95.
Can anyone tell me whether what I'd like to
do is possible? How I could do it?
Thanks for reading.
Midas
------------------------------
Date: Sat, 20 Dec 2003 12:34:35 +0100
From: Calle Dybedahl <calle@cyberpomo.com>
Subject: Re: ModuleA calls ModuleB which calls ModuleA
Message-Id: <86d6aj67uc.fsf@ulthar.bisexualmenace.org>
>>>>> "Midas" == Midas <buffysmith02@hotmail.nospam.com> writes:
> Can anyone tell me whether what I'd like to
> do is possible? How I could do it?
perldoc -f caller
--
Calle Dybedahl <calle@lysator.liu.se>
"I'd definitely like to see more rubber-clad literature in future."
-- Penny Dreadful
------------------------------
Date: Sat, 20 Dec 2003 10:50:39 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: perl golf techniques
Message-Id: <3FE4296F.C1CF4CAB@acm.org>
Scott wrote:
>
> tiltonj@erols.com (Jay Tilton) wrote in message news:<3fe249f3.4299694@news.erols.com>...
> > Some good starting points:
> > http://perlgolf.sourceforge.net/
> > http://perlgolf.org/
> >
> > There are details of a number of past competitions on those sites,
> > including piles of code and discussions of players' inspirations and
> > algorithms.
>
> I'm looking for the players inspirations and discussions... In the
> pages that I see, I see the code and maybe a one line comment, but not
> really any discussion on it... Since I am new to it, I'd love to get
> more information to see what is going on...
Have a look at the perl.golf mailing list:
http://www.nntp.perl.org/group/perl.golf
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 17 Dec 2003 20:23:28 +0100
From: Matija Papec <perl@my-header.org>
Subject: Re: Please critique this short script that scans a log file
Message-Id: <f271uvciq2pdmomvkhfo96bglo4oi08ht5@4ax.com>
X-Ftn-To: J.W.
J.W. <jwngaa@att.net> wrote:
>but avoided it because of NFA regex engine
>-- the timestamp regex could've been simplified to /(...) (...) (..)
>(..):(..):(..) (....)/ but I deliberately wanted to use character
>classes to only extract valid date strings
>
>-----
>
>#!/usr/bin/perl
>#
># Read db2uext2.log.NODE0000 and calculate archive copy
># durations (in seconds) between "Time Started" and
># "Time Completed"
>
>use strict;
Everything ok here. :)
>use Time::Local;
>use Time::Local 'timegm_nocheck';
You only need second line, it does same thing as first, but imports just
timegm_nocheck sub to your namespace.
>my $regex_ctime;
>my %MonthIndex;
>my $ts1;
>my $ts2;
>my $ts1_started;
>my $ts2_completed;
>my $rc;
This is fine, but you can choose to define these variables later when you're
initializing them.
># $1 $2 $3 $4 $5 $6 $7
>#Time Started: Mon Dec 17 13:47:42 2001
>#Time Started: Wed Jul 23 17:35:35 2003 (20030723173535)
>
>$regex_ctime = qr/ (Sun|Mon|Tue|Wed|Thu|Fri|Sat)
>(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([ |0-3][0-9])
>([0-2][0-9]):([0-5][0-9]):([0-5][0-9]) ([0-9][0-9][0-9][0-9])
[0-9] is digit class so you can,
(\d\d\d\d)
or just,
(\d{4}) #match \d 4 times
>/o;
Afaik, /o part isn't needed here as you're compiling regex for later use.
"o" switch is usually used on plain regex when actual matching is being
performed.
>%MonthIndex = (
> "Jan", 0,
> "Feb", 1,
> "Mar", 2,
You could use fancy commas when defining a hash if you think it looks
prettier,
"Jan" => 0,
or just,
Jan => 0,
as hash keys are auto quoted (except v-strings, so you'll have to quote keys
beginning with "v" anyway).
>while (<>) {
Explicity is sometimes more preferred, you'll decide when to use,
while (my $line = <>) {
> # chomp; # not needed for this type of processing
> if (/^Time Started:/) {
> if ($_ =~ $regex_ctime) {
if (/$regex_ctime/) {
will also work.
> if (/^RC\s+:\s+(\d+)/) { # Return Code
Since every line can match only once(?), you can use elsif's here to avoid
unnecessary matches.
IMO, you're fine, if you want good advices on solving practical problems
take a look at Perl Cookbook.
--
Matija
------------------------------
Date: 20 Dec 2003 02:54:34 -0800
From: ineverlookatthis@yahoo.com (Steve)
Subject: Re: Problem with DBI MySQL (UPDATE command)
Message-Id: <f0d57f86.0312200254.17bee9fa@posting.google.com>
pj_sammie@hotmail.com (Brad) wrote in message news:<2abd2946.0312191426.1a7e7347@posting.google.com>...
>
> Is there a way to grab a row into an array where each column is its
> own param (i.e. array[0] = column 1, array[1] = coulmn2, etc.)? I am
> only grabbing 1 row when opening the MySQL.
>
> Thanks again,
> Brad
Of course there is. There are also many other ways of grabbing the
data; I usually end up using hashref which allows you to step through
selected columns in a way that doesn't depend on the underlying table
structure or the order you grabbed them in. That way you can add or
delete cols without breaking your program.
I too went through a steep learning curve when starting this stuff.
When you find yourself hard-coding anything (col name, table name, etc
etc) into an SQL statement, stop and think again. It almost always
better to have these as variables clearly declared at the top of your
program. eg the cols I want to display are usually predeclared as an
array of col names. Then I can just step through the list using them
as keys for hashref. To change the order of appearance in my output or
to add or remove a col is then a few seconds work.
I would reccommend reading the manual!
Steve
------------------------------
Date: Sat, 20 Dec 2003 13:56:54 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: ticks and FreeBSD
Message-Id: <20031220085653.7ba08af3.jwillmore@remove.adelphia.net>
On Fri, 19 Dec 2003 19:20:13 GMT
Erik Tank <jundy@jundy.com> wrote:
> On Fri, 19 Dec 2003 12:35:44 GMT, James Willmore
> <jwillmore@remove.adelphia.net> wrote:
> >On Fri, 19 Dec 2003 07:04:11 GMT
> >Erik Tank <jundy@jundy.com> wrote:
<snip>
> I did read the docs. I went back to CPAN and read the README where
> I found this:
> This is BETA software; it seems to work, but use at your own risk :)
Beta, to me, is a relative term. And others, like myself, don't
believe something is every tested enough. But, looking over the
README, there is a rather long list of people who have contributed to
the module's development. One, I know for a fact, is deeply involved
in Tk module development and is a stickler for writing good code
that is reliable. So, I'd take that note with a grain of salt :-)
> So looks like it doesn't work on FreeBSD 4.9 or 5.0 because I
> started with the code examples in the man page and they don't work.
> I will continue looking for other solutions.
And have you tried the one I posted? Does it work?
To venture off this path for a moment ... (or, now for something
completely different :-) )
if you're having trouble with making the version you wrote (in the OP)
work on both Linux and FreeBSD, you could use the $^O variable to
handle the different OS system commands. In this way, you can add
some intelligence to your script and reduce some of the maintainence
of the script. In other words, if the issue is the 'ps' command, you
could use the $^O command to determine the best switches to feed 'ps'
to produce the appropriate output based upon the OS. If the output is
uniform, you can then fashion one routine to parse the output and do
whatever you need to do next (which is why I suggested the module to
begin with :-) )
OTOH, you could contact the author of Proc::ProcessTable and see if
you could contribute - since you have a real need for this module to
work :-)
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Certainly there are things in life that money can't buy, but it's
very funny-- Did you ever try buying them without money? --
Ogden Nash
------------------------------
Date: Sat, 20 Dec 2003 11:29:05 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: When closing DOS window...
Message-Id: <95a8uvg9cuv1fr3pvrf0npd6l65c9add6h@4ax.com>
R Solberg wrote:
>I would like to learn more about wperl.exe. Does anyone know of a man
>page or something else I can read about wperl.exe?
You can start by checking out how it got created.
perldoc exetype
online available on the URL
<http://aspn.activestate.com/ASPN/docs/ActivePerl/bin/exetype.html>
and therefore, lookup in the Windows API documentation what this means.
I found this:
<http://msdn.microsoft.com/library/en-us/vccore/html/_core_.2f.subsystem.asp>
<http://msdn.microsoft.com/library/en-us/vccore/html/_core_.2f.entry.asp>
In practise, it turns out that a WINDOWS program creates no window by
default, and a CONSOLE program starts with a "DOS" console window. You
can still create a console window from a normal Windows program using
the AllocConsole API call. Full documentation is here:
<http://msdn.microsoft.com/library/en-us/dllproc/base/creation_of_a_console.asp>
Note: ONE console per program max.
BTW while investigating this, I found this page:
<http://jenda.mydot.net/perl/GUIscripts.txt>
--
Bart.
------------------------------
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 5962
***************************************