[13279] in Perl-Users-Digest
Perl-Users Digest, Issue: 689 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 31 17:07:31 1999
Date: Tue, 31 Aug 1999 14:05:10 -0700 (PDT)
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, 31 Aug 1999 Volume: 9 Number: 689
Today's topics:
<DATA> in a module(package) (Lack Mr G M)
active perl 5.005 or standard perl 5.004 <paulsxxx@cascadelinear.com>
Re: active perl 5.005 or standard perl 5.004 (Eric Bohlman)
Re: active perl 5.005 or standard perl 5.004 (Larry Rosler)
ANNOUNCE: Champaign-Urbana Perl Mongers Meeting Wed Sep (Daniel S. Lewart)
ATTENTION EXPERIENCED PROGRAMMERS ONLY!!! <rdfletch@home.com>
Re: Building perl <elaine@chaos.wustl.edu>
Re: Case insensitive SQL query mrbog@my-deja.com
Re: Case insensitive SQL query <makkulka@cisco.com>
cgi error on apache <p.meidl@klivv.oeaw.ac.at>
Date / time problem (resolution) <news@news.news>
Re: Date / time problem (resolution) (Larry Rosler)
EVAL ?? tvn007@my-deja.com
Re: EVAL ?? (Larry Rosler)
gethosybyaddr <farber@admin.f-tech.net>
how to open a file in the internet? <zhuang@ic.sunysb.edu>
Re: how to open a file in the internet? <makkulka@cisco.com>
How to rewind DATA filehandle? <rhgv90@email.sps.mot.com>
Re: How to rewind DATA filehandle? <garethr@cre.canon.co.uk>
Re: Insecure dependency in open while running with -T s <makkulka@cisco.com>
Re: Insecure dependency in open while running with -T s (Larry Rosler)
Re: LWP::Simple GET ??? <makkulka@cisco.com>
PerformanceProb: file I/Os vs. heavy string operations marcza@my-deja.com
Perl and ADO: How to access errors? <temp133@hotmail.com>
Re: perl equivalent of a Unix command line sort? (Eric Bohlman)
Re: perl equivalent of a Unix command line sort? (Larry Rosler)
Re: Perl On NT <jeff@vpservices.com>
Re: regex bug: (?:\d{3})+ loses count (Ilya Zakharevich)
Re: Select Multiple Form Field via Perl into Oracle err (Larry Rosler)
Re: Simple question about if statement <stampes@xilinx.com>
Re: Simple question about if statement <uri@sysarch.com>
Re: Simple question about if statement (Larry Rosler)
Re: stat function (Charles DeRykus)
Use of push when building an array? <news@news.news>
Re: Use of push when building an array? <news@news.news>
why's my program printing it's own source <jimmy@blackhole-designs.com>
Re: why's my program printing it's own source <jimmy@blackhole-designs.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 31 Aug 1999 19:07:34 BST
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: <DATA> in a module(package)
Message-Id: <1999Aug31.190734@ukwit01>
I'm trying ot write a module which needs to have some data structures
setup from the very start. These can be derived from a very simple text
format - the data structures to be used are somewhat more complex.
I've been trying to use the <DATA> file handle to read a text stream
from the end of the module code, but this doesn;t seem to work in a
package, or when the module coded is sucked in by a "use". Am I missign
something, or is this not allowed? (I'm using v 5.004p4).
Here's my little test:
----- perl script -----------------------
#!/usr/central/bin/perl
use dummy;
dummy::show_it_all;
----- perl module (dummy.pm) -----------------------
package dummy;
my %info = ();
while (<DATA>) {
print "Read: $_";
chomp;
my $key = substr($_, 0, 1);
my $data = substr($_, 3);
$info{$key} = $data;
}
sub show_it_all {
print "Showing all of the keys\n";
for $k (keys %info) {
print "$k -> $info{$k}\n";
}
}
1;
__END__
A: Line 1 is here
C: Line 2 is here
B: Guess which line this is? (Answer: 3)
--
--------- Gordon Lack --------------- gml4410@ggr.co.uk ------------
This message *may* reflect my personal opinion. It is *not* intended
to reflect those of my employer, or anyone else.
------------------------------
Date: Tue, 31 Aug 1999 11:19:31 -0700
From: Paul Alan Spitalny <paulsxxx@cascadelinear.com>
Subject: active perl 5.005 or standard perl 5.004
Message-Id: <37CC1CB3.56000FC2@cascadelinear.com>
This is a multi-part message in MIME format.
--------------8E10FAC72B6DE295D0445D85
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
What's the main differences between "active perl" 5.005 or "standard
perl "5.004 (Win NT binary) as listed in the web site:
http://www.cpan.org/ports/index.html#win32
Any help appreciated
Thanks, Paul
--
To return this email you must remove the xxx after pauls
--------------8E10FAC72B6DE295D0445D85
Content-Type: text/x-vcard; charset=us-ascii;
name="paulsxxx.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Paul Alan Spitalny
Content-Disposition: attachment;
filename="paulsxxx.vcf"
begin:vcard
n:Spitalny;Paul
tel;fax:425-828-7147
tel;home:425-828-6948
tel;work:425-828-6948
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:pauls@cascadelinear.com
fn:Paul Spitalny
end:vcard
--------------8E10FAC72B6DE295D0445D85--
------------------------------
Date: 31 Aug 1999 19:42:24 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: active perl 5.005 or standard perl 5.004
Message-Id: <7qhb70$c0r@dfw-ixnews6.ix.netcom.com>
Paul Alan Spitalny (paulsxxx@cascadelinear.com) wrote:
: What's the main differences between "active perl" 5.005 or "standard
: perl "5.004 (Win NT binary) as listed in the web site:
: http://www.cpan.org/ports/index.html#win32
That fact that one of them is perl 5.005 and the other is perl 5.004.
Seriously.
The term "standard" as applied to Gurusamy Sarathy's Win32 port of 5.004
is now rather misleading. At the time he did the port, ActiveState's
ports were decidedly non-standard; they weren't based on the official
perl source tree and they weren't compatible with many external modules.
ActiveState has since cleaned up its act, and its ports are now compiled
from the same sources as everyone else's, so the 500-series ActivePerls
are now just as "standard" as anything else.
------------------------------
Date: Tue, 31 Aug 1999 13:20:09 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: active perl 5.005 or standard perl 5.004
Message-Id: <MPG.1235d8d171ffd20c989ef1@nntp.hpl.hp.com>
In article <37CC1CB3.56000FC2@cascadelinear.com> on Tue, 31 Aug 1999
11:19:31 -0700, Paul Alan Spitalny <paulsxxx@cascadelinear.com> says...
> What's the main differences between "active perl" 5.005 or "standard
> perl "5.004 (Win NT binary) as listed in the web site:
> http://www.cpan.org/ports/index.html#win32
ActivePerl 5.005 is actively supported and up-to-date. Perl 5.004 is
obsolescent.
> Any help appreciated
> Thanks, Paul
>
> --
> To return this email you must remove the xxx after pauls
Why would I want to do that? If you want to get email, remove the xxx
yourself.
> begin:vcard
And why would I want to see this noise? Please ask your so-called
newsreader 'X-Mailer: Mozilla 4.61 [en] (Win95; I)' to suppress it in
the future.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 31 Aug 1999 20:54:25 GMT
From: d-lewart@uiuc.edu (Daniel S. Lewart)
Subject: ANNOUNCE: Champaign-Urbana Perl Mongers Meeting Wed Sep 1
Message-Id: <7qhfe1$elf$1@vixen.cso.uiuc.edu>
Champaign-Urbana Perl Mongers,
It has been arbitrarily decreed that we shall meet:
Wed Sep 1 19:00-21:00 CDT
The Bread Company on Goodwin
706 S Goodwin Ave
Urbana, IL
I will wear my Perl t-shirt. We may be in the back (East) room.
Fearlessly,
Daniel Lewart
Champaign-Urbana Perl Mongers Fearless Leader
http://cmi.pm.org/
------------------------------
Date: Tue, 31 Aug 1999 20:48:20 GMT
From: Editor 2 <rdfletch@home.com>
Subject: ATTENTION EXPERIENCED PROGRAMMERS ONLY!!!
Message-Id: <37CC3F7E.58DF605@home.com>
My company is currently seeking an experienced perl or C++ programmer to
write an affiliate program. We have a Linux box and we currently are
using mySQL. mySQL is already installed. The program will have to work
with multiple credit card processors. Please e-mail me at
webmaster@excessive.com for more details and detailed visual templates.
Please only experienced programmers only. The time span for the project
is 2 weeks so if you don't have the time and the dedication to get the
job done then please do not apply.
Please include the following info with your reply:
Full Name:
E-mail Address:
Your Resume:
Your Phone Number:
Any examples of your work.
Any refferals you may have.
US RESIDENTS ONLY / MUST SPEAK ENGLISH / SERIOUS INQUIRIES ONLY
MUST BE OVER 18 /
Thanks.
Editor 2
------------------------------
Date: Tue, 31 Aug 1999 16:20:25 -0400
From: Elaine -HFB- Ashton <elaine@chaos.wustl.edu>
Subject: Re: Building perl
Message-Id: <37CC38B2.99C239C7@chaos.wustl.edu>
Andrew Keyes wrote:
> Is this possiblity what it should be doing ? Or did something go wrong
> a along the way. I didn't expect it to
> take 100's of MB of diskspace to build perl.
Something is very wrong. What version of Perl and which compiler are you
using? Did you check the READMEs for build gotchas?
e.
------------------------------
Date: Tue, 31 Aug 1999 19:28:23 GMT
From: mrbog@my-deja.com
Subject: Re: Case insensitive SQL query
Message-Id: <7qhac6$48m$1@nnrp1.deja.com>
Oh please, SQL is obviously tangentially related to perl. Not only
that but I'm sure my question is a common one and doesn't require heaps
of documentation to solve.
And BTW mysql.com doesn't solve my problem.
In article <MPG.1235e428a5c1d8e2989c9e@news-server>,
elephant@squirrelgroup.com (elephant) wrote:
> mrbog@my-deja.com writes ..
>
> <completely irrelevant to Perl question deleted>
>
> >Do any of you know how to do that? (I know this isn't exactly a perl
> >question, sorry..)
>
> not "exactly" a Perl question ? .. it's not a Perl question at all -
> MySQL has a HEAP of documentation .. and a HEAP of mailing lists for
> asking these kinds of questions
>
> you're far more likely to find someone there that'll be able to
answer
> your question .. we know about Perl - not MySQL .. if I were to take
a
> wild stab in the dark - I'd say their web page is probably
www.mysql.com
>
> --
> jason - elephant@squirrelgroup.com -
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 31 Aug 1999 13:22:08 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Case insensitive SQL query
Message-Id: <37CC3970.7A101C9F@cisco.com>
[ mrbog@my-deja.com wrote:
> My site uses a mySQL database and I need to do a LIKE query that is
> case insensitive. So, for example:
> SELECT from dbname where name LIKE "%Joe%";
Do match after you have converted both your args to lowercase or uppercase.
eg: SELECT from dbname where UPPER( name) LIKE "%JOE%";
> I know this isn't exactly a perl question, sorry.
Thanks. Next time you might find a database/SQL/mySQL related newsgroup to
be more helpful.
------------------------------
Date: Tue, 31 Aug 1999 19:35:59 GMT
From: Patrick Meidl <p.meidl@klivv.oeaw.ac.at>
Subject: cgi error on apache
Message-Id: <37CC2F63.7C4E9605@klivv.oeaw.ac.at>
hi,
on a debian 2.1 system with apache 1.3.3 and perl 5.004, I get the
following errors when I try to run a sample cgi-script (from the CGI.pm
homepage):
[error] (2)No such file or directory: exec of
/usr/lib/cgi-bin/cgitest.pl failed
[error] [client xx.xx.xx.xx] Premature end of script headers:
/usr/lib/cgi-bin/cgitest.pl
the script "cgitest.pl" looks like this:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
#!/usr/bin/perl
use CGI qw(:standard);
print header;
print start_html('A Simple Example'),
h1('A Simple Example'),
start_form,
"What's your name? ",textfield('name'),
p,
"What's the combination?",
p,
checkbox_group(-name=>'words',
-values=>['eenie','meenie','minie','moe'],
-defaults=>['eenie','minie']),
p,
"What's your favorite color? ",
popup_menu(-name=>'color',
-values=>['red','green','blue','chartreuse']),
p,
submit,
end_form,
hr;
if (param()) {
print
"Your name is",em(param('name')),
p,
"The keywords are: ",em(join(", ",param('words'))),
p,
"Your favorite color is ",em(param('color')),
hr;
}
print end_html;
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
the file /usr/lib/cgi-bin/cgitest.pl exists, permissions are 755,
/usr/lib/cgi-bin is my cgi-directory, and CGI.pm is in /usr/lib/perl5,
and the perl path is also right.
any ideas what's wrong?
thanx
*patrick*
--
Patrick Meidl
Witzelsbergerg. 20/6
A-1150 Vienna
Austria
!!!NEW +43-699-10460516 NEW!!!
p.meidl@klivv.oeaw.ac.at
http://unet.univie.ac.at/~a8903821
--
------------------------------
Date: Tue, 31 Aug 1999 19:44:57 +0100
From: news <news@news.news>
Subject: Date / time problem (resolution)
Message-Id: <37CC22A9.DF7F800C@news.news>
Dear all,
I posted this a few days ago:
# This prints seconds from epoch ok
$date = time;
# This returns nothing
$date = localtime;
# This too
$date =gmtime;
I managed to solve the problem by doing this:
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
------------------------------
Date: Tue, 31 Aug 1999 13:25:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Date / time problem (resolution)
Message-Id: <MPG.1235d9f7e21b4f85989ef2@nntp.hpl.hp.com>
In article <37CC22A9.DF7F800C@news.news> on Tue, 31 Aug 1999 19:44:57
+0100, news <news@news.news> says...
> Dear all,
> I posted this a few days ago:
>
> # This prints seconds from epoch ok
> $date = time;
> # This returns nothing
> $date = localtime;
> # This too
> $date =gmtime;
What nonsense. You were told earlier that you have a problem with your
perl installaion. But you have chosen to work around it, rather than
fix it. So why should we care (except that you are spewing
misinformation which might mislead the unwary.
#!/usr/local/bin/perl -w
use strict;
my $date;
# This prints seconds from epoch ok
$date = time;
print "|$date|\n";
# This returns nothing
$date = localtime;
print "|$date|\n";
# This too
$date =gmtime;
print "|$date|\n";
print "\nperl version $]\n";
__END__
|936130983|
|Tue Aug 31 13:23:03 1999|
|Tue Aug 31 20:23:03 1999|
perl version 5.00503
> I managed to solve the problem by doing this:
>
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
No, you found a way to solve a different problem.
Maybe you should stick to 'alt.perl' for your answers (removed from this
response).
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 31 Aug 1999 18:52:37 GMT
From: tvn007@my-deja.com
Subject: EVAL ??
Message-Id: <7qh89f$2lk$1@nnrp1.deja.com>
Hello,
I am new to PERL, and not sure how to solve this
problem.
Would someone please give me some hints ?
Here is the problem:
I have a file called "FILE1"
with the following data in it:
Name Formula1 Formula2
A "x+y" "x+1"
C "z+y" "y+2"
and other file call "FILE2"
with the follwoing data in it:
x 2
y 5
z 3
The question I have is:
What technique should I use so that I can have the
output :
Name Formula1 Formula2
A 7 3
C 8 7
Thanks in advance for any help
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 31 Aug 1999 13:27:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: EVAL ??
Message-Id: <MPG.1235da7bf3be4f13989ef3@nntp.hpl.hp.com>
In article <7qh89f$2lk$1@nnrp1.deja.com> on Tue, 31 Aug 1999 18:52:37
GMT, tvn007@my-deja.com <tvn007@my-deja.com> says...
> Hello,
>
> I am new to PERL, and not sure how to solve this
> problem.
>
> Would someone please give me some hints ?
>
> Here is the problem:
>
> I have a file called "FILE1"
>
> with the following data in it:
>
> Name Formula1 Formula2
>
> A "x+y" "x+1"
> C "z+y" "y+2"
You posted this yesterday and got a response. What about it didn't you
understand, that would make you post it again?
And what is wrong with your newsreader, that it posts in right field?
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Oh.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 31 Aug 1999 15:00:05 -0400
From: Paul Farber <farber@admin.f-tech.net>
Subject: gethosybyaddr
Message-Id: <Pine.LNX.4.04.9908311455120.1730-100000@admin.f-tech.net>
Can anyone spare a snippet of code that will get the hostname from an IP
address? I looked in the camel book but the book dosen't really cover
ADDRTYPE.. and the function will not work without it. So far I have:
$hn=gethostbyaddr("207.44.65.67",AF_INET); # pg 350
print("Checking: $hn\n");
but it dosen't print anything out. The book also says that in scalar from
the only returned value is the hostname... I get zilch.
Using RH 5.2 perl
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
Platform:
osname=linux, osvers=2.0.34, archname=i386-linux
uname='linux porky.redhat.com 2.0.34 #1 thu may 7 10:17:44 edt 1998
i686 unknown '
hint=recommended, useposix=true, d_sigaction=define
bincompat3=y useperlio=undef d_sfio=undef
thanks
Paul D. Farber II
Farber Technology
Ph. 570-628-5303
Fax 570-628-5545
farber@admin.f-tech.net
------------------------------
Date: Tue, 31 Aug 1999 13:33:45 -0400
From: "Z. Huang" <zhuang@ic.sunysb.edu>
Subject: how to open a file in the internet?
Message-Id: <37CC11F8.6F303461@ic.sunysb.edu>
Can anyone tell me how to retrieve a file from the internet or point
me to some samples? Thanks in advance.
------------------------------
Date: Tue, 31 Aug 1999 13:23:07 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: how to open a file in the internet?
Message-Id: <37CC39AA.A112C2CF@cisco.com>
[ "Z. Huang" wrote:
> Can anyone tell me how to retrieve a file from the internet or point
> me to some samples? Thanks in advance.
perldoc LWP::Simple
perldoc LWP::UserAgent
--
------------------------------
Date: Tue, 31 Aug 1999 12:49:51 -0500
From: Steve Schwartz <rhgv90@email.sps.mot.com>
Subject: How to rewind DATA filehandle?
Message-Id: <37CC15BF.64AF05B@email.sps.mot.com>
I've tried to read the text from DATA more than once and have only been
successful with an ugly hack. Here's a simple example of what I want to do:
% my_script.pl test1 test2 test3
should produce 3 files called test1.out test2.out and test3.out and each file
should have a first line that's different and then the text after the __END__
token.
Here's the original simple idea but it only works correctly for the first
output file. After that, each output file has only one line because (I assume)
the DATA filehandle is at EOF. So, the question is, how do I rewind the DATA
filehandle back to it's original starting point.
#!/usr/local/bin/perl
for $file (@ARGV) {
$ofile = ">$file.out";
open(OFILE, $ofile) || die ("can't open $file.out for output\n");
select OFILE;
print $file;
while (<DATA>) {
print;
}
close(OFILE);
}
__END__
line1
line2
line3
# previous line is the end of script
My hack is to use seek(DATA,0,0) and then read DATA until the __END__ token.
Is there a better way?
Steve
------------------------------
Date: Tue, 31 Aug 1999 18:25:44 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: How to rewind DATA filehandle?
Message-Id: <sibtbnst7b.fsf@cre.canon.co.uk>
Steve Schwartz <rhgv90@email.sps.mot.com> wrote:
> My hack is to use seek(DATA,0,0) and then read DATA until the __END__
> token. Is there a better way?
Do `$start_of_data = tell(DATA)' before reading anything from DATA; then
you can `seek(DATA, $start_of_data, 0)'.
--
Gareth Rees
------------------------------
Date: Tue, 31 Aug 1999 10:56:50 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Insecure dependency in open while running with -T switch
Message-Id: <37CC1761.F6ACE32C@cisco.com>
[ Larry Rosler wrote:
> Also, your newsreader continues to throw in random empty lines and line
> fragments.
I don't know why it is doing this ? I am using Netscape Communicator 4.5?
Can you suggest some windows95 newsreaders that might
be helpful here ? I am not allowed to install Unix based newsreaders like
Tin etc.
--
------------------------------
Date: Tue, 31 Aug 1999 12:24:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Insecure dependency in open while running with -T switch
Message-Id: <MPG.1235cbb935213bba989eee@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <37CC1761.F6ACE32C@cisco.com> on Tue, 31 Aug 1999 10:56:50 -
0700, Makarand Kulkarni <makkulka@cisco.com> says...
> [ Larry Rosler wrote:
>
> > Also, your newsreader continues to throw in random empty lines and line
> > fragments.
>
> I don't know why it is doing this ? I am using Netscape Communicator 4.5?
That is hacked-up garbage, not a newsreader.
> Can you suggest some windows95 newsreaders that might
> be helpful here ? I am not allowed to install Unix based newsreaders like
> Tin etc.
Consider Gravity, <URL:http://www.microplanet.com/>. It has all the
bells and whistles you never dreamed you needed, as well as excellent
technical support. About $30 if I recall correctly.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 31 Aug 1999 12:46:49 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: LWP::Simple GET ???
Message-Id: <37CC3129.8A3C1E1@cisco.com>
[ Bob Freedman wrote:
> When using LWP::Simple GET is there a way to time-out the retrevial of
> the html document?
Looks like LWP::Simple does not allow you to timeout. But LWP::UserAgent
does have timeout().
--
------------------------------
Date: Tue, 31 Aug 1999 19:50:42 GMT
From: marcza@my-deja.com
Subject: PerformanceProb: file I/Os vs. heavy string operations
Message-Id: <7qhbmd$5fp$1@nnrp1.deja.com>
I am thinking about the "best" way of implementing a certain task
regarding the performance. I've two ways of doing that:
1.) Loading approx. 100 files with 5kb each
This will result in hardly any string operations
2.) Loading 1 file with 500kb and
doing a lot of string manipulations (approx. 10000 of appends and
splices)
What would be the most performant way ?
Do file I/o really cost that much time ?
The target system will be Linux
Bye
Marcus
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 31 Aug 1999 12:15:46 -0700
From: "Arvin Portlock" <temp133@hotmail.com>
Subject: Perl and ADO: How to access errors?
Message-Id: <7qh9b1$psk$1@agate-ether.berkeley.edu>
I've been unable to translate the Visual Basic ADO examples
into perl. I want to see if there are errors from executing my
SQL statement but can't figure out how to do it in perl. I've tried
the following:
$Conn->Execute("INSERT INTO myTable ($sqlfields) VALUES ($sqlvalues);");
if ($Conn->Errors->Count) {
print $Conn->Errors->Description, "\n";
}
but to no avail. I've successfully tested at least that
$Conn->Errors->Count works by deliberately screwing up my
SQL. But how to get the error messages themselves. An example
from anybody who's done this would be great. By the way, the
rest of the program works fine, it's just the errors I'm interested
in now.
Regards,
Al
------------------------------
Date: 31 Aug 1999 19:28:03 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: perl equivalent of a Unix command line sort?
Message-Id: <7qhac3$c0r@dfw-ixnews6.ix.netcom.com>
Paul L. Lussier (plussier@baynetworks.com) wrote:
: mgjv@comdyn.com.au (Martien Verbruggen) writes:
: > use Socket;
: > my @sorted_ips = sort { inet_aton($a) cmp inet_aton($b) } @ips;
:
: Could you explain *why* this works? I don't quite understand what 'use Socket'
: does that would help with sorting?
It's where the code for inet_aton() resides.
------------------------------
Date: Tue, 31 Aug 1999 12:33:47 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: perl equivalent of a Unix command line sort?
Message-Id: <MPG.1235cdf43ddbca1e989eef@nntp.hpl.hp.com>
In article <h67k8qbnags.fsf@baynetworks.com> on 31 Aug 1999 13:09:23 -
0400, Paul L. Lussier <plussier@baynetworks.com> says...
> mgjv@comdyn.com.au (Martien Verbruggen) writes:
>
> > In article <h67ogfo29ty.fsf@baynetworks.com>,
> > plussier@baynetworks.com (Paul L. Lussier) writes:
> > >
> > > Hi all,
> > >
> > > I'm trying sort a lists of ip addresses in a script
> >
> > This happens to work, for various modes of 'work', useability is left
> > to the reader.
> >
> > use Socket;
> > my @sorted_ips = sort { inet_aton($a) cmp inet_aton($b) } @ips;
>
> Could you explain *why* this works? I don't quite understand what 'use Socket'
> does that would help with sorting?
perldoc Socket
inet_aton() is a function defined in the Socket module that converts IP
addresses into packed 32-bit integers suitable for use by
gethostbyaddr(), for example. These integers are four-byte strings that
can be compared lexicographically, as shown.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 31 Aug 1999 19:00:07 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl On NT
Message-Id: <37CC253A.246D8922@vpservices.com>
Bill Tucker wrote:
>
> Question, does anyone know what needs to be done to have perl execute on a
> NT 4.0 system running Netscape Enterprise 3.5? I have perl in the path but
> obviously you can't use the same HTML syntax as you do within Unix (<form
> method="post" action="/cgi-bin/send_wba.pl">) to have pl file execute.
Um, nothing wrong with that syntax except POST should be capitalized.
But it is your web server that determines what is needed to execute cgi
scripts. Check the netscrape docs to find out what shebang you need,
and how you need to configure your mime-types and directories and if you
still have problems try server or cgi newsgroups.
--
Jeff
------------------------------
Date: 31 Aug 1999 19:58:13 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: regex bug: (?:\d{3})+ loses count
Message-Id: <7qhc4l$g9u$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to M.J.T. Guy
<mjtg@cus.cam.ac.uk>],
who wrote in article <7qgvq0$3gu$1@pegasus.csx.cam.ac.uk>:
> So you should think of 5.005_02 as a development release. Anyone
> running it should upgrade to 5.005_03 immediately.
I think the same about 5.005_03. IME 5.005_03 is much less stable
than other development releases (say, 5.005_56, which practically
should be of production quality). You *at least* need the _ph_head.ph
(sp?!! the file which is included from other .ph files?) patch which
restores .ph functionality on many systems.
Ilya
------------------------------
Date: Tue, 31 Aug 1999 12:08:40 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Select Multiple Form Field via Perl into Oracle error
Message-Id: <MPG.1235c812926fa37d989eed@nntp.hpl.hp.com>
In article <FHByIH.Kp8@ig.co.uk> on Tue, 31 Aug 1999 12:54:17 GMT,
Jacqui Caren <Jacqui.Caren@ig.co.uk> says...
> In article <ej%w3.1$2B2.769@news.enterprise.net>,
> Simmo <simsi@hotmail.com.nospam> wrote:
...
> >DBD::Oracle::db prepare failed: ORA-01756: quoted string not properly
> >terminated (DBD ERROR: OCIStmtPrepare) at news.pl line 855.
...
> >An example string i'm writing incidentally is:
> >
> >$categories_selected = $FORM{'categories'};
>
> $categories_selected = $dbh->escape($FORM{'categories'});
>
> should fix your problem...
Is that function particular to DBD::Oracle? The DBI module has a
function called 'quote' that seems to do what is wanted, but no function
called 'escape'.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 31 Aug 1999 17:46:40 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: Simple question about if statement
Message-Id: <7qh4e0$9r1@courier.xilinx.com>
Nostradamus <mboertien@my-deja.com> wrote:
: I have a small question. I have a certain code which i want to check
: for different values but i don't want to write the following :
: if ($code == 10 || $code==20 || $code==30 etc.....)
TMTOWTDI:
if ($code == 10 || 20 || 30 ) {}
if ($code =~ /^10|20|30$/) {}
if ($code =~ /^(1|2|3)0$/) {}
%valid = ( 10 => 1, 20 => 1, 30 => 1);
if ($valid{$code}) {}
iAnd I'm sure there's a couple dozen more ways.
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: 31 Aug 1999 15:39:15 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Simple question about if statement
Message-Id: <x7emgjvixo.fsf@home.sysarch.com>
>>>>> "JS" == Jeff Stampes <stampes@xilinx.com> writes:
JS> Nostradamus <mboertien@my-deja.com> wrote:
JS> : I have a small question. I have a certain code which i want to check
JS> : for different values but i don't want to write the following :
JS> : if ($code == 10 || $code==20 || $code==30 etc.....)
JS> TMTOWTDI:
JS> if ($code == 10 || 20 || 30 ) {}
BZZZ!!! you failed. go to the back of the class.
JS> if ($code =~ /^10|20|30$/) {}
this passes 100, 200, 330 and fails on 300. try again.
JS> if ($code =~ /^(1|2|3)0$/) {}
no need to grab the text. use non-grabbing parens (?:). but even better
when doing an | on single chars, use a char class
if ($code =~ /^[123]0$/) {}
JS> %valid = ( 10 => 1, 20 => 1, 30 => 1);
JS> if ($valid{$code}) {}
2 out of 4 correct. not a good batting average in this group. please
test your examples before posting them.
JS> iAnd I'm sure there's a couple dozen more ways.
and most of them are correct!
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Tue, 31 Aug 1999 13:09:09 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Simple question about if statement
Message-Id: <MPG.1235d644309a124989ef0@nntp.hpl.hp.com>
In article <7qh4e0$9r1@courier.xilinx.com> on 31 Aug 1999 17:46:40 GMT,
Jeff Stampes <stampes@xilinx.com> says...
> Nostradamus <mboertien@my-deja.com> wrote:
> : I have a small question. I have a certain code which i want to check
> : for different values but i don't want to write the following :
>
> : if ($code == 10 || $code==20 || $code==30 etc.....)
>
> TMTOWTDI:
And some of them are Right Ways and some of them are Wrong Ways. You
seem unable to distinguish them, because you made no attempt to test
your suggestions before posting them.
> if ($code == 10 || 20 || 30 ) {}
This is always TRUE. The expression is actually shown correctly in the
original post (above).
> if ($code =~ /^10|20|30$/) {}
This matches 10x, y20z, w30, or practically anything. /^(10|20|30)$/
> if ($code =~ /^(1|2|3)0$/) {}
This works, but is inefficient (/^[123]0$/) and hardly scales well to
other numbers, as requested.
> %valid = ( 10 => 1, 20 => 1, 30 => 1);
> if ($valid{$code}) {}
Finally a correct, scalable solution. And it is found in the FAQ.
Those who like writing less would do it this way:
my %valid;
@valid{10, 20, 30} = ();
if (exists $valid$code}) { }
> iAnd I'm sure there's a couple dozen more ways.
No doubt, and many of them are Right Ways. There are several more in
the FAQ.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 31 Aug 1999 19:48:53 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: stat function
Message-Id: <FHCHpH.MJK@news.boeing.com>
In article <8E32B3B05DallasKiddsolution6c@news.optus.net.au>,
Dallas Kidd <8103086@iname.com> wrote:
>Hi,
>
>I am wanting to use the stat function for PERL 5.... on solaris 2.6.
>
>I get nothing back when I use:
>
> ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
>$atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
>
Add this:
($dev,...) = stat($filename) or warn "stat failed: $!";
hth,
--
Charles DeRykus
------------------------------
Date: Tue, 31 Aug 1999 20:50:42 +0100
From: news <news@news.news>
Subject: Use of push when building an array?
Message-Id: <37CC3212.825098F3@news.news>
Hi,
I am reading in a colon separated file and splitting it like this:
($dbfirstname,$dblastname,$dbage)=split(/:/);
I am then trying to match entries based on form input, but this only
prints the last match. Should I be using push here?
# This only prints the last match
@results= "$dbfirstname $dblastname $dbage" if $dbage == $formage;
Thanks,
Saiid.
------------------------------
Date: Tue, 31 Aug 1999 21:02:03 +0100
From: news <news@news.news>
Subject: Re: Use of push when building an array?
Message-Id: <37CC34BB.753C268E@news.news>
Sorry, please ignore..fixed it with
push @list, @results;
news wrote:
> Hi,
> I am reading in a colon separated file and splitting it like this:
>
> ($dbfirstname,$dblastname,$dbage)=split(/:/);
>
> I am then trying to match entries based on form input, but this only
> prints the last match. Should I be using push here?
>
> # This only prints the last match
> @results= "$dbfirstname $dblastname $dbage" if $dbage == $formage;
>
> Thanks,
> Saiid.
------------------------------
Date: Tue, 31 Aug 1999 19:30:23 GMT
From: Jimmy Humphrey <jimmy@blackhole-designs.com>
Subject: why's my program printing it's own source
Message-Id: <37CC2D40.1482BE42@blackhole-designs.com>
Why is my program at http://www.blackhole-designs.com/pokerbot/ (after
you send the info) printing out it's own source code instead of
executing the file? Using perl 5.004_01, Linux, apache, all file
permisions are correct.
Thanks,
Jimmy
------------------------------
Date: Tue, 31 Aug 1999 19:44:44 GMT
From: Jimmy Humphrey <jimmy@blackhole-designs.com>
Subject: Re: why's my program printing it's own source
Message-Id: <37CC309E.B0016C1E@blackhole-designs.com>
never mind
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 689
*************************************