[11800] in Perl-Users-Digest
Perl-Users Digest, Issue: 5400 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 16 14:07:39 1999
Date: Fri, 16 Apr 99 11:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 16 Apr 1999 Volume: 8 Number: 5400
Today's topics:
Complex sort help needed. Please! troutmask338@my-dejanews.com
Re: Complex sort help needed. Please! (Andrew Johnson)
Re: Complex sort help needed. Please! (Larry Rosler)
Re: Complicated reg. exp. question <eedalf@eed.ericsson.se>
copyto URL <info@grobler.co.za>
Re: FAQ 1.10: When shouldn't I program in Perl? <emschwar@rmi.net>
fork processes in batches senthilr@email.com
Re: FREE Certifications Offered Online to perl programm (Joe McMahon)
Re: FREE Certifications Offered Online to perl programm <bowman@montana.com>
Re: FREE Certifications Offered Online to perl programm <gellyfish@gellyfish.com>
Re: FREE Certifications Offered Online to perl programm <uri@home.sysarch.com>
Re: FREE Certifications Offered Online to perl programm (Andrew Johnson)
Re: FREE Certifications Offered Online to perl programm (Larry Rosler)
Re: goto or recursion? <Wm.Blasius@ks.sel.alcatel.de>
How to write images to file <alyciad@c-esystems.com>
mldbm, How can I change the serialiser method of existi joel@testtutor.com
Re: Need info on Perl vs. VB for manager persuasion <cassell@mail.cor.epa.gov>
Re: Need info on Perl vs. VB for manager persuasion kdphillips@my-dejanews.com
Perl Stopping Before Substitution is complete <jim@*nospam*network-2001.com>
Re: Perl Stopping Before Substitution is complete (Andrew Johnson)
Re: Perl Stopping Before Substitution is complete (Bart Lateur)
Re: Perl Stopping Before Substitution is complete <jim@*nospam*network-2001.com>
Re: Recursion not working properly <cassell@mail.cor.epa.gov>
Re: TZ not used in winnt Date/Time routines <cassell@mail.cor.epa.gov>
Re: TZ not used in winnt Date/Time routines (Larry Rosler)
Re: warnings on Win32 <Allan@due.net>
Re: why won't this statement work @array=<*.*> (I R A Aggie)
Re: why won't this statement work @array=<*.*> <tchrist@mox.perl.com>
Re: why won't this statement work @array=<*.*> <tchrist@mox.perl.com>
Re: Would anyone care to teach me perl? <hunt@queen.es.hac.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 16 Apr 1999 16:14:24 GMT
From: troutmask338@my-dejanews.com
Subject: Complex sort help needed. Please!
Message-Id: <7f7nkm$1l6$1@nnrp1.dejanews.com>
Hello!
I'm trying to sort lines in a text database based on multiple criteria and am
having no luck.
I have an unsorted textfile containing space-delimited fields for the name, IP
address and score for a variety of web servers, like this:
myServer 123.345.567.765 29
yourServer 234.432.234.432 105
hisServer 123.345.567.765 29
herServer 234.432.234.432 105
theirServer 111.222.111.222 13
anotherServer 123.345.567.765 29
yetAnotherServer 255.244.255.244 105
As you can see, several servers share the same IP address and, therefore, have
the same score.
What I want to do is sort this list with highest scoring servers listed first
and sorted by like IP addresses and then alphabetically by server name. The
output for the above example would be:
herServer 234.432.234.432 105
yourServer 234.432.234.432 105
yetAnotherServer 255.244.255.244 105
anotherServer 123.345.567.765 29
hisServer 123.345.567.765 29
myServer 123.345.567.765 29
theirServer 111.222.111.222 13
so we have the highest-scoring servers at the top, sorted by IP address when
the score is the same, then sorted alphabetically on the server name.
I can sort on individual fields to produce, for instance, the list sorted
based upon score only, but how do I incorporate several criteria to create a
"sub-sort"? I've tried putting multiple sorts into the sort subroutine with
the result that the last sort produces the final result. That is, if I sort
first on score, then on IP address, then on name, I get a list sorted by name
only.
Any tips/help greatly appreciated!!!!!
Thanks!
-Les Brown
lbrown2@uswest.net
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 16 Apr 1999 16:59:22 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Complex sort help needed. Please!
Message-Id: <K%JR2.601$KO5.79644@news1.rdc1.on.wave.home.com>
In article <7f7nkm$1l6$1@nnrp1.dejanews.com>,
troutmask338@my-dejanews.com <troutmask338@my-dejanews.com> wrote:
! Hello!
!
! I'm trying to sort lines in a text database based on multiple criteria and am
! having no luck.
did you look at the faq's?
perlfaq4.pod: How do I sort an array by (anything)?
(which has examples of sorting on multiple fields)
! I have an unsorted textfile containing space-delimited fields for the name, IP
! address and score for a variety of web servers, like this:
!
! myServer 123.345.567.765 29
! yourServer 234.432.234.432 105
! hisServer 123.345.567.765 29
! herServer 234.432.234.432 105
! theirServer 111.222.111.222 13
! anotherServer 123.345.567.765 29
! yetAnotherServer 255.244.255.244 105
!
! As you can see, several servers share the same IP address and, therefore, have
! the same score.
!
! What I want to do is sort this list with highest scoring servers listed first
! and sorted by like IP addresses and then alphabetically by server name. The
one way:
#!/usr/bin/perl -w
use strict;
chomp(my @data = <DATA>);
my @sorted = map{$_->[0]}
sort{$b->[3] <=> $a->[3] ||
$a->[2] cmp $b->[2] ||
$a->[1] cmp $b->[1]
}
map{[$_,split]} @data;
print join("\n",@sorted);
__DATA__
myServer 123.345.567.765 29
yourServer 234.432.234.432 105
hisServer 123.345.567.765 29
herServer 234.432.234.432 105
theirServer 111.222.111.222 13
anotherServer 123.345.567.765 29
yetAnotherServer 255.244.255.244 105
Note: for simplicity, this one does stringwise comparisons on the
whole IP address (field 2)---if you want a more specific sort on IP
addresses use the techniques from the perlfaq4 entry noted above or
check deja-news for previous postings on this issue.
regards
andrew
------------------------------
Date: Fri, 16 Apr 1999 10:09:32 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Complex sort help needed. Please!
Message-Id: <MPG.11810ea28353d97c9898c7@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7f7nkm$1l6$1@nnrp1.dejanews.com> on Fri, 16 Apr 1999
16:14:24 GMT, troutmask338@my-dejanews.com <troutmask338@my-
dejanews.com> says...
> I'm trying to sort lines in a text database based on multiple criteria and am
> having no luck.
Luck has little to do with it.
<SNIP> of detailed problem description, but no code.
> Any tips/help greatly appreciated!!!!!
perlfaq4: "How do I sort an array by (anything)?"
This has several examples of multi-field sorting.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 16 Apr 1999 18:16:07 +0200
From: Alex Farber <eedalf@eed.ericsson.se>
To: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Complicated reg. exp. question
Message-Id: <37176247.7BF2EBF@eed.ericsson.se>
[mailed + posted]
Jonathan Feinberg wrote:
> Unless I am misreading your code, it seems that each of these data
> chunks is on its own line. If that's the case, why are you going
> through these complicated regex gymnastics? If you simply read the
> file line by line, then skipping comments and blank lines looks like
> this:
>
> while (<THEFILE>) {
> next if /^!/ || /^\s*$/;
Thanks for your reply, but it is unfortunately more complicated -
those are some phone switches assembler files and they can have
comments after some instruction, like this:
JEC DR0,0,L1; ! IF LEGP:LDIAMPROC = ZYES THEN !
and that PCORI can appear not only at the line beginning:
END; PCORI:BLOCK=SHMM,IA=H'2BBB;
> Do you need for your regexp to be so paranoid? In other words, it
> seems you're not so much doing detection of a particular pattern as
> you are checking the syntax. If you know that the lines are
> well-formed, then you could just
>
> s/\bCI=[A-Z]{5}\d{4}\b/CI=$whatever/ if /^PCORI/;
The problem here is that I have some PCORI-lines with CI=$whatever
already inserted (in previous runs of my script) and some without...
/Alex
------------------------------
Date: Fri, 16 Apr 1999 18:28:49 +0200
From: Phillip Grobler <info@grobler.co.za>
Subject: copyto URL
Message-Id: <37176540.88D27949@grobler.co.za>
How can one copy a file to a url or from a url from a perl script
--
Phillip Grobler
______________________________________
C.a.T.S. (Computer Assisted Telephony Systems CC),
P.O. Box 2238, Bellville, 7535 South Africa.
Tel +27 21 930 4469 Mobile +27 82 787 9502 Fax +27 21 930 1829
http://www.grobler.co.za
______________________________________
------------------------------
Date: 16 Apr 1999 10:02:29 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: FAQ 1.10: When shouldn't I program in Perl?
Message-Id: <xkfpv54lfje.fsf@valdemar.col.hp.com>
wescott@cygnus.ColumbiaSC.NCR.COM (Mike Wescott) writes:
> In article <37154637@cs.colorado.edu> Tom Christiansen writes:
> > When your manager forbids it -- but do consider replacing them :-).
>
> Shouldn't that be "him"? Or is this a bit of gender neutrality?
Probably the latter, but it's okay-- he's in excellent company in his
choice of pronouns:
<URL:http://uts.cc.utexas.edu/~churchh/austheir.html>
-=Eric
------------------------------
Date: Fri, 16 Apr 1999 17:20:17 GMT
From: senthilr@email.com
Subject: fork processes in batches
Message-Id: <7f7rg7$5ha$1@nnrp1.dejanews.com>
Hi:
I am writing a job dispatching program. The goal is to keep
n number of jobs running all the time. Right now I fork n jobs
and wait for those n jobs to complete, then I fork another n jobs.
The thing is sometimes a few jobs finish early and cpu time is wasted
in waiting for the rest of the jobs to finish before I can submit the
next batch. What I would like to do is, say n = 10, the dispatcher should
dispatch 10 jobs, if 1 job finishes, the dispatcher should submit one more
to keep the number of running jobs 10.
What would be the best approach to do this.
TIA,
..Senthil.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 16 Apr 1999 11:55:33 -0400
From: joe.mcmahon@gsfc.nasa.gov (Joe McMahon)
Subject: Re: FREE Certifications Offered Online to perl programmers
Message-Id: <joe.mcmahon-1604991155330001@prtims.stx.com>
In article <x7g161m9qw.fsf@home.sysarch.com>, Uri Guttman
<uri@home.sysarch.com> wrote:
>this is a fairly bogus test. i just got a 4.25 (or 34/40 right) score so
>i am certified as a master perl hacker. hell i BOUGHT for $3 a
>certificate from the perl mongers at the last conference that said the
>same thing. some of the questions are just wrong like saying the
>difference between use and require is compile time vs. runtime without
>mentioning import. also a perl/tk question was asked which is stupid as
>it is not needed to be fluent in perl. other questions were not clear or
>the answer choices were ambiguous. on most of my wrong answers i
>actually timed out since i wasn't paying attention to the tiny ticker in
>the message bar.
Plus 90% of the questions were "what output does this give". Well, since
I have Perl running in the other window here - cut paste ...
I agree on the Tk question. Never use it. You also noted the crypt question
in which two answers were identical - AND wrong?
--- Joe M.
------------------------------
Date: Fri, 16 Apr 1999 10:10:56 -0600
From: "bowman" <bowman@montana.com>
Subject: Re: FREE Certifications Offered Online to perl programmers
Message-Id: <HiJR2.3$P03.260@newsfeed.slurp.net>
Uri Guttman <uri@home.sysarch.com> wrote in message
news:x7g161m9qw.fsf@home.sysarch.com...
> >>>>> "l" == ludlow1435 <ludlow1435@my-dejanews.com> writes:
>
> this is a fairly bogus test. i just got a 4.25 (or 34/40 right) score so
> i am certified as a master perl hacker. http://www.northernlight.com
Similar 'tests' have appeared in many language newsgroups. Probably just a
headhunter trying to amass a database of people who are not completely
incompetent in any given language. You'll know when you start getting the
spam, "A colleague gave my your name as a master <someLanguage> programmer
......"
------------------------------
Date: 16 Apr 1999 17:17:34 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: FREE Certifications Offered Online to perl programmers
Message-Id: <3717629e@newsread3.dircon.co.uk>
Leo Schalkwyk <schalkwy@minnie.RZ-Berlin.MPG.DE> wrote:
> Uri Guttman (uri@home.sysarch.com) wrote:
> : >>>>> "l" == ludlow1435 <ludlow1435@my-dejanews.com> writes:
>
> : l> To qualify as a Certified perl Programmer, you must pass the
> : l> examination with a score of 2.75 or higher. To be certified as a
> : l> Master perl Programmer, you must obtain a score of 4.00 or higher.
>
> : this is a fairly bogus test. i just got a 4.25 (or 34/40 right) score so
> : i am certified as a master perl hacker. hell i BOUGHT for $3 a
>
> Well I know at most a tenth as much as Uri and I got 4.17
I cheated like hell and got 4.53 ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
------------------------------
Date: 16 Apr 1999 12:48:29 -0400
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: FREE Certifications Offered Online to perl programmers
Message-Id: <x7btgomrz6.fsf@home.sysarch.com>
>>>>> "JS" == Jonathan Stowe <gellyfish@gellyfish.com> writes:
JS> Leo Schalkwyk <schalkwy@minnie.RZ-Berlin.MPG.DE> wrote:
>> Uri Guttman (uri@home.sysarch.com) wrote:
>> : >>>>> "l" == ludlow1435 <ludlow1435@my-dejanews.com> writes:
>>
>> : l> To qualify as a Certified perl Programmer, you must pass the
>> : l> examination with a score of 2.75 or higher. To be certified as a
>> : l> Master perl Programmer, you must obtain a score of 4.00 or higher.
>>
>> : this is a fairly bogus test. i just got a 4.25 (or 34/40 right) score so
>> : i am certified as a master perl hacker. hell i BOUGHT for $3 a
>>
>> Well I know at most a tenth as much as Uri and I got 4.17
JS> I cheated like hell and got 4.53 ...
there was one question in particular that bothered me. what was the
difference between the grep and the foreach loop with push/if
statement. they seemed identical to me and the answers all looked bogus.
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
------------------------------
Date: Fri, 16 Apr 1999 17:10:23 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: FREE Certifications Offered Online to perl programmers
Message-Id: <3aKR2.788$KO5.79599@news1.rdc1.on.wave.home.com>
In article <x7g161m9qw.fsf@home.sysarch.com>,
Uri Guttman <uri@home.sysarch.com> wrote:
! >>>>> "l" == ludlow1435 <ludlow1435@my-dejanews.com> writes:
!
! l> To qualify as a Certified perl Programmer, you must pass the
! l> examination with a score of 2.75 or higher. To be certified as a
! l> Master perl Programmer, you must obtain a score of 4.00 or higher.
!
! this is a fairly bogus test. i just got a 4.25 (or 34/40 right) score so
! i am certified as a master perl hacker. hell i BOUGHT for $3 a
! certificate from the perl mongers at the last conference that said the
! same thing.
heck, I got three years worth of 'Certified Perl Developer'
certificates from Plover systems for free (backdated with renewal)
--- I value them much more highly than my Master certificate from
TekMetrics, and there were no silly tests involved :-)
regards
andrew
------------------------------
Date: Fri, 16 Apr 1999 10:36:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FREE Certifications Offered Online to perl programmers
Message-Id: <MPG.1181150b6f1183659898c9@nntp.hpl.hp.com>
In article <3717629e@newsread3.dircon.co.uk> on 16 Apr 1999 17:17:34
+0100, Jonathan Stowe <gellyfish@gellyfish.com> says...
> Leo Schalkwyk <schalkwy@minnie.RZ-Berlin.MPG.DE> wrote:
> > Uri Guttman (uri@home.sysarch.com) wrote:
> > : >>>>> "l" == ludlow1435 <ludlow1435@my-dejanews.com> writes:
> >
> > : l> To qualify as a Certified perl Programmer, you must pass the
> > : l> examination with a score of 2.75 or higher. To be certified as a
> > : l> Master perl Programmer, you must obtain a score of 4.00 or higher.
> >
> > : this is a fairly bogus test. i just got a 4.25 (or 34/40 right) score so
> > : i am certified as a master perl hacker. hell i BOUGHT for $3 a
> >
> > Well I know at most a tenth as much as Uri and I got 4.17
>
> I cheated like hell and got 4.53 ...
I didn't "cheat" at all (I didn't think it was an 'open-book' exam), and
got over 4. That included guessing at things I know nothing about (tk)
or little about (OOP).
In regard to the $3 certificate that Uri mentioned, mine (bought at the
same time as his) reads "Certifiable Perl Pornographer". I'll stand by
that!
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 16 Apr 1999 18:36:38 +0200
From: William Blasius #42722 <Wm.Blasius@ks.sel.alcatel.de>
To: Slav Inger <vinger@ford.com>
Subject: Re: goto or recursion?
Message-Id: <37176716.41C67EA6@ks.sel.alcatel.de>
[ a copy of this posting was sent to Slav Inger <vinger@ford.com>]
Slav Inger wrote:
>
> Hello,
>
> I have a situation where a sub1 calls sub2. Upon return from sub2, sub1
> should re-execute (sentinnel loops don't apply in this case). I'm not a
> big fan of goto statements, so I'm trying to decide whether it's better
> to use a goto to send control to the beginning of sub1, or to make a
> recursive call from sub1 to itself - I wonder if I'm going to run out of
> stack space sooner or later with the recursion approach.
>
> Any ideas?
The first question that occurs to me is "Why don't you just enclose
sub1 in an outer loop structure?". I'm sure there must be a reason,
but I can't imagine what it is.
hth
Wm Blasius
Stuttgart
--
...now I'm <wm.blasius@ks.sel.alcatel.de> - no matter what my mail
server says!
------------------------------
Date: Fri, 16 Apr 1999 09:58:11 -0700
From: "Alycia Dasmann" <alyciad@c-esystems.com>
Subject: How to write images to file
Message-Id: <924281609.284.13@news.remarQ.com>
I am working with a SQL Server 7 database storing images to be displayed
eventually on a website. The field is an image datatype.
I want to be able to open a recordset and write the image to a temporary
file and then load it into the web page. The problem I'm having is the file
seems to be twice the size as it should be and appears to be spaced.
Here's what I have so far...
$myFile = 'D:\\Program Files\\temp.bmp';
open(DESTINATION,">$myFile")||die "File open error " . $!;
binmode(DESTINATION);
$FileData = $rs->Fields('SupplierLogo')->Value||'';
print(DESTINATION $FileData);
close(DESTINATION);
$rs->Close;
Alycia Dasmann
------------------------------
Date: Fri, 16 Apr 1999 16:32:45 GMT
From: joel@testtutor.com
Subject: mldbm, How can I change the serialiser method of existing db's
Message-Id: <7f7ond$2n5$1@nnrp1.dejanews.com>
I have a number of databases which are stored using mldbm with the Data Dumper
serialiser and would like to change them to the Storable serialiser (becuase I
have heard that it is quicker). I assumme that all I have to do is open the db
with one serialiser and save it with another but I am not sure how to do this
change in the middle of a script.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 16 Apr 1999 10:17:50 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Need info on Perl vs. VB for manager persuasion
Message-Id: <371770BE.A372BA8B@mail.cor.epa.gov>
Keith Phillips wrote:
>
> The IT manager at my company wants me to come up with a Perl-
> vs-VB point sheet. I checked the FAQs, but came up empty. Is
> there already a document somewhere that compares Perl to VB?
I suspect that there are 765.4 such documents out there on the web,
and 765.399999 of them are incorrect and/or out of date. Be
wary of advice from strangers when the advice cannot be verified
[including this post, of course].
> [ ... or do I need to write one and post it for all to use? :-) ]
Yes.
I work with a hacker who has programmed in VB (among several other
languages), and he is quite frustrated with the rate at which the
core language has changed over time. That seems like a serious
drawback to me.
OTOH, it may be easier to use VBA for automation within Micro$oft
Office products, if only because the documentation for the details
seems to be better for VB. I read in the win32-perl-users listserv
just a couple weeks ago that someone was writing his code in Perl
using some of the Win32 modules, but that the lack of docs and
examples to do detailed fiddling in Excel and Word was hindering
his progress. He basically ended up writing the code in VB, then
figuring out what the translation was. Didn't look optimal.
You may want to check on the aforementioned listserv. I saw there
some benchmarks on PerlSCript vs VBScript (and 20 other alternatives)
for webservers. Of course, Perl won.
You may find yourself recommending VB for automating Office apps,
and Perl elsewhere. That's not unreasonable. No language can be
the absolute best at everything. Anyone who tells you their language
can do everything, and should be used to do everything.. well, just
give them another Prozac and pat them on the head and don't get
them upset when they're near a weapon. :-)
HTH,
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: Fri, 16 Apr 1999 17:07:26 GMT
From: kdphillips@my-dejanews.com
Subject: Re: Need info on Perl vs. VB for manager persuasion
Message-Id: <7f7qo7$4s8$1@nnrp1.dejanews.com>
In article <7f76tb$qp7$1@solti3.sdm.de>,
sb@engelschall.com (Steffen Beyer) wrote:
> Well, basically I'd say that whenever you need to deal with the proprietary
> innards of WinWord or Excel (i.e., VB for Applications), you're stuck with
> VBA anyway.
Understood. We're using MS Access for *very minor* database work, so VBA is
really not a problem...
> All else I'd rather do with Perl because this makes you independent of a
> monopolist (M$) determined to squeeze the last cent out of you...
>
> So far for guts feeling and political reasoning.
Yeah, but we agree. :->
[ very good tech args snipped ]
> The problem certainly is how to convince a suit, because in most cases
> the job can be done with either language.
This is the sticking point. The manager in question is NOT a programmer,
therefore your arguments would not work with her.
> Especially if your manager is misguided by FUD into believing there'd be
> no support for Perl etc., which is simply not true (see Perl Clinic,
> Active State etc. besides USENET newsgroups).
Amazingly enough, she is open-minded *if* you can provide a sound, logical
argument for your side.
> An argument that might convince him is that you can say that you will be
> able to develop faster under Perl and that maintenance will also be
> easier (i.e.: cheaper) under Perl.
This is where the trade journals work against me. She can easily see all the
ads / articles /editorials for and about VB; aren't too many about Perl...
> Of course this is not true for a well-written VB script compared with a
> quick-and-dirty-hack in Perl...
Given.
> But I dare to allege that a programmer equally well-trained in Perl and
> VB will always prefer Perl and will also be faster in Perl and produce
> better code - but I might be biased, as I have much less experience in
> VB than in Perl... :-)
<rant> I've been working in VB for over 4 years, and Perl for not quite a
year now, and I can honestly say I am quite fed up with VB and Micro$loth in
general. Each successive version of VB is more bloated, with increasingly
cryptic hoops to jump through just to accomplish the simplest tasks. Probably
the best version of VB that's existed to date would probably be 5.0 (or 3.0
if you want to include 16-bit), and it's just gone down a greased slope with
version 6. </rant>
Keith Phillips
kdp@hom.net
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 16 Apr 1999 12:07:04 -0500
From: "Jim" <jim@*nospam*network-2001.com>
Subject: Perl Stopping Before Substitution is complete
Message-Id: <7f7qmp$st7$1@news3.infoave.net>
I have a script that replaces some text in a file with other text,
however it doesnt remove all of the old text, it stops at |... is there
a way to get around this problem?
Here's the problem part:
sub replaceit{
open(DATABASEF, "+<$path/database.txt");
flock(DATABASEF, LOCK_EX);
@data_infoF = <DATABASEF>;
seek(DATABASEF, 0, 0);
foreach (@data_infoF){
s/the|text|to|be|replaced/text|to|replace|other|text/;
}
print DATABASEF @data_infoF;
close(DATABASEF);
print "done";
}
thanks for any help,
Jim
------------------------------
Date: Fri, 16 Apr 1999 17:17:18 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Perl Stopping Before Substitution is complete
Message-Id: <ygKR2.860$KO5.79599@news1.rdc1.on.wave.home.com>
In article <7f7qmp$st7$1@news3.infoave.net>,
Jim <jim@*nospam*network-2001.com> wrote:
! I have a script that replaces some text in a file with other text,
! however it doesnt remove all of the old text, it stops at |... is there
! a way to get around this problem?
!
! Here's the problem part:
!
! sub replaceit{
! open(DATABASEF, "+<$path/database.txt");
! flock(DATABASEF, LOCK_EX);
! @data_infoF = <DATABASEF>;
! seek(DATABASEF, 0, 0);
! foreach (@data_infoF){
! s/the|text|to|be|replaced/text|to|replace|other|text/;
You do know that the | character is the alternation
operator in the pattern side of a substitution right?
Are you trying to replace 'the' OR 'to' OR 'be' ... with
the replacement text? Maybe you mean
s/the\|text\|to.../text|to|be.../;
Or you could look at the quotemeta() function, or the \Q \E
escape sequences.
regards
andrew
------------------------------
Date: Fri, 16 Apr 1999 17:18:32 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Perl Stopping Before Substitution is complete
Message-Id: <37177059.330318@news.skynet.be>
Jim wrote:
>I have a script that replaces some text in a file with other text,
>however it doesnt remove all of the old text, it stops at |... is there
>a way to get around this problem?
> s/the|text|to|be|replaced/text|to|replace|other|text/;
This trips up many newbies: the "|" character is special for regexes
(the left side). It indicates alternatives: this substitution actually
looks for ANY of "the", "text", .... You get the picture.
Precede each "|" with "\", and you're set.
s/the\|text\|to\|be\|replaced/text|to|replace|other|text/;
Bart.
------------------------------
Date: Fri, 16 Apr 1999 12:25:45 -0500
From: "Jim" <jim@*nospam*network-2001.com>
Subject: Re: Perl Stopping Before Substitution is complete
Message-Id: <7f7rpn$tk5$1@news3.infoave.net>
thanks, got it now
Jim
Bart Lateur <bart.lateur@skynet.be> wrote in message
news:37177059.330318@news.skynet.be...
| Jim wrote:
|
| >I have a script that replaces some text in a file with other text,
| >however it doesnt remove all of the old text, it stops at |... is
there
| >a way to get around this problem?
|
| > s/the|text|to|be|replaced/text|to|replace|other|text/;
|
| This trips up many newbies: the "|" character is special for regexes
| (the left side). It indicates alternatives: this substitution actually
| looks for ANY of "the", "text", .... You get the picture.
|
| Precede each "|" with "\", and you're set.
|
| s/the\|text\|to\|be\|replaced/text|to|replace|other|text/;
|
| Bart.
------------------------------
Date: Fri, 16 Apr 1999 09:45:14 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Recursion not working properly
Message-Id: <3717691A.DA8E5A78@mail.cor.epa.gov>
Ala Qumsieh wrote:
>
> "Mike Rizzo" <mrizzo@ismd.ups.com> writes:
>
> > I have a perl script in wihch a recursive call that I am attempting is not
> > executing properly. The sub is called coparedirs(), when I call comparedirs
> > from inside
> > comparedirs, it does start exectuing compare dirs, but it seems as if the
> > original
> > call to comparedirs never completes running. Is there something I am missing
> > about recursion in Perl that I should know about before attempting this
> > execution.
>
> Let me guess ...
> your comparedirs() subroutine contains an:
>
> exit;
>
> statement on line 5. Am I correct?
Line 17.
I used the PSI::ESP module, since Doris was still over at gellyfish.com
:-)
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: Fri, 16 Apr 1999 09:48:43 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: TZ not used in winnt Date/Time routines
Message-Id: <371769EB.EDE2E4E8@mail.cor.epa.gov>
Jonathan Stowe wrote:
>
> john gury <gury@interaccess.com> wrote:
> > Does anyone know how to get the TZ var to work under winnt perl?
> > I'm showing that regardless of TZ settings the timezone used is the
> > unadjusted windows system timezone. Is this another "use a real
> > OS to get it to work" issue?
>
> I seem to recall it depends with whose C libraries the Perl was built.
> Anyhow it shouldnt matter the NT settings should work properly. But I
> would advocate switching OS just for the hell of it.
The easiest kludge on win32 is stuffing the value of TZ into %ENV
yourself. But that's still a kludge, and has to be done for each such
program.
Unfortunately, for most people `get a better OS' is even less
realistic than `ask your boss to buy you a faster machine'.
David
--
David Cassell, OAO
cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541)
754-4468
mathematical statistician fax: (541)
754-4716
------------------------------
Date: Fri, 16 Apr 1999 10:24:05 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: TZ not used in winnt Date/Time routines
Message-Id: <MPG.1181120cdcf335429898c8@nntp.hpl.hp.com>
In article <371769EB.EDE2E4E8@mail.cor.epa.gov> on Fri, 16 Apr 1999
09:48:43 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
> Jonathan Stowe wrote:
> > john gury <gury@interaccess.com> wrote:
> > > Does anyone know how to get the TZ var to work under winnt perl?
> > > I'm showing that regardless of TZ settings the timezone used is the
> > > unadjusted windows system timezone. Is this another "use a real
> > > OS to get it to work" issue?
> >
> > I seem to recall it depends with whose C libraries the Perl was built.
> > Anyhow it shouldnt matter the NT settings should work properly. But I
> > would advocate switching OS just for the hell of it.
>
> The easiest kludge on win32 is stuffing the value of TZ into %ENV
> yourself. But that's still a kludge, and has to be done for each such
> program.
That seems to depend on the version of perl, as Jonathan said. The
ActiveState perl that most of us are now using takes no notice of
$ENV{TZ} for localtime. But the MKS ToolKit versions of perl 5.002 and
5.003 do respect it.
I remember a long time ago finding code in the source for ctime etc. in
the M$ Visual C++ 5.0 library that looks for $ENV{TZ} before consulting
the system clock. Evidently ActivePerl is bound with a different
library.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 16 Apr 1999 12:07:28 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: warnings on Win32
Message-Id: <7f7n87$6ug$1@camel19.mindspring.com>
David Cantrell wrote in message <3717064e.150399593@news.insnet.net>...
:On Thu, 15 Apr 1999 22:21:55 GMT, "Allan M. Due" <All@n.due.net>
:enlightened us thusly:
:>Gus <spg@quokka.com> wrote in message
:>news:3716518a.58650915@news.earthlink.net...
:>: Seems simple but I can't figure how to turn on warnings in Win32
:>: scripts (command line is not a problem)
:>:
:>: Unix is a layup:
:>: #! /usr/bin/perl -w
:>:
:>: but since Win32 doesn't recognize the shebang, how would I turn on
:>: warnings?
:>
:>Well, that is not quite true. The #! is recognized (in fact is has to be
:>there)
:
:Not true. Windows uses the file extension to determine what binary
:executable to use to open the file. Perl itself looks at the #! but
:it is not required.
:
:I can't be bothered to test this, but is the space between the #! and
:the /usr/bin/perl breaking it?
Now wait, he wants -w to work. If so, then both #! and perl (with the
caveats from my first post) are required. If we don't care about flags then
one can dispense with the shebang. Testing would have revealed that the
space does not matter.
#! /usr/bin/perl -w
would work just fine.
HTH
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
I'd rather have a free bottle in front of me than a prefrontal lobotomy.
- Fred Allen
------------------------------
Date: 16 Apr 1999 16:14:41 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: why won't this statement work @array=<*.*>
Message-Id: <slrn7heokc.8gd.fl_aggie@stat.fsu.edu>
On Fri, 16 Apr 1999 11:18:33 -0400, Slav Inger
<vinger@ford.com>, in <371754C9.C3570D82@ford.com> wrote:
+ Try this: @array = <*>;
+ This should work on all platforms.
Depends on how one defines "work". As I understand it, globbing (<*>)
is dependent upon an underlying shell, csh under unix, and whatever under
Win3/Win9x/WinNT. The shell does the work of expanding the glob, but then
you are also constrained by the limitations of the shell.
One constraint that I am very familiar with is the number of files that
can be referenced in a glob: typically it is ~1000 files (1024??). Consider:
someothershell> csh
% ls -l *
UX:csh: SV=0: Arguments too long
% ls -1 | wc -l
3877
Fortunately, opendir(),readdir(),closedir() handle this. And they're
platform independent, so if you use readdir(), you'll get what you're
after on any platform.
James
------------------------------
Date: 16 Apr 1999 10:57:16 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: why won't this statement work @array=<*.*>
Message-Id: <37176bec@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, George <dscapin@harris.com> writes:
:@array = <*.*>
That only gets filenames with literal periods in the middle of
them. The "all (non-dot) files" glob is <*>.
--tom
--
"Bjarne Strousup was sharing a cubicle with me at the time he was creating
C++. That's part of the reason why I don't use it." --Rob Pike
------------------------------
Date: 16 Apr 1999 11:53:58 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: why won't this statement work @array=<*.*>
Message-Id: <37177936@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Jonathan Stowe <gellyfish@gellyfish.com> writes:
:If all else fails :
:
:opendir(DIR,'.') || die "aieee - $!\n";
:@array = readdir(DIR);
:closedir(DIR);
It's true that some ports have broken implementations of glob().
One should spend time fixing them instead of making everyone
go to the same idiotic pain.
--tom
--
"Nowadays people just don't distinguish between prudence and paranoia."
--Larry Wall
------------------------------
Date: Fri, 16 Apr 1999 10:23:13 -0700
From: KC <hunt@queen.es.hac.com>
Subject: Re: Would anyone care to teach me perl?
Message-Id: <37177201.467CED11@queen.es.hac.com>
Ala Qumsieh wrote:
> Why? Don't you know how to read books? It's very simple. In English,
> words go from left to write, but you knew that already.
> Pages can be flipped. A book is made up of one or more pages. Words in
> books look almost exactly like words in email messages. They can be
> read too.
Book?? You mean a non-volitale storage media ;-)
--
-----
KC
------------------------------
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 5400
**************************************