[12943] in Perl-Users-Digest
Perl-Users Digest, Issue: 353 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 3 18:07:15 1999
Date: Tue, 3 Aug 1999 15:05:15 -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, 3 Aug 1999 Volume: 9 Number: 353
Today's topics:
Re: [offtopic]RE:Quot St and the Jeop Gm <llornkcor@llornkcor.com>
Re: [was]Re: reg expression <llornkcor@llornkcor.com>
BerkeleyDB on AIX taggor@yahoo.com
code posted <tech1@magicnet.net>
Copying a file (Jimtaylor5)
Re: Copying a file (Malcolm Ray)
Re: Copying a file (Juergen Heinzl)
Re: Copying a file <tom.kralidis@ccrs.nrcanDOTgc.ca>
Re: Extracting plain text from email (Bob Kline)
Re: Extracting plain text from email <tchrist@mox.perl.com>
Re: Free Programs <cassell@mail.cor.epa.gov>
Re: Getting Date from HTTP::Response <gisle@aas.no>
Re: Getting Date from HTTP::Response (Larry Rosler)
Re: Help - Perl/CGI on MS Personal Web Server. <gellyfish@gellyfish.com>
Re: Help Please <gellyfish@gellyfish.com>
help with find command mr_potato_head@my-deja.com
Re: How can I know what modules are installed on server <flavell@mail.cern.ch>
Re: How can I trap/block a kill -9 signal <gellyfish@gellyfish.com>
Re: How can I trap/block a kill -9 signal <aqumsieh@matrox.com>
Re: Need Help Understanding a perl script <aqumsieh@matrox.com>
Re: Newbie Q: Removing files from a folder <andrewf@beausys.freeserve.co.uk>
Re: Newbie Q: Removing files from a folder <aqumsieh@matrox.com>
Re: Perl and Oracle using DBI <paul.glidden@unisys.com>
Re: Perl CGI vs VB ASP <cassell@mail.cor.epa.gov>
Re: Perl or CGI pricerbumanto@my-deja.com
Re: perl s///e weirdism||bug <Allan@due.net>
Re: perl s///e weirdism||bug (Larry Rosler)
Perl seems to be LAME! <bluebit@gmx.net>
Re: Perl seems to be LAME! (Sam Holden)
Re: Running scrips on own pc <paulreid@cableinet.co.uk>
tar <pjw7@ukc.ac.uk>
Re: tar <paul.glidden@unisys.com>
Re: tar (Malcolm Ray)
Re: tar <tchrist@mox.perl.com>
Re: towards uploading binary files... (Larry Rosler)
Re: using __PACKAGE__ <cassell@mail.cor.epa.gov>
Using the Win32:: module from a non-Win32 machine. <louis@alten.net.nospam>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 3 Aug 1999 15:30:42 -0600
From: "llornkcor" <llornkcor@llornkcor.com>
Subject: Re: [offtopic]RE:Quot St and the Jeop Gm
Message-Id: <7o7mum$jnn$1@oak.prod.itd.earthlink.net>
Because I thought I would try and stand up for over abused newbies here, and
try to make it better, and nicer place to
get perl help. But obviously this list thinks it is moderated, and those
*perl-gawhds* obviously don't have a compassionate bone in their bodies.
It's too bad, cause perl is a wonderful tool.
It was worth a try...
> Seriously, you're not saying anything new. Every few days a newbie says
> much the same, frequently with worse spelling and punctuation than yours.
> Guess what? It makes no difference. So why bother?
------------------------------
Date: Tue, 3 Aug 1999 15:35:21 -0600
From: "llornkcor" <llornkcor@llornkcor.com>
Subject: Re: [was]Re: reg expression
Message-Id: <7o7n7c$k8o$1@oak.prod.itd.earthlink.net>
> Way too many. Got any solutions for exterminating those pesky people
> that ask questions that trigger rude responses?
well, you COULD ignore them...
why not try that for a change?
------------------------------
Date: Tue, 03 Aug 1999 21:44:51 GMT
From: taggor@yahoo.com
Subject: BerkeleyDB on AIX
Message-Id: <7o7nsh$671$1@nnrp1.deja.com>
I'm trying to build the Perl module BerkeleyDB version 0.06 on AIX
Version 4. I have Berkeley DB version 2.7.5 built. I'm getting errors
when I'm doing the "make test". Here are the errors I'm getting:
PERL_DL_NONLAZY=1 /usr/local/bin/perl -I./blib/arch -I./blib/lib -
I/usr/local/lib/perl5/a
ix/5.00404 -I/usr/local/lib/perl5 -e 'use Test::Harness qw(&runtests
$verbose); $verbose=0; runte
sts @ARGV;' t/*.t
t/btree.............dubious
Test returned status 0 (wstat 132, 0x84)
test program seems to have generated a core
t/env...............Transaction Manager not enabled at t/env.t line
133. dubious
Test returned status 2 (wstat 512, 0x200)
DIED. FAILED tests 3, 22-49
Failed 29/49 tests, 40.82% okay
t/filter............dubious
Test returned status 0 (wstat 132, 0x84)
test program seems to have generated a core
t/hash..............dubious
Test returned status 0 (wstat 132, 0x84)
test program seems to have generated a core
t/unknown...........dubious
Test returned status 0 (wstat 132, 0x84)
test program seems to have generated a core
Any help would be greatly appreciated.
Chuck Rickard
chuck-rickard@reliantenergy.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 3 Aug 1999 17:48:35 -0400
From: "Diane" <tech1@magicnet.net>
Subject: code posted
Message-Id: <rqep4ipts4scq6@corp.supernews.com>
I have posted the code.. please see my previous post, the one after my
initial one..
thanks in advance
D.
------------------------------
Date: 03 Aug 1999 21:39:07 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Copying a file
Message-Id: <19990803173907.24137.00006400@ng-fw1.aol.com>
I'm trying to find information on copying a file, and yes, I have read the FAQ.
Even searched Cspan and the entire web for copy files in perl and get
absolutely no information on what seems to me should be a simple task (being a
newbe and ignorant of what's difficult and easy). I don't want to rename the
file, just copy ABC.gif to DEF.gif. I want to retain the original. can anyone
tell me how I would go about doing this "or" if that's too difficult, where I
might find the information on it?
Thanks in advance for any direction or info you can give me.
------------------------------
Date: 3 Aug 1999 21:58:56 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Copying a file
Message-Id: <slrn7qeph0.ve.M.Ray@carlova.ulcc.ac.uk>
On 03 Aug 1999 21:39:07 GMT, Jimtaylor5 <jimtaylor5@aol.com> wrote:
>I'm trying to find information on copying a file, and yes, I have read the FAQ.
>Even searched Cspan and the entire web for copy files in perl and get
>absolutely no information on what seems to me should be a simple task (being a
>newbe and ignorant of what's difficult and easy). I don't want to rename the
>file, just copy ABC.gif to DEF.gif. I want to retain the original. can anyone
>tell me how I would go about doing this "or" if that's too difficult, where I
>might find the information on it?
>Thanks in advance for any direction or info you can give me.
You must have somehow missed the File::Copy module, which you almost
certainly already have installed on your system. 'perldoc File::Copy'
will tell you how to use it.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Tue, 03 Aug 1999 21:59:24 GMT
From: juergen@monocerus.demon.co.uk (Juergen Heinzl)
Subject: Re: Copying a file
Message-Id: <slrn7qepfa.7s.juergen@monocerus.demon.co.uk>
In article <19990803173907.24137.00006400@ng-fw1.aol.com>, Jimtaylor5 wrote:
>I'm trying to find information on copying a file, and yes, I have read the FAQ.
>Even searched Cspan and the entire web for copy files in perl and get
>absolutely no information on what seems to me should be a simple task (being a
>newbe and ignorant of what's difficult and easy). I don't want to rename the
>file, just copy ABC.gif to DEF.gif. I want to retain the original. can anyone
>tell me how I would go about doing this "or" if that's too difficult, where I
>might find the information on it?
>Thanks in advance for any direction or info you can give me.
use File::Copy;
...
copy( $from, $to )
...
Ta',
Juergen
--
\ Real name : Jürgen Heinzl \ no flames /
\ EMail Private : juergen@monocerus.demon.co.uk \ send money instead /
------------------------------
Date: Tue, 03 Aug 1999 18:00:57 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: Re: Copying a file
Message-Id: <37A76699.A620659A@ccrs.nrcanDOTgc.ca>
Here's a couple of ways to do it:
1./
#!/usr/bin/perl -w
print "Enter filename to copy from >";
chomp($from = <STDIN>);
print "Enter filename to copy to >";
chomp($to = <STDIN>);
open(FROM, "$from");
open(TO, ">$to");
@lines_from = <FROM>;
print TO @lines_from;
2./
#!/usr/bin/perl -w
use File::Copy;
copy("/home/user/file0", "/home/user/bin/file0");
Hope this helps.
..Tom
Jimtaylor5 wrote:
>
> I'm trying to find information on copying a file, and yes, I have read the FAQ.
> Even searched Cspan and the entire web for copy files in perl and get
> absolutely no information on what seems to me should be a simple task (being a
> newbe and ignorant of what's difficult and easy). I don't want to rename the
> file, just copy ABC.gif to DEF.gif. I want to retain the original. can anyone
> tell me how I would go about doing this "or" if that's too difficult, where I
> might find the information on it?
> Thanks in advance for any direction or info you can give me.
--
-----------------------------------------------------------------------------------------
Tom Kralidis Geo-Spatial Technologist
Canada Centre for Remote Sensing Tel: (613) 947-1828
588 Booth Street , Room 241 Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7 http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------
------------------------------
Date: 3 Aug 1999 20:51:55 GMT
From: bkline@cortex.nlm.nih.gov (Bob Kline)
Subject: Re: Extracting plain text from email
Message-Id: <7o7kpb$fd$1@lhc.nlm.nih.gov>
: Your continued attempts at branding design flaws and outright mistakes
: "matters of opinion" firmly places you in the same crowd as the cultural
: relativists, where everything is merely opinion, and all opinions are
: equally valid, and both good and bad have ceased to exist.
And now, for a contrasting opinion:
"TMTOWTDI." - LW
Lighten up, folks. :->}
------------------------------
Date: 3 Aug 1999 15:40:37 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Extracting plain text from email
Message-Id: <37a761d5@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
bkline@cortex.nlm.nih.gov (Bob Kline) writes:
:And now, for a contrasting opinion:
:
: "TMTOWTDI." - LW
Nice try, but TMTOWTDI does not mean that everything is good.
Please don't use it that way. That's not what it means.
Please read
http://www.perl.com/tchrist/defop/defconfaq.html#Isn_t_making_another_way_to_do_s
--tom
--
"Noalias must go. This is non-negotiable." --dmr
------------------------------
Date: Tue, 03 Aug 1999 14:52:25 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Free Programs
Message-Id: <37A76499.9D5369FF@mail.cor.epa.gov>
Programmaholic wrote:
>
> Hi,
>
> I'm a student and I would like to improve my programming skills. So if
> anybody here needs a Perl Program, I'll be willing to help develop it with
> you, or do the entire thing on my own. Of course this depends on my
> available free time after college.
That's durn nice of you. When I saw your subject line, I
assumed that you were going to be *asking* for free programs
instead of contributing them.
May I suggest that you take a look at the Perl Power Tools
project [ http://language.perl.com/ppt/ ] and consider one or
more of these tasks? You will find that a number of these
are already partially-done, and you can learn a lot of Perl
techniques and style from perusing the available code.
Good luck,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 03 Aug 1999 23:01:54 +0200
From: Gisle Aas <gisle@aas.no>
Subject: Re: Getting Date from HTTP::Response
Message-Id: <m3n1w87f3x.fsf@eik.g.aas.no>
maxime69@my-deja.com writes:
> In order to get Date value of HTTP::Response I do
>
> $request = new HTTP::Request 'GET', 'http//.....';
> $header = new HTTP::Headers;
> $response = $UserAgent->request($request, $header);
>
> print "Date is ", $header->date(time), "\n";
> Here I have use of uninitialized value
>
> Someone of you knows the mistake ?
There are several. Just use the 'date' method of the $response
object:
print localtime($response->date), "\n";
...and don't pass a second argument to $UserAgent->request()
--
Gisle Aas
------------------------------
Date: Tue, 3 Aug 1999 14:49:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Getting Date from HTTP::Response
Message-Id: <MPG.121103ba6e8dfbfe989da7@nntp.hpl.hp.com>
In article <m3n1w87f3x.fsf@eik.g.aas.no> on 03 Aug 1999 23:01:54 +0200,
Gisle Aas <gisle@aas.no> says...
...
> print localtime($response->date), "\n";
^
scalar ???
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 3 Aug 1999 21:14:45 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help - Perl/CGI on MS Personal Web Server.
Message-Id: <7o7m45$5fp$1@gellyfish.btinternet.com>
[ Follow-ups set and posted to comp.infosystems.www.servers.ms-windows]
In comp.lang.perl.misc Nico Zigouras <zigouras@mail.med.upenn.edu> wrote:
> Hi:
> I am having problems configuring MS PWS for Perl/CGI. I can run Perl fine
> from command line. I think i associated the .pl extension with it OK.
>
If you are using the lastest distribution of Perl from Activestate from
<http://www.activestate.com> then this is answered in the Win32 specific
FAQ that is part of the documenentation that is installed as HTML
documents accessible from your Start Menu.
If you still have difficulty after having read the documentation then you
might have better luck if you ask in a more appropriate group than the
ones you have scatter gunned here.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 3 Aug 1999 21:29:25 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help Please
Message-Id: <7o7mvl$5gh$1@gellyfish.btinternet.com>
On Tue, 03 Aug 1999 16:14:02 +0100 Chris Wilkinson wrote:
> Andreas Fehr wrote:
>> try to find something about STDIN and STDOUT in your documentation).
> I have just discovered this thanks to someone e-mailing me, and I now have it
> working, the only other problem is that the password when entered is visble
> rather than a series of ******.
You should read this section from perlfaq8 :
=head2 How do I ask the user for a password?
The given solutions of course do not give you masking characters - that is
left as an exercise for the reader.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Tue, 03 Aug 1999 21:46:41 GMT
From: mr_potato_head@my-deja.com
Subject: help with find command
Message-Id: <7o7nvu$692$1@nnrp1.deja.com>
Hi,
Can anyone tell me how to convert this csh command line into perl so
I can put it in my perl script? Thanks in advance...
find /u1 -name "*99*" -mtime +3 -exec rm -r {} \;
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 3 Aug 1999 23:10:16 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How can I know what modules are installed on server?
Message-Id: <Pine.HPP.3.95a.990803230637.26289F-100000@hpplus03.cern.ch>
On 3 Aug 1999, 99% Energy wrote:
> I don't think is such a bad idea to quote the entire article when replying
> in newsgroups.
Then you'd better rush along to the relevant news.admin.* group, where
the issue would be on-topic, and propose your exciting new rules for
usenet. Until you've convinced them that this is a good idea, you'd
better follow the guidance that's given in news.announce.newusers and
followed by the vast majority of seasoned usenauts. Well, unless you
find killfiles a nice place to be.
Now what was your perl language issue?
------------------------------
Date: 3 Aug 1999 21:38:25 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How can I trap/block a kill -9 signal
Message-Id: <7o7ngh$5gk$1@gellyfish.btinternet.com>
On 3 Aug 1999 11:21:30 -0700 Tom Christiansen wrote:
> [courtesy cc of this posting mailed to cited author]
>
> In comp.lang.perl.misc,
> "Ming" <fungs@logica.com> writes:
> :Does anyone out there know how to trap/ignore a 'kill -9' signal for a Perl
> :process.
>
> Yes, but you've have to break your kernel to do so.
>
Alternatively write your program in Informix 4GL on SCO unix ;-{ (If you
dont believe me I'll post the 'script' output ).
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Tue, 3 Aug 1999 15:53:57 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: How can I trap/block a kill -9 signal
Message-Id: <x3yyafsd4iy.fsf@tigre.matrox.com>
"Ming" <fungs@logica.com> writes:
> Does anyone out there know how to trap/ignore a 'kill -9' signal for a Perl
> process.
You need to have a look at the %SIG special hash. It is documented in
perlvar. You should be interested in trapping the INT signal. So,
you should have something like this in your code ..
$SIG{INT} = \&interrupt;
...
...
sub interrupt {
print "Someone hit Ctrl-C ..\n";
}
HTH,
Ala
------------------------------
Date: Tue, 3 Aug 1999 15:29:40 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Need Help Understanding a perl script
Message-Id: <x3yzp08d5nf.fsf@tigre.matrox.com>
"Diane" <tech1@magicnet.net> writes:
> I need some help from one of you experts out there. I teach a web
> development course which is mostly HTML that I know in my sleep. But, part
> of the course discusses perl and cgi. I have a brief perl script that
> basically just echoes back some form data. I have a basic understanding of
> it but could use a more line by line explanation to offer to my class.
>
> Any one interested in helping me out?
How about posting the code so that all of us can look at it? Like this
you'll get more (and probably quicker) feedback. I'm sure you'll even
get some suggestions for improving your code. You might even get to
like Perl, and start dreaming in Perl (like I sometimes do).
Ala
------------------------------
Date: Tue, 3 Aug 1999 18:27:15 +0100
From: Andrew Fry <andrewf@beausys.freeserve.co.uk>
Subject: Re: Newbie Q: Removing files from a folder
Message-Id: <1+6PFBAzZyp3Ewop@beausys.freeserve.co.uk>
In article <37a6ea5e_1@newsread3.dircon.co.uk>, Jonathan Stowe
<gellyfish@gellyfish.com> writes
>Andrew Fry <andrewf@beausys.freeserve.co.uk> wrote:
>> if (opendir(DIR,$foldername))
>> {
>> @filelist = grep { /\.$myext$/ } readdir(DIR);
>> closedir(DIR);
>> $numfound = $#filelist;
>> if ($numfound > 0)
>> {
>> print @filelist;
>> }
>> # delete files...
>> # $i = unlink(@filelist);
>> print "Folder: $foldername, file [*.$myext], found $numfound,
>> deleted $numdeleted.\n";
>> }
>> }
>> }
>>
>
>Unless $foldername is actually your current directory
It is ... see my first posting. I hadnt gotten around to the unlink
yet ... I wanted to sort out why the filelist didnt look right.
I think Ive sussed it now ... the problem is that the files in
some of these directories, although these show up as x.y (with
Windows Explorer), are actually x.y.lnk (ie shortcut) links!
So, I dont pick them up with my grep match! Doh!
> this wont work -
>you will need to provide the full path to your files: I will generally
>do this kind of thing -
>
> @filelist = map { $foldername . '/' . $_ } grep { /\.$myext$/} readdir(DIR);
>
>/J\
---
Andrew Fry
"Time flies like an arrow. Fruit flies like a banana". (Groucho Marx).
------------------------------
Date: Tue, 3 Aug 1999 15:14:27 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Newbie Q: Removing files from a folder
Message-Id: <x3y1zdkekx8.fsf@tigre.matrox.com>
Andrew Fry <andrewf@beausys.freeserve.co.uk> writes:
> I want a little utility that will tidy up various Win95/WinNT
> folders for me ...
So directories are being called "folders" these days? Interesting ..
------------------------------
Date: Tue, 3 Aug 1999 16:42:43 -0500
From: "Paul Glidden" <paul.glidden@unisys.com>
Subject: Re: Perl and Oracle using DBI
Message-Id: <7o7nok$62i$1@eanews1.unisys.com>
I question whether or not your DBD or DBI ever installed correctly.
What were the results of your "make test" when installing DBD::Oracle
I bet there were some problems there.
Secondly, subscribe to the mailing list dbi-users@isc.org
That is the proper place for those questions as is stated in the readme
file.
Did you read the readme file?
I don't think so
Arvind Krishnaswamy wrote in message <37A74C9B.4510611@altavista.com>...
>I am trying to set up my system to access an Oracle 8 database from
>Perl. I have installed the DBI module (version 1.13) and the DBD-Oracle
>module (version 1.03) retreived from
>CPAN. My environment seems to be set up correctly in that I can access
>the database by typing "sqlplus user/pwd" from the command line. But my
>test program always fails on
>the "connect" statement:
> use DBI;
> DBI->connect('DBI:Oracle:XYY, 'user', 'pwd');
>where XYZ is the database name, user is the userid and pwd is the
>password. The error is:
>
>install_driver(Oracle) failed: Can't load '..../Oracle/Oracle.so' for
>module DBD::Oracle: dlopen: cannot load
>'..../Oracle/Oracle.so' at '...../Dynaloader.pm line 168.
>
>The pertinent Oracle environment variables set are:
>ORACLE_SID
>ORACLE_HOME
>ORACLE_USERID
>
>Any help would be appreciated.
>
------------------------------
Date: Tue, 03 Aug 1999 14:57:14 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl CGI vs VB ASP
Message-Id: <37A765BA.B2EABA3@mail.cor.epa.gov>
DMSbclar wrote:
>
> I am about to embark on a project where I need to read input from a flat file
> on a unix box.
Okay, Perl will do that. But so will lots of other tools.
> I know VBScript for ASP, but that's not going to help. From my
> experience, VB is easy to follow (read, easy to hack out). I'm also a Unix
> guy, so I don't think Perl will be that difficult to learn. I can awk with the
> best of them. Unfortunately those toys are not native to the Wintel Oligopoly.
But gawk is available for win32 now, as far as I know. Still,
if you know awk and sed and C, then you'll probably find
Perl fairly intuitive. And if you can write the awk code
to do it, you can use a2p to convert to [sub-optimal] Perl
code.
I don't know enough about your background, but if you're
accustomed to unix and awk, you're probably at a level to get
the most out of either "Learning Perl" [the llama book] or
"Programming Perl" [the camel book].
Now what was your Perl question? :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 03 Aug 1999 21:33:36 GMT
From: pricerbumanto@my-deja.com
Subject: Re: Perl or CGI
Message-Id: <7o7n7g$5i0$1@nnrp1.deja.com>
In article <a1btcprmao.fsf@cyclone.jprc.com>,
Jason Reed <jcreed@cyclone.jprc.com> wrote:
> PerlCoder@Unix.com (CGI) writes:
(trancx')
> > Your answer was like recommending someone learn Esperanto instead of
> > English.
>
> Kio estas malbona pri esperanto?
Laux mia kompreno, "perlcoder" simple konstatas, ke la angla mutle pli
disvastigxas ol E-o, k en tre diversaj sferoj, k do sekve, proporcie pli
utila. Kompreneble, al mi sxajnas iom artajxa tiu kontrauxstaro de la
angla "kontraux" E-o; kial ne lerni ambaux la du lingvojn? Unue E-on,
cxar gxi estas relative multe pli lernebla, ecx por eneuxroplingvano,
due (gxis la atingebla nivelo) la anglan lingvon. Tamen cxu io simila
eblas, rilate al Perl k Python, mi ne pretas sugesti! ;-)
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 3 Aug 1999 16:03:18 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: perl s///e weirdism||bug
Message-Id: <7o7hum$cbb$1@nntp3.atl.mindspring.net>
Andrew Cannon wrote in message <37A73A1F.B7511A30@spam.sr.hp.com>...
:test.C contains the following:
<snip>
{
:test=1;
:}
:execute on the command line the following:
: perl -pi -e 's/(test=)(\d+);.*$/print $1.($2+1).";"/e' test.C
:test.C now contains
[snip]
:test=2;1
:}
:I was expecting:
[snip]
:test=2;
:}
:
:I have tried adding more parenthesis to control the execution flow,
:but I get the same result. If this is not a bug, can someone explain
:where the extra 1 comes from.
You are the bug <g> (it is your code produces the 1).
Your print was successful (which returns a 1) and that 1 is substituted
for the match. Each line up until the match is printed, then your match
is printed in the regex, then the substituted line is printed. The
substituted line consists of 1.
HTH
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
Imagination is more important than knowledge.
- Albert Einstein
------------------------------
Date: Tue, 3 Aug 1999 14:22:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: perl s///e weirdism||bug
Message-Id: <MPG.1210fd6cdff544e0989da6@nntp.hpl.hp.com>
In article <37A73A1F.B7511A30@spam.sr.hp.com> on Tue, 03 Aug 1999
11:51:11 -0700, Andrew Cannon <acannon@spam.sr.hp.com> says...
> test.C contains the following:
>
> // $Author:$
> // $Source:$
> // $Date:$
> // $Revision:$
> void main() {
> test=1;
> }
>
> execute on the command line the following:
> perl -pi -e 's/(test=)(\d+);.*$/print $1.($2+1).";"/e' test.C
...
> test=2;1
...
> I have tried adding more parenthesis to control the execution flow,
> but I get the same result. If this is not a bug, can someone explain
> where the extra 1 comes from.
When 'print' succeeds, it returns 1. What is happening is that during
the evaluation of the substitution part of the regex you are printing
the new data; then you are substituting the '1' which is the value
returned by the 'print', which is getting printed out in the '-p' loop.
Leave the 'print' out of the substitution.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 03 Aug 1999 23:19:57 +0200
From: Moritz Mertinkat <bluebit@gmx.net>
Subject: Perl seems to be LAME!
Message-Id: <37A75CFD.ADAC451E@gmx.net>
Hi,
I've got a big problem:
I'm using a text file (~1.11 MB) with about 10000 entries
for searching. Now, when I just run through all the lines
- without even doing *anything* - it takes up to 7 seconds!
And with the search algorithm about 11 seconds!
------------------------------------
Here's the code snippet:
$found = 0;
foreach $line (<FILE>) {
$match = 0;
foreach $term (@query) {
# Perform case insensitive comparison
if (!($line =~ /$term/i)) {
# Term did not match.
$match = 0;
last;
} else {
# Term matched
$match = 1;
}
}
if ($match == 1) {
$found = 1;
print "$line<br>\n";
}
}
if ($found == 0) {
print "No entries were found!<br>\n";
}
------------------------------------
Any ideas are welcome!
Thank you very much,
Moritz Mertinkat
------------------------------
Date: 3 Aug 1999 22:04:39 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl seems to be LAME!
Message-Id: <slrn7qeps9.oet.sholden@pgrad.cs.usyd.edu.au>
On Tue, 03 Aug 1999 23:19:57 +0200, Moritz Mertinkat <bluebit@gmx.net> wrote:
>Hi,
>
> I've got a big problem:
>
> I'm using a text file (~1.11 MB) with about 10000 entries
> for searching. Now, when I just run through all the lines
> - without even doing *anything* - it takes up to 7 seconds!
> And with the search algorithm about 11 seconds!
How long does it take to 'cat' the file ('type' I guess if your on windows)?
If that takes 7 seconds, then you probably want to invest in a new computer
and hard disk (or stop reading the file off a tape ;).
If that takes much less time, then I guess your script must be the
culprit.
>
>------------------------------------
>
> Here's the code snippet:
>
>$found = 0;
>
>foreach $line (<FILE>) {
^^^^^^
The perlsyn documentation tells us what perl syntax does, in this case it
says :
LABEL foreach VAR (LIST) BLOCK
^^^^
So you are using <FILE> in a list context.
What does the documentation that comes with perl say this will do :
perlop :
If a <FILEHANDLE> is used in a context that is looking for
a list, a list consisting of all the input lines is
returned, one line per list element. It's easy to make a
LARGE data space this way, so use with care.
In other words you just read the entire file into memory. This is often
slow. Although with a small file of only a meg or so it shouldn't be
cripling.
You could instead read one line of the file at a time like so :
while(<FILE>) { #$_ will contain the line read assuming there was a line left
>
> $match = 0;
>
> foreach $term (@query) {
>
> # Perform case insensitive comparison
>
> if (!($line =~ /$term/i)) {
This would become :
if (! /$term/i) { # $_ is used by default in the match
Although I personally would drop the ! and swap the if and else blocks
around.
>
> # Term did not match.
> $match = 0;
> last;
>
> } else {
>
> # Term matched
> $match = 1;
>
>
> }
> }
>
>
> if ($match == 1) {
> $found = 1;
>
> print "$line<br>\n";
> }
>
>}
>
>if ($found == 0) {
> print "No entries were found!<br>\n";
>}
There is no need for all that jumping through hoops, though I guess it
doesn't hurt too much. You want to indicate a match if all the terms
where found in the line.
So we can use something like:
LOOP: while (<FILE>) { #loop over each line of the file
foreach $term (@query) { #check each search term
next LOOP unless /$term/; #skip line if search term not found
}
$found=1; # we found a line that matched all the terms
print "$_<br>\n"; #$_ already ends in a \n, but in HTML it matters not
}
print "No entries were found!<br>\n" unless $found; #print if we found zip
This shouldn't have much of a speed increase however. I think it is more
readable, though. It is more efficient on memory which might make it faster
for a large file, but your file isn't that large...
Everything after this is only relevant for the 4 seconds spent doing the
searches.
Another possibility for a slow down is if @query has a lot of terms. You
are compiling each term into a regular expression for every line. You could
do that once only and a bit of time should be saved.
With modern perls you can use qr{} to compile a regex. The documentation
is in the perlop documentation (perldoc perlop). With older perls you
can use eval to create a subroutine that you call, or you can just
use eval to unroll the foreach loop.
A further concern is that /i is a slow on older perls (though I think it
has improved). It in all likelyhood (I don't know perl's internals, so
I'm guessing) prevents perl from optimising the regexes fully in cases where
$term contains a fixed string of reasonable length in any case.
So you might be able to improve that situation by converting each line
to lowercase (see the 'lc' function in perlfunc), and converting the
elements in @query to lowercase as well (once of course, not every time
through the loop) - you would need to keep the original line to display at
the end, but you might get a speed increase.
The best way to find out is to use a wonderful perl module called Benchmark.
See the 'perldoc Benchmark' documentation for details. I can't do it for you
since I don't know how what @query is like, and I also can't be bothered
at the moment.
--
Sam
Another result of the tyranny of Pascal is that beginners don't use
function pointers.
--Rob Pike
------------------------------
Date: Tue, 03 Aug 1999 22:44:39 +0100
From: Paul Reid <paulreid@cableinet.co.uk>
Subject: Re: Running scrips on own pc
Message-Id: <37A762C6.1DBFB619@cableinet.co.uk>
Thanks for the help folks.
I finally got it running with PWS from the scripts dir.
It doesn't run from the cgi-bin dir though .
Thanks
Oh And it seems I can type any old thing at the top my scripts now
#! perl-w * lol*
>
------------------------------
Date: Tue, 03 Aug 1999 22:09:45 +0100
From: Peter <pjw7@ukc.ac.uk>
Subject: tar
Message-Id: <37A75A99.5C9C@ukc.ac.uk>
I don't really know that much about unix, but if I download a file of
type .tar how do I open/decompress it?
Thanks
Peter
------------------------------
Date: Tue, 3 Aug 1999 16:38:38 -0500
From: "Paul Glidden" <paul.glidden@unisys.com>
Subject: Re: tar
Message-Id: <7o7ngs$5ru$1@eanews1.unisys.com>
Peter wrote in message <37A75A99.5C9C@ukc.ac.uk>...
>I don't really know that much about unix, but if I download a file of
>type .tar how do I open/decompress it?
tar -xvf filename
secondly, UNIX for dummies
------------------------------
Date: 3 Aug 1999 21:52:20 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: tar
Message-Id: <slrn7qep4k.ve.M.Ray@carlova.ulcc.ac.uk>
On Tue, 03 Aug 1999 22:09:45 +0100, Peter <pjw7@ukc.ac.uk> wrote:
>I don't really know that much about unix, but if I download a file of
>type .tar how do I open/decompress it?
tar is a format for collecting files together into a single archive file.
If you want to extract the files from within a perl program (which would
be the only sensible reason for posting this question to a perl newsgroup,
wouldn't it?), there is a module called Archive::Tar available from
CPAN which can be used for this. It includes documentation and a
sample program which uses the module.
If you want to extract the archive from the Unix command line, you're
asking in the wrong place. Consult the online manpage for tar. If
you still can't figure it out, ask on comp.unix.misc.
If you want to extract it on Winduhs, I've heard that WinZip can do
so, though I can't vouch for the accuracy of that.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: 3 Aug 1999 15:55:05 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: tar
Message-Id: <37a76539@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
Peter <pjw7@ukc.ac.uk> writes:
:I don't really know that much about unix, but if I download a file of
:type .tar how do I open/decompress it?
You open it with the open(2) system call. But I don't think you're
using open the way I do. :-)
The program is called, surprisingly enough, "tar". :-)
% man tar
Will tell you how to use it, as will
http://www.openbsd.org/cgi-bin/man.cgi?query=tar&apropos=0&sektion=1&manpath=OpenBSD+Current&format=html
Here are sample uses:
Extract contents:
% tar xf something.tar
Extract verbosely:
% tar xvf something.tar
List contents:
% tar tf something.tar
List verbosely:
% tar tvf something.tar
Many versions support compressed or gzipped or even bzip2'ed
files, for example:
Extract contents from gzipped version, verbosely:
% tar xzvf something.tar.gz
Hold on, what the devil is this doing in the perl group?
I thought I was in the unix shell group! Perhaps you did
as well.
--tom
--
"I have many friends who question authority. For some reason most of 'em
limit themselves to rhetorical questions."
--Larry Wall
------------------------------
Date: Tue, 3 Aug 1999 14:15:28 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: towards uploading binary files...
Message-Id: <MPG.1210fbc9cd4de5b6989da5@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7o7c2d$t0l$1@nnrp1.deja.com> on Tue, 03 Aug 1999 18:23:23
GMT, irf@netexecutive.com <irf@netexecutive.com> says...
> to upload binary files (eg, gif etc), i tried using this code:
> (data comes from an <INPUT TYPE=FILE> element)
> ----------------------------------------------
Use 'binmode(STDIN);' here. It is essential for Windows/DOS and won't
hurt otherwise.
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
Where is the check that you actually read the number of bytes expected?
> $dat=$buffer;
Why not read directly into $dat?
> #these next lines to get rid of data that is not part of the file
> $dat=~s/.*\n.*\n.*\n//;
> $dat=~s/\-+\d+\-+//;
> $dat=~s/\n//g;
> $dat=~s/\r//g;
Without seeing what comes back in fact, I can only guess what you are
doing here. There must be three lines of text that you are stripping,
and some sort of numerical tag. But stripping all the "\n" and "\r"
characters must be wrong, because it would damage the contents of the
image, which may well contain those bytes.
> print "Content-type: image/gif\n\n";
> print $dat;
> -------------------------------------------
> funnily enough, the gif's size is retained but the image does not
> come through. (i get a correct bounding-box, but broken image icon).
> also, if i save it, the new file size is smaller than it should be.
No surprise. You have mangled it!
> could someone please help me out with this - i know there are libraries
> out there that can do this easily, but i want to understand what i am
> doing wrong (which i am sure are a lot of things).
HTH.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 03 Aug 1999 14:59:50 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: using __PACKAGE__
Message-Id: <37A76656.5090CBBB@mail.cor.epa.gov>
Paul Glidden wrote:
>
> I think the actual problem here results from people who's minds aren't open
> to new programming constructs.
>
> Coming from a c++ background, many of perl's constructs seemed
> counterintuitive while reading the documentation.
>
> So, I bought a book
>
> Programming Perl 2nd edition. Of which Tom was one of the authors.
>
> In no way can these constructs be better explained, then if one is open
> minded, the simplicity of such becomes apparent.
>
> Closed mindedness is no excuse for discussing the constructs of a
> programming language.
>
> This thread should just be over with.
I agree. How about if you call someone a Nazi? That might
do it. :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 3 Aug 1999 16:40:03 +0100
From: "LA" <louis@alten.net.nospam>
Subject: Using the Win32:: module from a non-Win32 machine.
Message-Id: <efJp3.150$cQ4.19227@typhoon01.swbell.net>
First, a big thanks to Dave Roth for putting the paragraph "The Deal with
UserCheckPassword()" on his Win32::adminmisc web page
http://www.roth.net/perl/adminmisc/
(to say nothing of writing most of the modules).
Scenario: I need to validate a user's Windows ID and password from a
non-Windows machine. The only way I can think of is using a separate script
on a Windows machine (maybe the PDC, but not necessarily), and connecting to
that script from the non-Windows machine.
Then, I would have to handle the protocol between the scripts, and
encrypt/decrypt the passwords while sending them over the network, among
other things.
Are there any other ways to do this?
BTW, are there functions in the Win32 API that implement a version of
UserCheckPassword()?
Thanks,
Louis
------------------------------
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". 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 V9 Issue 353
*************************************