[10844] in Perl-Users-Digest
Perl-Users Digest, Issue: 4445 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 17 06:07:17 1998
Date: Thu, 17 Dec 98 03:00:22 -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 Thu, 17 Dec 1998 Volume: 8 Number: 4445
Today's topics:
"Parse exceptions" using WIN32::ODBC <pgrob@ipass.net>
Re: ADODB Problems, final adjustment georgina1303@my-dejanews.com
Re: ANNOUNCE: CodeMagic Universal IDE for Win32 (Free P (Tad McClellan)
Re: arrays, multi-dimensional arrays, pointers and such <tchrist@mox.perl.com>
Re: arrays, multi-dimensional arrays, pointers and such dave@mag-sol.com
Re: ASP <matt@teamamiga.org_NOSPAM>
Re: binmode (Tad McClellan)
CGI.pm and fileupload <e.christensen@netjob.dk>
Compiling byteperl in v5.005_02 <betse@sfu.ca>
Re: Complicated sorting problem <ebohlman@netcom.com>
Re: Complicated sorting problem (Bart Lateur)
database access <howard@vortexweb.com>
Re: database access (Tim Cutts)
Re: Favourite Editor for NT Perl <lss@shaw.wave.ca.spamtrap>
Re: First German Perl Workshop 1.0 (J|rgen P|nter)
Re: First German Perl Workshop 1.0 birgitt@my-dejanews.com
How to call MATLAB from perl ? <Stefan.Mueller@ruhr-uni-bochum.de>
Re: Making the name of a var the contents of another <rick.delaney@home.com>
New module Net::RawIP <ksv@gw.al.lg.ua>
Re: querying/updating Access db in WinPerl? <lss@shaw.wave.ca.spamtrap>
question <blu@mtu.edu>
Re: recursive dir in perl <dsfamily@bangornews.infi.net>
Re: renaming an array with a number at the end <aqumsieh@matrox.com>
Re: school me on RE please (Tad McClellan)
Re: Searching through a 10MB file <uri@sysarch.com>
Re: STDIN works too well (Mark-Jason Dominus)
Re: Why doesn't setenv freeze my script (Tad McClellan)
Re: win-95 hangs with tkperl and pipe (Victor B Wagner)
Re: Writing Perl with Notepad <shameluss plug> (Bart Lateur)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 17 Dec 1998 08:16:10 GMT
From: Peter Robbins <pgrob@ipass.net>
Subject: "Parse exceptions" using WIN32::ODBC
Message-Id: <3678BB7E.DECA00E0@ipass.net>
Howdy. I am a novice Perl programmer so spare the technicalities,
but
I need to access an ODBC database source name on an NT 4.0 server
and I cannot for the life of me implement the use win32::odbc, etc... It
consistently gives back "parse exception" errors.
I tried to find some loose threads using dejanews search engine and
found some mention of the problem, but I most were written in German.
Does anyone know of such an error attempting to use the ODBC
module at www.roth.net??? I have double checked where the .pm
etc.. files need to be. I followed the direction exactly, but to no
avail.
I think it finds it, but screws up somewhere in the interpreting the
API. It doesnt even matter if I use any methods from the api. I
do not even have to connect and open a source, it is just in typing
in the USE Win32::odbc; It does not like this at all!
Any help would be, well... helpful
Peter Robbins
------------------------------
Date: Thu, 17 Dec 1998 10:36:03 GMT
From: georgina1303@my-dejanews.com
Subject: Re: ADODB Problems, final adjustment
Message-Id: <75amqj$bhr$1@nnrp1.dejanews.com>
Hello,
I tried the different versions of your example but it does not work;
I get the error message
Can't locate object method "createobject via package "ole".
I changed
$Cn = CreateObject OLE 'ADODB.Connection';
to
$Cn = CreateObject Win32::OLE 'ADODB.Connection';
then I get the message:
unable to create ADO connection object.
My problem might be caused here:
# DSN Connection
$dbconnection = "DSN=MyData;Uid=my;Pwd=password;";
# DSNless Connection
#$dbconnection = 'DBQ=D:\SubDir\MyData.mdb;Driver={Microsoft Access Driver
(*.mdb)};Uid=sa;Pwd=;';
I never worked with databases. What is the difference between DSN=MyData and
DBQ=D:\SubDir\MyData.mdb? Do I have to change the words Driver={Microsoft
Access Driver (*.mdb)}
I had similar problems with other examples. In each case I am not able to open
the database.
I read the faq and everything I could find but I got no answers.
please help me,
thanks in advance
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 16 Dec 1998 23:05:11 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: ANNOUNCE: CodeMagic Universal IDE for Win32 (Free Perl IDE)
Message-Id: <7e3a57.94l.ln@magna.metronet.com>
[
There is nothing about modules in here. Followups trimmed.
... uhh there is precious little about Perl in it either,
but I can't trim them all...
]
Steven Morlock (newspost@morlock.net) wrote:
: I think you should give David a break.
(but it doesn't really matter. spammers don't read the
newsgroups they spam, so he never saw Clay's followup...
)
: I'm sure he has learned his lesson on the Job SPAM.
Which wasn't classical spam, just routine Internet abuse.
Now this week he is going to learn his lesson about classical spam?
How much of other people's resources will he spend learning
_next_ week's lesson?
Internet abusers are evil.
David (or Pete) is an Internet abuser.
David (or Pete) is evil.
You build your reputation and then you live with what
you have built...
: Clay Irving wrote in message <755sjl$f2c@panix.com>...
: >In <754c55$kt$1@nnrp1.dejanews.com> pete@davesworld.net writes:
: >
: >>ANNOUNCE: CodeMagic Universal IDE for Win32
: >>Win32 Based FREE IDE for Perl, TclTk, Java, C, Python
: >>Beta Release 1 (15 Dec, 1998)
: >
: >>NEVER PAY FOR FREE SOFTWARE!
: >>NEVER PAY FOR PERL SOFTWARE WHEN ALL YOU WANT IS FREE!
: >>NEVER PAY FOR PROPRIETARY PERL SOFTWARE!
: >
: >WARNING!! WARNING!
: >
: >"pete@davesworld.net" is the same little snot who spammed posters in the
: >Perl newsgroups with a sob story about his resume last week -- This week
: >it's "FREE! FREE! SOFTWARE!" posted individually to each newsgroup
: >instead of cross-posting...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Dec 1998 05:45:05 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: arrays, multi-dimensional arrays, pointers and such
Message-Id: <75a5p1$840$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, tabo <cswfrank@rica.net> writes:
:it there something that kinda resembles a pointer in perl?
man perlref
man perllol
man perldsc
--tom
--
"All things are proceeding rapidly to their contusion." --Larry Wall
------------------------------
Date: Thu, 17 Dec 1998 10:39:23 GMT
From: dave@mag-sol.com
Subject: Re: arrays, multi-dimensional arrays, pointers and such
Message-Id: <75an0r$bqm$1@nnrp1.dejanews.com>
In article <367802F9.850F00CA@rica.net>,
tabo <cswfrank@rica.net> wrote:
> it there something that kinda resembles a pointer in perl? if there
> are, does anyone know how its used?
Yes, they are called references. Many people here know how to use them quite
adequately.
> anyway, back to the jest of this post. i am trying to write a cgi
> script file that is to automatically generate a table based on the
> directories present and the files located in that directory. is there
> anyway to implement that? what i had in mind was to create a files
> list, an array and a couple of lists. the array would be used to hold
> the names of the lists that are available. the lists would kinda
> contain the equivilent of java applet params, which just tells my script
> file where the info will go in the table. the main jest is to have the
> web admin and any user that uploads files, to only modify the files list
> and thats it. so it kinda looks like this
>
> %doc1 = (
> "title", "docuements table"
> "wp5", "word perfect 5 document"
> );
>
> %doc2 = (
> "title", "documents table"
> "wp6", "word perfect 5 documents"
> );
>
> @docTypes(??????????????);
> this is where i am stuck at. i want to have a generic variable that
> will hold a reference to one of the lists.
> @docTypes(ref_to_doc1, ref_to_doc2)
> $temp = @docType[0];
> print "$temp{title}\n";
> that hopefull will print out "documents table". i know that i could do
> it with the individual names of the lists, but i the problem is that if
> i do that, when i add in new documentation i would have to manaully
> modify the codes again. the whole jest is not to do that. so is there
> any way that could be accomplished? i know i could do it in c or
> c++(pointers, and multi-dimensional arrays), but programming in c or c++
> for a cgi script is kinda long and tedious and just a plain pain in the
> ass.
Take a look at perldoc perlref and perldoc perldsc. These will answer all of
your questions.
> please reply to cswfrank@rica.net or tabo@cstone.net
> any help would be greatly appreciated. thanx
If you ask here, you should be prepared to look for the answer here.
hth,
Dave...
--
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 17 Dec 1998 09:15:42 +0000
From: Matt Sergeant <matt@teamamiga.org_NOSPAM>
Subject: Re: ASP
Message-Id: <3678CBBE.B7CB3D0E@teamamiga.org_NOSPAM>
Don Fykes wrote:
>
> I need to have a perl script fire an ASP.
>
> open(MAIL,"|$mailprog -t");
>
> where $mailprog would be mail.asp
>
> Can this be done?
No. If it's not perl, change it to a wscript program and run it as "|
wscript $mailprog", otherwise, run it as normal perl.
--
<Matt email="matt@teamamiga.org" />
| Fastnet Software Ltd | Perl in Active Server Pages |
| Perl Consultancy, Web Development | Database Design | XML |
| http://come.to/fastnet | Information Consolidation |
------------------------------
Date: Wed, 16 Dec 1998 23:13:36 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: binmode
Message-Id: <0u3a57.94l.ln@magna.metronet.com>
Bart Lateur (bart.lateur@skynet.be) wrote:
: Tad McClellan wrote:
: >You surely have already seen this, so please point out what part
: >is unclear so the docs can be fixed. Thank you.
: One word: "cookbook".
: If there's anything wrong with the docs, it's the lack of very simple
: examples for newbies. Just to get started.
This has crossed my mind with more frequency of late.
Maybe we should have a swFAQ (Small Words FAQ), that attempts
to answer for a non-programmer audience.
Many of the FAQ answers are geared toward experienced programmers
who, in the Perl world, seem to be an ever decreasing
proportion of the total prog^H^H^H^Husers.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 17 Dec 1998 10:36:56 +0100
From: Ernst Christensen <e.christensen@netjob.dk>
Subject: CGI.pm and fileupload
Message-Id: <3678D0B7.4B7B491D@netjob.dk>
Hi
I am trying to make a fileupload script with the CGI module.
But this module creates temporary files in a directory called tmp.
How can I change this to anothher by my choice, I have looked in the
docs, and Dejanews -> now(answers)
Quote from the docs:
CGI.pm creates temporary files in either the /usr/tmp or the /tmp
directory.
These temporary files have names like CGItemp125421, and should be
deleted automatically.
Ernst
------------------------------
Date: Thu, 17 Dec 1998 00:39:48 -0800
From: Betty Tse <betse@sfu.ca>
Subject: Compiling byteperl in v5.005_02
Message-Id: <3678C354.9F2CE5BA@sfu.ca>
I downloaded the latest Perl source and compiled it. No problem there.
I compiled a Perl file into bytecode using the "Bytecode" module
provided.
Now to run the bytecode, I need the "byteperl" program. This "byteperl"
does
not get make by default.
The problem is when compiling byteperl (using gcc), it reports a list of
undefined symbols. But, these symbols exists in "libperl.a" which also
exists. I tried including libperl.a by means of the -L or -l options.
I also tried
to include the path of libperl.a in LD_LIBRARY_PATH. None of them
worked.
??? Any help would be very much appreciated.
Betty
------------------------------
Date: Thu, 17 Dec 1998 10:32:18 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Complicated sorting problem
Message-Id: <ebohlmanF43uLu.oH@netcom.com>
Uri Guttman <uri@sysarch.com> wrote:
: have the worse the sort if you do all the work in the compare. short
: data sets don't count as they emphasize the conversion work over the
: compare work. this is basic sort theory and there has been volumes
: written on it.
I think a lot of us are guilty of forgetting this when we post benchmarks;
we compare a bunch of routines all accessing the same data set multiple
time, but we don't redo the comparison on a different-sized data set.
This can give misleading results, especially if the data sets are small;
if you were to compare the time taken to do 10,000 bubble sorts of a
5-element array with the time taken to do 10,000 quicksorts of the same
array, the bubble sort would probably come out better; an N^2+C1
algorithm can outperform an N*logN+C2 algorithm if the run times are
dominated by the C's (as they won't be in Real Life, but can be in
quickly slapped-together benchmarks).
IMHO it would be a good idea to post two sets of benchmarks, with the
second using twice as much data as the first. Behavior of run time when
doubling N can give a good approximation to an algorithm's time
complexity; if a linear algorithm takes a minute to process N items, it
will take 2 minutes to process 2N items. An NlogN algorithm will take a
little over 2 minutes, a quadratic algorithm will take 4 minutes, and an
exponential-time algorithm will take an hour(!).
------------------------------
Date: Thu, 17 Dec 1998 10:31:27 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Complicated sorting problem
Message-Id: <3678da3a.9515536@news.skynet.be>
Tim Gim Yee wrote:
>Here's an example of the Orcish Maneuver to go along with Uri's
>explanation above. This one sorts files by date:
>
>my %age;
>@sorted = sort {
> ($age{$a} ||= -M $a) <=>
> ($age{$b} ||= -M $b)
>} @files;
>
>Pronounce ||= as 'or cache' (give me the file age 'or cache' an
>expensive calculation of it), and instead of calling it the 'or-cache
>method'... well, at least that's the way I think it goes.
Aha! Now I get it. Clever trick. That does indicate that Larry Rossler's
"Orcish manoeuver" isn't one at all.
>Newsgroups: comp.lang.perl.misc
>Subject: Re: Sorting problem: Is there a better way?
>Date: Sun, 13 Dec 1998 18:52:37 -0800
>Message-ID: <MPG.10de1d51f12e3aab989957@nntp.hpl.hp.com>
Also, note that this cache trick doesn't work if for some reason the RHS
returns a false value.
Damned. We're there again. See the current thread on 'counterintuitive
behavior of "shift'.
It's about time "we" make a new version of || (and && ?) that does
continue depending on the "definedness" of the left side result, instead
of the "true-ness" ("truth" doesn't feel right).
I propose the operators ||| (triple vertical bar), in line with the
tradition of "|" and "||".
Examples:
$cache{$a} |||= -M $a
$one = shift ||| 1;
It would keep the left side value value, if it is defined (even if
"false"). Otherwise, the right side is evaluated. Mmmm... *I* like it.
Bart.
------------------------------
Date: Thu, 17 Dec 1998 01:52:39 -0600
From: "Howard Dierking" <howard@vortexweb.com>
Subject: database access
Message-Id: <#QCdvIZK#GA.231@upnetnews05>
I've got someone who wants me to develop an interface between his Access
database (even though his web server is on UNIX/Apache) and the web. He
wants to do this through dilineated text. I have no trouble putting the
form into the text with Perl, but how in the world would I dump all this
into his database? Any ideas? suggestions? Thanks,
howard
------------------------------
Date: 17 Dec 1998 09:45:52 +0000 (GMT)
From: timc@chiark.greenend.org.uk (Tim Cutts)
Subject: Re: database access
Message-Id: <0eo*0sJNn@news.chiark.greenend.org.uk>
In article <#QCdvIZK#GA.231@upnetnews05>,
Howard Dierking <howard@vortexweb.com> wrote:
>I've got someone who wants me to develop an interface between his Access
>database (even though his web server is on UNIX/Apache) and the web. He
>wants to do this through dilineated text. I have no trouble putting the
>form into the text with Perl, but how in the world would I dump all this
>into his database? Any ideas? suggestions? Thanks,
DBI is probably what you want. There is an ODBC driver for it. I
have just started experimenting with talking to a Sybase database
using DBI, and it works quite well, especially for querying. However,
if you want to insert data in the database, its performance is poor,
since you can only do this one row at a time. This is a Bad Thing if
you have a lot of rows to enter (I typically have a couple of thousand
rows).
I got around this in Sybase by using the external program provided
with sybase called bcp (bulk copy) which takes a delimited file and
shoves the whole thing into a table in one go. I then use DBI to call
some stored procedures on the new table and then read the now
completed table.
Tim.
------------------------------
Date: Thu, 17 Dec 1998 10:41:19 GMT
From: "LSS" <lss@shaw.wave.ca.spamtrap>
Subject: Re: Favourite Editor for NT Perl
Message-Id: <jd5e2.14$yp4.78@news.rdc1.on.wave.home.com>
I use SlickEdit. It is cross platform and a commercial product (sometimes
that means it is of high quality). Emacs is great, SlickEdit is better.
------------------------------
Date: 17 Dec 1998 07:28:32 GMT
From: Juergen.Puenter@materna.de (J|rgen P|nter)
Subject: Re: First German Perl Workshop 1.0
Message-Id: <75abr0$hi4$3@penthesilea.Materna.DE>
In article <7596r6$3vu$1@nnrp1.dejanews.com>, birgitt@my-dejanews.com
says...
>
>In article <754026$954$1@black.news.nacamar.net>,
> "G.Richter" <richter@ecos.de> wrote:
>> (German version below)
>> ########################################
>>
>> German Perl Workshop 1.0
>
>This announcement was NOT made in de.comp.lang.perl, nor in clpm, nor in
>clp.announce. Just in clp.moderated.
>
>Is it worth wondering why ?
Perhaps because 90% of us would be banned from it from the
start.
Roughly translated from http://www.gmd.de/Events/Perl-WS99/ :
"Since this is a meeting meant for experience-exchange, noone
who has not written larger Perl-programs will be allowed to
participate..."
In short, Gurus only. No wonder considering that they have room
for only 40-70 participants and demand a little 'what I have done
with Perl'-speech from everyone.
Juergen Puenter
------------------------------
Date: Thu, 17 Dec 1998 09:52:41 GMT
From: birgitt@my-dejanews.com
Subject: Re: First German Perl Workshop 1.0
Message-Id: <75ak98$9m2$1@nnrp1.dejanews.com>
In article <75abr0$hi4$3@penthesilea.Materna.DE>,
Juergen.Puenter@materna.de (J|rgen P|nter) wrote:
> In article <7596r6$3vu$1@nnrp1.dejanews.com>, birgitt@my-dejanews.com
> says...
> >
> >In article <754026$954$1@black.news.nacamar.net>,
> > "G.Richter" <richter@ecos.de> wrote:
> >> (German version below)
> >> ########################################
> >>
> >> German Perl Workshop 1.0
> >
> >This announcement was NOT made in de.comp.lang.perl, nor in clpm, nor in
> >clp.announce. Just in clp.moderated.
> >
> >Is it worth wondering why ?
>
> Perhaps because 90% of us would be banned from it from the
> start.
>
> Roughly translated from http://www.gmd.de/Events/Perl-WS99/ :
> "Since this is a meeting meant for experience-exchange, noone
> who has not written larger Perl-programs will be allowed to
> participate..."
>
> In short, Gurus only. No wonder considering that they have room
> for only 40-70 participants and demand a little 'what I have done
> with Perl'-speech from everyone.
>
Yes, I read this, but didn't want to speak out publically what I thought about
it. Now you know. :-)
birgitt
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 17 Dec 1998 11:18:16 +0100
From: Stefan Mueller <Stefan.Mueller@ruhr-uni-bochum.de>
Subject: How to call MATLAB from perl ?
Message-Id: <3678DA68.6D65@ruhr-uni-bochum.de>
Hi out there!
I'm trying to call MATLAB from perl for win32. It's no
big deal to call matlab using the Win32::OLE package.
The problem there is that matlab will terminate after
perl is done.
I tried to open a matlab window before executing my
perl script, but OLE always opens up a second matlab window.
Is there a possibility to call the matlab ENGINE from perl
on a win32 system????
Any help appreciated.
Thanks in advance.
Stefan M.
--------------------------------------------
Dipl.-Ing. Stefan Mueller
Ruhr-University Bochum
AG f. num. Meth. i.d. Mechanik und
Simulationstechnik
Germany
--------------------------------------------
------------------------------
Date: Thu, 17 Dec 1998 05:01:03 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Making the name of a var the contents of another
Message-Id: <367891D2.30D38FBC@home.com>
[posted & mailed]
johngalt25@excite.com wrote:
>
> Is it possible to make the name of a new variable out of the contents
> (a string) of another?
Yes, but don't do that. Use a hash instead.
> This is what I have so far, which does not work, but should give the
> idea:
> $oldstrvar = 'newname';
>
> $"$oldstrvar" = 3;
${$oldstrvar} = 3 would work but again, don't do that.
Use a hash instead:
$hash{$name_from_file} = $value;
You don't want to miss out on hashes. They're Perl's best data type.
perldoc perldata
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Thu, 17 Dec 1998 09:52:49 +0200
From: "Sergey V. Kolychev" <ksv@gw.al.lg.ua>
Subject: New module Net::RawIP
Message-Id: <Pine.LNX.3.96.981217094017.27859A-100000@gw.al.lg.ua>
Good day.
I'm writing module for easy manipulating raw ip packets in perl
May be somebody find my work interesting.
Latest version 0.02a available from
http://www.ic.al.lg.ua/~ksv/Net-RawIP-0.02a.tar.gz
version 0.01 available from CPAN
Here is a two small examples
land.pl
----------
#!/usr/bin/perl
require 'getopts.pl';
use Net::RawIP;
Getopts('i:p:');
$a = new Net::RawIP;
die "Usage $0 -i <target> -p <target port>" unless ($opt_i && $opt_p);
$a->set({ ip => {saddr => $opt_i,
daddr => $opt_i
},
tcp=> {dest => $opt_p,
source => $opt_p,
psh => 1,
syn => 1}
});
$a->send(1,100);
---------
ping.pl
---------
#!/usr/bin/perl
use Net::RawIP qw(:pcap);
$a = new Net::RawIP ({icmp =>{}});
$a->set({ip => {saddr => 'hercules.amk.lan', # insert your site here !
daddr => $ARGV[0]},
icmp => {type => 8, id => $$}
});
$device = 'eth1'; # insert your device here !
$filt = 'ip proto \\icmp and dst host hercules.amk.lan';# insert your site here!
$size = 1500;
$tout = 30;
$pcap = $a->pcapinit($device,$filt,$size,$tout);
$i =0;
if(fork){
loop $pcap,-1,\&dmp,\@a;
}
else{
sleep 2;
for(;;){
$a->set({icmp => {sequence => $i,data => timem()}});
$a->send(1,1);
$i++
}
}
#############
sub dmp{
$a->bset(substr($_[2],14));
my @ar = $a->get({ip => [qw(ttl)], icmp=>[qw(sequence data)]});
printf("%u bytes from %s: icmp_seq=%u ttl=%u time=%5.1f ms\n",length($ar[2])+8,
,$ARGV[0],$ar[1],$ar[0],(timem()-$ar[2])*1000);
}
---------------
----------------------Alchevsk Linux User Group-----------------------
UNIX is user friendly. It's just selective who the friends are.
Linux is like wigwam - no windows, no gates, apache inside.
http://www.ic.al.lg.ua/~ksv | e-mail: ksv@gw.al.lg.ua
PGP key & Geekcode: finger ksv@gw.al.lg.ua
------------------------------
Date: Thu, 17 Dec 1998 10:29:03 GMT
From: "LSS" <lss@shaw.wave.ca.spamtrap>
Subject: Re: querying/updating Access db in WinPerl?
Message-Id: <P15e2.13$yp4.22@news.rdc1.on.wave.home.com>
# Here is a sample that should give you a good start. This approach uses
the new ADO services. You may need to install these first.
use OLE;
use Win32;
use Win32::File;
$dbconnection = "DSN=DNSDefinedName;Uid=name;Pwd=password;";
$Cn1;
$Cm1;
$Rs1;
StartDb();
# If the query fails, an empty recordset is returned.
while ( !$Rs1->EOF )
{
# Extract the row.
$fields = $Rs1->Fields;
# Count the columns.
$co = $fields->Count;
for ( $j=0; $j < $co; $j++ )
{
# Get the jth field.
$i = $fields->Item($j);
$n = $i->Name;
$v = $i->Value;
# Print its name and value.
print "$n: $v ";
}
print "\n";
# Advance to the next record.
$Rs1->MoveNext();
}
StopDb();
die "\n";
sub ReportFatalError
{
local($errmsg) = $_[0];
print "Error: $errmsg\n";
die "\n";
}
sub StartDb
{
if ( $dbconnection )
{
dbOpen($Cn1, $Cm1, $Rs1, $dbconnection);
$Cm1->{CommandText} = "SELECT * FROM SOMETHING";
$Rs1->Open($Cm1);
}
}
sub UpdateDb
{
my($ObjectName, $Comments);
if ( $dbconnection )
{
$ObjectName = $_[0];
$Comments = $_[1];
$Rs1->AddNew;
$Rs1->Fields(0)->{value} = $ObjectName;
$Rs1->Fields(1)->{value} = $Comments;
$Rs1->Update;
}
}
sub StopDb
{
if ( $dbconnection )
{
$Rs1->Close;
$Cn1->Close;
}
}
sub SetErrMsg
{
my($errmsg);
$errmsg = $_[0];
ReportFatalError($errmsg);
}
sub dbOpen
{
my($Cn, $Cm, $Rs, $Errors, $LoadName, $retval);
$LoadName = $_[3];
$retval = 0;
$Cn = CreateObject OLE "ADODB.Connection";
if ( $Cn )
{
$Cn->{ConnectionTimeout} = 15;
$Cn->{CommandTimeout} = 30;
$Cm = CreateObject OLE "ADODB.Command";
if ( $Cm )
{
$Rs = CreateObject OLE "ADODB.Recordset";
if ( $Rs )
{
$Cn->Open($LoadName, "", "");
$Errors = $Cn->Errors();
$retval = keys %$Errors;
if ( $retval )
{
$retval = 1;
foreach $error ( keys %$Errors )
{
if ( $error->{Number} != 0 )
{
$retval = 0;
}
}
if ( !$retval )
{
SetErrMsg("Unable to open ADO connection.");
}
}
else
{
$retval = 1;
}
if ( $retval )
{
$Cm->{ActiveConnection} = $Cn;
$Cm->{CommandType} = 1;
$Rs->{CursorType} = 1;
$Rs->{LockType} = 3;
$_[0] = $Cn;
$_[1] = $Cm;
$_[2] = $Rs;
}
}
else
{
SetErrMsg("Unable to create ADO recordset object.");
}
}
else
{
SetErrMsg("Unable to create ADO command object.");
}
}
else
{
SetErrMsg("Unable to create ADO connection object.");
}
return $retval;
}
------------------------------
Date: 17 Dec 1998 05:26:49 GMT
From: Bing Lu <blu@mtu.edu>
Subject: question
Message-Id: <75a4mp$ds3$1@campus1.mtu.edu>
hi, can any1 tell me how to modify file content w/ STDIN,e.g.
orig file a 1 2 aa ;want to modify a w/ STDIN aaa
output file aaa 1 2 aa, i'm kinda new to perl pls help
thx in adv blu@mtu.edu
------------------------------
Date: Thu, 17 Dec 1998 03:53:29 -0500
From: Bulls_Fan <dsfamily@bangornews.infi.net>
Subject: Re: recursive dir in perl
Message-Id: <3678C689.AABA5FDC@bangornews.infi.net>
Calle Dybedahl wrote:
>
> pser <pascal.serode@alcatel.fr> writes:
>
> > What I need, in fact, is just a script able to go down directories
> > , recursively, building a list of every file met.
>
> perldoc File::Find
> --
or you could just use this:
#######################################
# This function looks for all the files that can be edited and returns
an array of names.
# It takes one argument : what directory to start searching through
sub getAllFilenames{
local( $fod ) = $_[0]; # localize where to look
print "Current directory:\n$fod\n";
opendir( DIR , $fod ) or die "\nCan`t open directory, $fod \.\n"; #
open the directory or die
foreach $_ (readdir DIR ){ # for each file in this directory
if( -r $_ and -w $_ ){ # if it is readable and
writeable
if( -d $_ and $_ !~ /^\.{1,2}$/ ){ # if the current item is a
directory not named as '.' or '..'
getAllFilenames( "$fod\/$_" ); # go recursive
}elsif(-f $_ ){ # elsewise if it is a file
push( @files, "$fod\/$_" ); # put its name in @files
}
}
else{ # if $_ is not readable and
writeable
print "\'$fod\/$_\' not readable and writeable, moving on\.\n";
# say so
}
}
closedir( DIR ); # close the current directory
@files; # return the files met
}
# BTW, if you do actually use this please tell me `twould be the first
time someone else had used some of my code. HTH
------------------------------
Date: Wed, 16 Dec 1998 19:12:16 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: renaming an array with a number at the end
Message-Id: <x3ybtl38w4g.fsf@tigre.matrox.com>
chamlin@my-dejanews.com writes:
> @array0 = (0);
> @array1 = (0, 1);
> @array2 = (0, 1, 2);
>
> for ($i = 0; $i < 3; $i++)
> { $name = "array$i";
> print "@$name\n";
> }
>
>
> Tried it and it seems to work, though -w complains.
> Guess it can't ``see'' through the use of soft
> references . . . not surprising?
-w won't complain if you had been using strict (which is a good thing
to do .. ALWAYS).
Then, you will be forced to declare your variables before using them.
------------------------------
Date: Wed, 16 Dec 1998 22:50:29 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: school me on RE please
Message-Id: <li2a57.94l.ln@magna.metronet.com>
keystroke@bigfoot.com wrote:
: I have a multi line string - an html file. I would like to match from a
: '<TD>' tag to the next matching '</TD>' tag, easy.
: But the problems start when I try to match the '<TD>' tag pair that
: contains a certain string. I get a match from the very first '<TD>' tag
: of the file to the '</TD>' tag following the string.
: $HTML_FILE =~ s|<TD>(.*?STRING.*?)</TD>|<TD>whatever</TD>|im;
: I understand what is happening. The RE is matching the first '<TD>' to
: the string and to the next '</TD>'. But I thought that the '?'
: following a quantifier makes it be non-greedy.
It does.
But the regex engine will still try to make a _successful_ match.
If it has to match over some more </?TD>s in order to match,
then that is what it will do.
: Does that not work like
: I thought it should? I know that the RE engine searches left to right
: and this is the first match that it finds, but how do I do it?
$HTML_FILE =~ s|<TD>(.*?)</TD>|
# if
$1 =~ /STRING/ ?
# then
"<TD>whatever</TD>" : # change it
# else
"<TD>$1</TD>"; # leave it alone
|gise;
: I guess I could use some examples of how to match it correctly.
See above ;-)
: Do I have to start using the variables $` and $' ?
Heavens no!
I have never come across a situation where I had to use them.
: Also, I having difficulties understanding the /s and the /m differences.
: /m means multi-line strings where '.' will match a newline, and ^ and $
: work off of the newlines in the string, right?
Wrong.
: /s means treat it like a single line where '.' will not match a
: newline, and ^ and $ only work at the ends of the string, right?
/s and /m are not related. Separate them in your mind.
It is really quite simple:
/s makes . match a newline (so only use it when you _have_ a dot
in your regex, else it has no effect)
/m makes ^ and $ anchors match in the interior of the string, instead
of only at the beginning/end (so only use it when you _have_ anchors
in your regex, else it has no effect)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Dec 1998 00:21:04 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Searching through a 10MB file
Message-Id: <x77lvrpcn3.fsf@sysarch.com>
>>>>> "CMA" == Christian M Aranda <christian.aranda@iiginc.com> writes:
CMA> Here is a sample from the datafile I'm searching:
CMA> Start: INS09837
CMA> data
CMA> End: INS09837
CMA> Start: INS20989
CMA> data
CMA> End: INS20989
CMA> The data appears in no particular order, unfortunatly, so I can't just
CMA> continue searching from where I left off.
are you searching for multiple entries per pass? if so then you can read
all the search id's into a hash and see if record matches any hash
entry. this will be a major win and speedup. but it only works if you
are looking for many items during one exec of the program. i will assume
so in my comments below. in any case, searching for one will not be slow
and is just a simpler case.
also larry rosler made some cogent comments, i may cover them too and i
have some others as well.
CMA> Here is a code snippet where I am doing the work:
CMA> sub get_ddts_record
CMA> {
CMA> $status = open(DDTS_DATA, "$ddts_file");
CMA> &err_msg("fatal", "Unable to open data file", "open", $status) unless
CMA> ($status);
rarely do perl hackers save the status and make that into 2
statements. it reads easier if it is like this:
open(DDTS_DATA, "$ddts_file") ||
&err_msg("fatal", "Unable to open data file", "open", undef ) ;
CMA> $BGSBugId = $ddts_value{identifier};
i will assume that this hash contains all the bug ids you are looking
for. BTW my taste is to quote constant hash keys. others disagree.
CMA> $BugIdFound = 'FALSE';
CMA> $GetData = 'FALSE';
CMA> $Done = 'FALSE';
this is a waste. just use boolean integers in your code. in fact i will
rewrite it not to even need flags. of all languages perl is the least
likely to need loop flags due to its rich set of loop constructs. learn
them and use them.
CMA> $title = 'History';
CMA> $end_record = 'End:';
using variables to hold constants for regexes makes little sense. i will
delete this.
CMA> $split_text = 'Related-file:';
again, why use a variable for a constant string.
CMA> undef($record{comment_tab});
this is a constant entry in a hash. why not just use a simple scalar and
later if needed store it in the hash. that will save all those hash
lookups in the loop.
CMA> while (<DDTS_DATA>) {
CMA> chop($_);
use chomp. it is safer.
CMA> if (/^Start: $BGSBugId/) { $BugIdFound = 'TRUE'; }
now we have some fun. make an inner loop when we find a start record.
i don't know the exact format of a bug id start line but i will assume a
single token ending with whitespace or the newline
if ( /^Start: (.+)\s*/ ) {
now we are in a record. is it one we want?
if ( $1 eq $ddts_value{identifier} ) {
now we loop again until the title record
while (<DDTS_DATA>) {
last if /^History/ ;
}
now we loop again until the title record but we collect the records
$record = '' ;
while (<DDTS_DATA>) {
chomp($_);
push( @comments, $_ ) ;
last if /^End/ ;
}
CMA> if (/^$title/ && $BugIdFound eq 'TRUE') { $GetData = 'TRUE'; }
CMA> if (/^$end_record/ && $BugIdFound eq 'TRUE') { $GetData =
CMA> 'FALSE'; $Done = 'TRUE'; }
CMA> if ($GetData eq 'TRUE' && $Done eq 'FALSE') {
CMA> $record{comment_tab} .= "$_\n";
CMA> }
CMA> }
all that flags stuff with the slow eq's are gone.
this end the if record is one we want
}
this end the if record start
}
ends outer while
}
CMA> @comments = split(/$split_text/,$record{comment_tab});
this makes little sense. why concatentate the records and then split
them? why not just push them onto an array like i did. it is not clear
the exact format of the records and how you are joining and splitting
but the idea is still valid.
the code above should blaze through your file in a reasonable time
(depending on cpu, under a minute is probable but who knows what you
have). it is much leaner and meaner than your code.
hth,
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 17 Dec 1998 01:34:34 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: STDIN works too well
Message-Id: <75a8lq$khv$1@monet.op.net>
In article <913819358.597458@elaine.drink.com>,
Alan Barclay <gorilla@elaine.drink.com> wrote:
>>>print "input is tty\n" if($stdin & 020000);
In article <758is2$3hn$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> wrote:
>>Hey, that's no good. It says that /dev/null is a tty, which it isn't.
In article <913830717.624223@elaine.drink.com>,
Alan Barclay <gorilla@elaine.drink.com> wrote:
>Well, it's saying actually it's a character special device,
Wow, that's creepy. Just like in `1984'.
It's saing it's a character special device.
It has always said it was a character special device.
>>>print "input is tty\n" if($stdin & 020000);
Gosh, to me it looks like it says `input is a tty'... AAAAGH! Not the
rats! No, no, anything but that! Auuuuuughhhhhhh!!!!!!!
It's saying it's a character special device.
It has always said it was a character special device.
>>>print "input is a character special device\n" if($stdin & 020000);
Yes! It does say it is a character special device. It has always
said it was a character special device.
War is Peace! Ignorance is Strength!
I love Big Brother.
------------------------------
Date: Wed, 16 Dec 1998 23:15:51 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Why doesn't setenv freeze my script
Message-Id: <724a57.94l.ln@magna.metronet.com>
Tommy1452 (tommy1452@aol.com) wrote:
: The following command:
: setenv HTTP_USER_AGENT "Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)";
: stops my script dead in it's tracks, how come?
You seem to have wandered into the Perl newsgroup by mistake.
There is no Perl in your question...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Dec 1998 08:50:43 GMT
From: vitus@brass.fe.msk.ru (Victor B Wagner)
Subject: Re: win-95 hangs with tkperl and pipe
Message-Id: <75agl3$9st$4@zware.space.ru>
J|rgen Ibelgaufts (ibelgaufts@gfc-net.de) wrote:
: hi,
: i developed a tiny program with tkperl on win-nt which has a listbox and issues
: some system commands (say, "dir" for example) piping the result back into a
: listbox.
: It works fine on win-nt with the listbox showing the result of the system command,
: even if tried several times within the same program, but on win95 the program
: hangs after having executed the system command and showing its results in the
: listbox.
: if i try to kill the process, it will be killed but its window cannot be removed
: from the desktop so win95 will have to be restarted.
: does anybody have any experiences with such problems ?
I'm afraid that there are few people using perl-tk on windows 95.
Go to comp.lang.tcl and you'll see much more horror stories about
Tk application on windows 95. Especially, interacting with system
programs. Really, Win95 have no pipes. It just emulates them using
temporary files, as dos is always do. Wait couple of years and your
problem would go away, becouse Win 2000 is NT-based.
Only solution I can see is to build perl with Cygnus GCC and carry 700K
cygnus emulation layer around.
: thanks in advance
: juergen ibelgaufts
--
--------------------------------------------------
Victor Wagner vitus@ice.ru
Programmer Office:7-(095)-964-0380
Institute for Commerce Home: 7-(095)-135-46-61
Engineering http://www.ice.ru/~vitus
------------------------------
Date: Thu, 17 Dec 1998 10:31:23 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Writing Perl with Notepad <shameluss plug>
Message-Id: <367cca97.5567033@news.skynet.be>
JT wrote:
>Try Textpad. It is the ultimate windows text editor, everything else
>is junk.
>http://www.textpad.com/
>It's so good that it's scary, I won't even try to explain.
It doesn't load files of over 32k lines.
I sometimes need that, e.g to look at a DXF file.
Bart.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4445
**************************************