[7900] in Perl-Users-Digest
Perl-Users Digest, Issue: 1525 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 22 21:07:18 1997
Date: Mon, 22 Dec 97 18:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 22 Dec 1997 Volume: 8 Number: 1525
Today's topics:
Don't want to offend <palobo@canadamail.com>
Re: Don't want to offend (brian d foy)
Re: Extensible File Handle Objects <gale@LiveLink.Com>
Re: Extensible File Handle Objects (Tushar Samant)
Re: Extensible File Handle Objects (Martien Verbruggen)
Re: Fast Suggestions for this string manipulation probl <rhodri@wildebst.demon.co.uk>
Re: Fast Suggestions for this string manipulation probl <shadowweb@worsdall.demon.co.uk>
Re: Fast Suggestions for this string manipulation probl <shadowweb@worsdall.demon.co.uk>
File read/write efficiency (Roger Musson)
Getting values from ResultSet is slow (vs. Perl/DBI) <ml@justintime.com>
Re: HELP! Bitwise XOR (^) doesn't work on strings? <dformosa@st.nepean.uws.edu.au>
Re: How to check files exists and if it does then? <reibert@mystech.com>
Re: How to check files exists and if it does then? <bholzman@mail.earthlink.net>
Re: How to check files exists and if it does then? <reibert@mystech.com>
Re: How to check files exists and if it does then? <shadowweb@worsdall.demon.co.uk>
Re: How to check files exists and if it does then? <rhodri@wildebst.demon.co.uk>
Re: one liners (Colin Kuskie)
Re: PERL 5.00404 / BSDI 3.0 INSTALL <khera@kciLink.com>
Re: Perl for Win32 and COM Ports (Repost because I got (Ken Irving)
Perl lib version (5.5.004) ???? jyanni@weir.net
Perl module POSIX.pm <Aruna=Gorantla%CAE%PCPD=Hou@netgate.compaq.com>
Re: Possible bug with garbage collector? <reibert@mystech.com>
Q: Database for Perl on NT (something like msql)? <rowanfan@algonet.se>
Q: what does __ do ? <songtao@nortel.ca>
Re: Regular Expression Question - non greedy match (Ilya Zakharevich)
Re: Removing Spaces (brian d foy)
Re: seeking to a previous line? <David.Leach@dpie.gov.au>
Starting a Daemon in a CGI script maverner@hotmail.com
thanks a lot!... <tjbiuso@redrose.net>
Re: thanks a lot!... (brian d foy)
Trouble with default CGI-BIN directories under Perl (Steve Linberg)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 22 Dec 1997 19:48:19 -0600
From: Paul Bonham <palobo@canadamail.com>
Subject: Don't want to offend
Message-Id: <349F1863.5F39@canadamail.com>
Hi,
I am a bookseller that offers excellent deals on Perl books as well as
other programming books and I would like to drop a note in the
comp.lang.perl.misc newsgroup from time to time but do not want to
offend anyone. Would this be appropriate for this newsgroup or is it
solely devoted to coding issues? If it isn't the appropriate place to be
doing this is there somewhere else where I could post these notices for
Perl programmers?
Paul
------------------------------
Date: Mon, 22 Dec 1997 20:58:20 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Don't want to offend
Message-Id: <comdog-ya02408000R2212972058200001@news.panix.com>
Keywords: from just another new york perl hacker
In article <349F1863.5F39@canadamail.com>, palobo@canadamail.com wrote:
>I am a bookseller that offers excellent deals on Perl books as well as
>other programming books and I would like to drop a note in the
>comp.lang.perl.misc newsgroup from time to time but do not want to
>offend anyone. Would this be appropriate for this newsgroup or is it
>solely devoted to coding issues?
this would not be the appropriate place, but the newsgroup is not
solely devoted to coding issues. discussions of books often take
place, but blatant or thinly disguised advertising has not often
been well received.
>If it isn't the appropriate place to be
>doing this is there somewhere else where I could post these notices for
>Perl programmers?
there are various newsgroups devoted to marketing and business in
which this sort of thing would be appropriate.
good luck :)
--
brian d foy <comdog@computerdog.com>
Meta Meta FAQ <URL:http://computerdog.com/Meta_MetaFAQ.html>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 23 Dec 1997 00:19:52 +0200
From: Yitzchak Gale <gale@LiveLink.Com>
To: "M.J.T. Guy" <mjtg@cus.cam.ac.uk>
Subject: Re: Extensible File Handle Objects
Message-Id: <Pine.LNX.3.96.971222231436.26114C-100000@int-gw.livelink.com>
>> Why not let <$fh> call the getline or getlines method whenever $fh is
>> any kind of blessed reference? ...
>> Is this hard to implement? Is it / was it already done?
> See the section "Tying FileHandles" in the perltie man page.
First of all, for those of you who missed Mike's reference, I quote
that man page section in its entirety:
This isn't implemented yet. Sorry; maybe someday.
Well, right ;). But my suggestion is on a totally different scale than
implementing tying on a whole new Perl data type. From the little
I have seen of Perl patches, it seems that this would not require
more than one or two lines of code.
While I personally am far from qualified to undertake such a thing,
I was just hoping to bring this idea to the attention of those who are.
Truth is, this is also an important issue in light of the upcoming
Perl/Java encounter. Did I hear rumors that IO::File is to be encrusted
as the "cannonical" class for file objects? True, canonical class names
are an important part of the Java philosophy, but this seems like a very
unPerly thing to do. My change would pave the way for a much more
flexible and configurable approach to handling this basic difference
between Java and Perl.
Yitzchak Gale
yitzchakg@livelink.com
LiveLink Systems, Ltd. - World Leaders in Hyperlinking Technology
=> www.livelink.com <=
------------------------------
Date: 22 Dec 1997 19:01:26 -0600
From: scribble@tekka.wwa.com (Tushar Samant)
Subject: Re: Extensible File Handle Objects
Message-Id: <67n2h6$187@tekka.wwa.com>
gale@livelink.com writes:
>> See the section "Tying FileHandles" in the perltie man page.
>
>First of all, for those of you who missed Mike's reference, I quote
>that man page section in its entirety:
>
> This isn't implemented yet. Sorry; maybe someday.
My man page says:
This is partially implemented now.
A class implementing a tied filehandle should define the
following methods: TIEHANDLE, at least one of PRINT,
PRINTF, READLINE, GETC, or READ, and possibly DESTROY.
[...]
------------------------------
Date: 23 Dec 1997 01:33:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Extensible File Handle Objects
Message-Id: <67n4dc$6a8$1@comdyn.comdyn.com.au>
In article <Pine.LNX.3.96.971222231436.26114C-100000@int-gw.livelink.com>,
Yitzchak Gale <gale@LiveLink.Com> writes:
> First of all, for those of you who missed Mike's reference, I quote
> that man page section in its entirety:
>
> This isn't implemented yet. Sorry; maybe someday.
You must have some old documentation. perl5.004_04 doco says:
Tying FileHandles
This is partially implemented now.
and continues to explain how.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: Mon, 22 Dec 1997 22:05:20 +0000 (GMT)
From: Rhodri James <rhodri@wildebst.demon.co.uk>
Subject: Re: Fast Suggestions for this string manipulation problem
Message-Id: <47fcaa86c4rhodri@wildebst.demon.co.uk>
In article <l7iUeMAIStn0EwGN@worsdall.demon.co.uk>,
Mark Worsdall <shadowweb@worsdall.demon.co.uk> wrote:
> All that was extracted was the 1st word upto the first '.'
That's what you appeared to be asking for :-)
[snip]
> So basically I have deceided just to strip the following:-
> # DNS Filters
> @dns = (".demon.co.uk", # Filter of all demon users
> ".co.", # This filters all .co.uk .co.nz etc etc
> ".com.mx", # Mexican Company's
> ".mil", # USA Military
> ".net", # ISP
> ".com"); # Filter of all .com
> $numberOfdns = @dns;
> So if it is a demon then note is done etc. So any more ideas?
Hmm. It looks like you want to special case everything. If your
expression is conveniently in $_, just fill in the following with whatever
you want to do (and no, I really don't understand what you're trying to
do, still).
if (/\.demon\.co\.uk$/)
{
# Do demon summoning stuff
}
elsif (/\.co\./)
{
# National companies -- do something despite the management
}
elsif (/\.mil/)
{
# US Military -- do something, sir
}
and so on. If you want more help, please describe more closely what the
"meaningful part" of the address is, because that doesn't mean much to me!
--
Rhodri James *-* Wildebeeste herder to the masses
If you don't know who I work for, you can't misattribute my words to them
... My heart is Danish, likewise is it blue
------------------------------
Date: Tue, 23 Dec 1997 00:30:47 +0000
From: Mark Worsdall <shadowweb@worsdall.demon.co.uk>
Subject: Re: Fast Suggestions for this string manipulation problem
Message-Id: <rWNHlfA3Ywn0EwU0@worsdall.demon.co.uk>
In article <67mpja$5he$2@comdyn.comdyn.com.au>, Martien Verbruggen
<mgjv@comdyn.com.au> writes
>
>=item split /PATTERN/,EXPR,LIMIT
>
>[snip]
>
>If LIMIT is specified and is not negative, splits into no more than
>that many fields (though it may split into fewer).
>
>[snip]
>
>In other words, the above expression splits $_ on dots, in no more
>than two fields. It assigns the first field to undef (effectively
>discarding it), and assignes the second and final field to $name.
>
>www.somewhere.com => $name = somewhere.com
>aaa.bbb.ccc.ddd.eee => $name = bbb.ccc.ddd.eee
>
>etc.
>
Arh, you see I read it from the manual that LIMIT would be the number of
items to split on, wrong I was!
--
Mark Worsdall (Webmaster) - WEB site:- http://www.shadow.org.uk
Shadow:- webmaster@shadow.org.uk
Home :- shadowweb@worsdall.demon.co.uk
Any opinion given is my own personal belief...
------------------------------
Date: Tue, 23 Dec 1997 01:32:18 +0000
From: Mark Worsdall <shadowweb@worsdall.demon.co.uk>
Subject: Re: Fast Suggestions for this string manipulation problem
Message-Id: <qHYXxyAiSxn0EwFQ@worsdall.demon.co.uk>
In article <47fcaa86c4rhodri@wildebst.demon.co.uk>, Rhodri James
<rhodri@wildebst.demon.co.uk> writes
>> # DNS Filters
>> @dns = (".demon.co.uk", # Filter of all demon users
>> ".co.", # This filters all .co.uk .co.nz etc etc
>> ".com.mx", # Mexican Company's
>> ".mil", # USA Military
>> ".net", # ISP
>> ".com"); # Filter of all .com
>> $numberOfdns = @dns;
>
>> So if it is a demon then note is done etc. So any more ideas?
>
>Hmm. It looks like you want to special case everything. If your
>expression is conveniently in $_, just fill in the following with whatever
>you want to do (and no, I really don't understand what you're trying to
>do, still).
>
> if (/\.demon\.co\.uk$/)
> {
> # Do demon summoning stuff
> }
> elsif (/\.co\./)
> {
> # National companies -- do something despite the management
> }
> elsif (/\.mil/)
> {
> # US Military -- do something, sir
> }
>
>and so on. If you want more help, please describe more closely what the
>"meaningful part" of the address is, because that doesn't mean much to me!
>
I monitor they way people travel around my site and the frequency of
their visits, previously I have been mailing the clients trvaleing
movements, but bandwidth has gone up so now I make a map of how that use
traversed the site in a file. Trouble is the same users are coming back
but are not being logged as the same user, that is to say they have
different names, I mean at the front. eg.:-
ppp12.nl.nisc.mil
ppp1.nl.nisc.mil
ppp102.nl.nisc.mil
So I want to subtract the name down to as near as the users web url as
possible (WITHOUT using LWP::Simple) It is not installed on our system.
So other than creating my own socket and get stuff to read the users
Index page and if there is no server/ an error then knock of the first
name until I get a page. So:-
ppp102.nl.nisc.mil
may end up as:-
nisc.mil
With the get page way but will only end up as:-
nl.nisc.mil
with a manula extraction way. Ofcourse I would prefer the actual get
page method but cannot find any stuff to butcher to see how to do it in
my own script.
Anyway then what happens is a file is created called:-
ppp102.nl.nisc.mil (I want to call it nl.nisc.mil if webpage is there)
Then from my cron a perl program is ran which creates a directory
called:-
Logs/ppp102.nl.nisc.mil and renames the file ppp102.nl.nisc.mil into the
directory Logs/ppp102.nl.nisc.mil under the name of the date it was
renamed with an extenstion of .txt at the end to ensure that MS IE will
disply the log and not try to download it or run it. See thread:-
How to check files exists and if it does then?
I hope this explains things.
It is running reasonably well apart from the problems mentioned. I will
also have to implement the GET page part as I will eventually have the
files stored as .html with how the moved around the site and what the
homepage looks like.
Ofcousre it would be nice to later on see if it is the same machine
viewing my pages, will do this via agent. I'm getting their. :-)
--
Mark Worsdall - Yes, it's underpants renewal time of year :)
Home:- jaydeeATworsdall.demon.co.uk WEB site:- http://www.worsdall.demon.co.uk
Shadow:- webmasterATshadow.org.uk WEB site:- http://www.shadow.org.uk
------------------------------
Date: Mon, 22 Dec 1997 23:41:52 GMT
From: hw@netcomuk.co.uk.No_Junk_Email (Roger Musson)
Subject: File read/write efficiency
Message-Id: <349ef6f0.45763959@nntp.netcomuk.co.uk>
Many Perl scripts I have seen that update text files e.g. a guestbook
load the whole file into an array then write it out again to the same
file with the appropriate changes.
I would prefer to read one line at a time from the original and write
each line to a temp file then at the end rename the temp file but is
this a very inefficient perl technique?
Thanks,
Roger Musson
Please delete NoJunkEmail from return email.
------------------------------
Date: Mon, 22 Dec 1997 17:05:29 -0800
From: Mike Linksvayer <ml@justintime.com>
Subject: Getting values from ResultSet is slow (vs. Perl/DBI)
Message-Id: <349F0E59.22E3BD92@justintime.com>
I have the following code running with Oracle's thin/type 4 JDBC driver
against Oracle 7.2, everything running on an Ultra 1 with JDK 1.1.4:
String select = "select 13 columns from several tables...";
Statement s = conn.createStatement();
ResultSet r = s.executeQuery(select);
while (r.next()) {
for (int i = 1; i <= 13; i++) {
r.getString(i);
}
}
Typically it takes 7 seconds to create the ResultSet, and an additional
four to do an empty while(r.next()) {}, and another additional 7 (18
total) to do ResultSet.getString(int) on each row. (It takes 28
seconds total if I do ResultSet.getString(String) on each row).
I've also tried running this with SunSoft's JDK 1.1.3 that comes
bundled with Solaris 2.6 (includes a JIT) on another Ultra 1 and didn't
see much difference.
I also had high hopes for changing the number of rows JDBC fetches at a
time with the following (default for this driver is 10, I tried
1,10,100,300,1000, and 3000):
((oracle.jdbc.driver.OracleStatement)s).setRowPrefetch(int);
With higher values it takes more time to create the ResultSet, and
looping through the empty while above takes very little time (these
basically cancel out). The amount of time taken to actually retrieve
the column values doesn't change much, which makes me question what
exactly is being prefetched.
Finally I tried specifying that I'd be trying to get strings with the
following code:
for (int i = 1; i <= 13; i++) {
((oracle.jdbc.driver.OracleStatement)s).defineColumnType(i,Types.VARCHAR);
}
This caused the ResultSet.getString(int) on each row portion to drop from
7 seconds to 2 seconds (for 13 total). This seems to indicate that the
column type was being checked again for each row!
Running on the same machine against the same database the following
Perl/DBI/DBD::Oracle code does much better:
$select = "select 13 columns from several tables...";
$cursor = $dbh->prepare($select);
$cursor->execute;
while (@row = $cursor->fetchrow) {}
Typically it takes 6 seconds to execute the query (equivalent to creating
a ResultSet). Looping through the cursor AND putting the columns from each
row into an array only takes an additional second.
The query used in both of the above tests produces 3000 rows. Saving the
results (e.g. putting them in an array of arrays) has negligible overhead
in both Java and Perl.
In both cases, it is taking 6 or 7 seconds for the database to finish
executing its query (this is also how long it takes in sqlplus, as expected).
Why does Perl loop through the cursor and retrieve the results so much
faster? I can only think of these possibilities...
* Perl is retrieving whole rows at a time, Java a column at a time. I
don't see anything like ResultSet.getArray(String[]) in JDBC.
* ResultSet.getString() returns a new String, which is expensive.
* One or more of Java, Sun's VM, JDBC, and Oracle's driver are slow.
So... Anyone have any suggestions as to how I can speed up getting
results out of JDBC? In summary, here's what I tried:
* Use column indices instead of names with ResultSet.get*() methods (obvious)
* Tell the driver what data type you will request of each column (is there
a generic way to do this in JDBC?)
* Tell the driver how many rows to fetch at a time (this didn't help me, but
I would be interested to know if there is a generic way to do this in JDBC).
Thanks,
--
Mike Linksvayer Just in Time Solutions, Inc. tel +1 415 553 6408
ml@justintime.com http://www.justintime.com/ fax +1 415 553 6499
------------------------------
Date: 22 Dec 1997 22:40:57 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: HELP! Bitwise XOR (^) doesn't work on strings?
Message-Id: <882830410.957856@cabal>
In <34a228cd.3500370@news.tornado.be> bart.mediamind@tornado.be (Bart Lateur) writes:
[...]
>Rubbish. I don't mean to say that what you say isn't correct, I'm saying
>that the rule stinks.
>Rules should be simple, and apply to everything there's supposed to
>apply to.
The name of the above idear is 'orthginality' and its one of the things
that perl dosn't have alot of.
--
Please excuse my spelling as I suffer from agraphia see the url in my header.
Never trust a country with more peaple then sheep.
Support NoCeM http://www.cm.org/
I'm sorry but I just don't consider 'because its yucky' a convincing argument
------------------------------
Date: Mon, 22 Dec 1997 15:49:17 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: How to check files exists and if it does then?
Message-Id: <349EEE6D.FA9412A9@mystech.com>
Mark Worsdall wrote:
> Hi, I need to be able to check if a file exists and if it does then
> append an 'a' unless that exists, in which case I will append a 'b'
> unless that exists etc etc etc.
>
> here is the variable:-
> $startloc/Logs/$urlpath/$date
>
> Where $date is the filename that has to be checked if exists and if does
> the the letter appended as described above.
There may be a cleaner way, but the following will work provided your character set
has the lower-case characters in sequence.
$base = "$startloc/Logs/$urlpath/$date";
$nextExt = 'a';
$file = $base;
while ( -e $file ) {
$file = $base . $nextExt;
$nextExt = chr( (ord $nextExt) + 1 );
}
At this point, $file is what you are looking for.
HTH
-----------------------------
Mark S. Reibert, Ph.D.
Mystech Associates, Inc.
3233 East Brookwood Court
Phoenix, Arizona 85044
Tel: (602) 732-3752
Fax: (602) 706-5120
E-mail: reibert@mystech.com
-----------------------------
------------------------------
Date: Mon, 22 Dec 1997 18:27:04 -0500
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Stephan Vladimir Bugaj <bugaj@bell-labs.com>
Subject: Re: How to check files exists and if it does then?
Message-Id: <349EF748.62F64AD9@mail.earthlink.net>
Stephan Vladimir Bugaj wrote:
>
> Mark Worsdall wrote:
> >
> > Hi, I need to be able to check if a file exists and if it does then
> > append an 'a' unless that exists, in which case I will append a 'b'
> > unless that exists etc etc etc.
Hmm, what's the requirement here? Should the letter be appended to the
filename, or the file itself? Not too clear...
> >
> > here is the variable:-
> > $startloc/Logs/$urlpath/$date
> >
> > Where $date is the filename that has to be checked if exists and if does
> > the the letter appended as described above.
> >
>
> try
>
> use File::Copy;
> $foo = "$startloc/Logs/$urlpath/";
$foo? How about '$path'?
> if(-e "$foo$date")
Well, if the requirement is that the filename should be appended to,
then you're only checking that it exists the first time, ie, you're not
checking to see that "$foo${date}a" exists, which makes the loop below
kind of pointless...
> {
> for($v=97; $v<=122; $v++)
> {
> $a = chr($v);
> next if ($date=~/$a/);
This is assuming that $date doesn't contain any of the letters a-z in a
non-terminal position, in which case it's a noop (see above), and
otherwise will probably not have the intended behavior.
> copy("$foo$date","$foo$date$a");
If all you're trying to do is rename a file, I'd use the built-in
rename() function...
HTH,
Benjamin Holzman
------------------------------
Date: Mon, 22 Dec 1997 16:52:43 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: How to check files exists and if it does then?
Message-Id: <349EFD4B.A42CC40D@mystech.com>
Stephan Vladimir Bugaj wrote:
> try
>
> use File::Copy;
> $foo = "$startloc/Logs/$urlpath/";
> if(-e "$foo$date")
> {
> for($v=97; $v<=122; $v++)
> {
> $a = chr($v);
> next if ($date=~/$a/);
> copy("$foo$date","$foo$date$a");
> }
> }
Be careful about harcoding character positions - you're asking for trouble and
portability problems! Also, the pattern match in your solution should be
something like $date =~ /$a$/. One more thing: I interpreted the original post
as wanting the next available file name and not populating all files with the
original :-)
-----------------------------
Mark S. Reibert, Ph.D.
Mystech Associates, Inc.
3233 East Brookwood Court
Phoenix, Arizona 85044
Tel: (602) 732-3752
Fax: (602) 706-5120
E-mail: reibert@mystech.com
-----------------------------
------------------------------
Date: Tue, 23 Dec 1997 00:45:02 +0000
From: Mark Worsdall <shadowweb@worsdall.demon.co.uk>
Subject: Re: How to check files exists and if it does then?
Message-Id: <bGDLBkAOmwn0EwTe@worsdall.demon.co.uk>
Ok say there are directory's and files looking like this:-
ipww01.proxy.aol.com/16December1997-Tuesday.txt
ipww04.proxy.aol.com/16December1997-Tuesday.txt
ipww04.proxy.aol.com/17December1997-Wednesday.txt
ipww05.proxy.aol.com/16December1997-Tuesday.txt
ipww05.proxy.aol.com/17December1997-Wednesday.txt
ipww05.proxy.aol.com/19December1997-Thursday.txt
ipww61.proxy.aol.com/16December1997-Tuesday.txt
ipww61.proxy.aol.com/19December1997-Thursday.txt
I am trying to merge the directory's into one directory but the problem
comes when the files already exist, so I am trying to end up with the
following:-
proxy.aol.com/16December1997-Tuesday.txt
proxy.aol.com/16December1997-Tuesday-a.txt
proxy.aol.com/16December1997-Tuesday-b.txt
proxy.aol.com/16December1997-Tuesday-c.txt
proxy.aol.com/17December1997-Wednesday.txt
proxy.aol.com/17December1997-Wednesday-a.txt
proxy.aol.com/19December1997-Thursday.txt
proxy.aol.com/19December1997-Thursday-a.txt
I hope this explains it all better, this also is part of a previous
problem about removing the 1st word ie ipww05. which is now working.
--
Mark Worsdall - Yes, it's underpants renewal time of year :)
Home:- jaydeeATworsdall.demon.co.uk WEB site:- http://www.worsdall.demon.co.uk
Shadow:- webmasterATshadow.org.uk WEB site:- http://www.shadow.org.uk
------------------------------
Date: Tue, 23 Dec 1997 01:27:47 +0000 (GMT)
From: Rhodri James <rhodri@wildebst.demon.co.uk>
Subject: Re: How to check files exists and if it does then?
Message-Id: <47fcbd0fa4rhodri@wildebst.demon.co.uk>
In article <bGDLBkAOmwn0EwTe@worsdall.demon.co.uk>,
Mark Worsdall <shadowweb@worsdall.demon.co.uk> wrote:
> Ok say there are directory's and files looking like this:-
Tsk. And I thought only Statesiders got apostophes wrong :-)
> ipww01.proxy.aol.com/16December1997-Tuesday.txt
> ipww04.proxy.aol.com/16December1997-Tuesday.txt
> ipww04.proxy.aol.com/17December1997-Wednesday.txt
> ipww05.proxy.aol.com/16December1997-Tuesday.txt
> ipww05.proxy.aol.com/17December1997-Wednesday.txt
> ipww05.proxy.aol.com/19December1997-Thursday.txt
> ipww61.proxy.aol.com/16December1997-Tuesday.txt
> ipww61.proxy.aol.com/19December1997-Thursday.txt
> I am trying to merge the directory's into one directory but the problem
> comes when the files already exist, so I am trying to end up with the
> following:-
> proxy.aol.com/16December1997-Tuesday.txt
> proxy.aol.com/16December1997-Tuesday-a.txt
> proxy.aol.com/16December1997-Tuesday-b.txt
> proxy.aol.com/16December1997-Tuesday-c.txt
> proxy.aol.com/17December1997-Wednesday.txt
> proxy.aol.com/17December1997-Wednesday-a.txt
> proxy.aol.com/19December1997-Thursday.txt
> proxy.aol.com/19December1997-Thursday-a.txt
> I hope this explains it all better, this also is part of a previous
> problem about removing the 1st word ie ipww05. which is now working.
Aha. This is a Different Thing. Assuming that $urlpath contains the
directory that you want to go to, rather than whichever of the directories
your current $date is in, try this untested code fragment:
$path = "$startloc/Logs/$urlpath/"; # because I'm lazy
$date =~ s/\.txt//; # cut off the .txt, put back later!
if (-e "$path$date.txt")
{
# Our target filename already exists, make something up
for ($extn = 'a'; $extn le 'z'; $extn++)
{
last if (! -e "$path$date-$extn.txt");
die "Got to 'z' moving $path$date.txt" if $extn eq 'z';
}
$result = "$path$date-$extn.txt";
}
else
{
$result = "$path$date.txt";
}
...and do your thing with $result or whatever you choose to call it.
--
Rhodri James *-* Wildebeeste herder to the masses
If you don't know who I work for, you can't misattribute my words to them
... Worse things happen in C
------------------------------
Date: 22 Dec 1997 16:36:00 -0800
From: colink@latticesemi.com (Colin Kuskie)
Subject: Re: one liners
Message-Id: <67n11g$h1t@sarek.latticesemi.com>
In article <67bjr4$op4@newton.cc.rl.ac.uk>,
Kevin Maguire <K.Maguire@dl.ac.uk> wrote:
>How to this in a perl one-liner:
>replace record 3 of line 10 in file nozz10 with hello:
>head -9 nozz10; head -10 nozz10 | tail -1 | awk '{$3="hello"; print $0}' ; tail +11 nozz10
WARNING-*-WARNING-*-WARNING-*-WARNING-*-WARNING-*-WARNING-*-WARNING
Spend a little time reading your friendly local perl manpages :)
WARNING-*-WARNING-*-WARNING-*-WARNING-*-WARNING-*-WARNING-*-WARNING
perl -pai.bak -e '$F[2]="hello"; print "@F\n";' *10
Remember, as Mickey found out:
a little power without knowledge is dangerous
Colin Kuskie
------------------------------
Date: 22 Dec 1997 18:15:55 -0500
From: Vivek Khera <khera@kciLink.com>
To: "Matthew Feinberg" <matt@monmouth.com>
Subject: Re: PERL 5.00404 / BSDI 3.0 INSTALL
Message-Id: <x7ra75ufys.fsf@kci.kciLink.com>
>>>>> "MF" == Matthew Feinberg <matt@monmouth.com> writes:
MF> I am trying to build perl 5.00404 under BSDI 3.0
MF> I'm fine untill make test, I run ./perl harness in ../t
MF> Bellow are my results
MF> My question is "Do I need 100% okay to build PERL or is there always going
MF> to be some falure rate?"
MF> Does anyone have experience with Perl 5 under BSDI 3.0 that can give some
MF> pointers to make this work?
Perl 5.004_04 compiles and tests 100% cleanly on BSD/OS 3.0 and 3.1.
A simple "./Configure -des" followed by "gmake" will build fine. I've
had trouble building with regular bsd make, so try gmake instead.
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D. Khera Communications, Inc.
Internet: khera@kciLink.com Rockville, MD +1-301-258-8292
PGP/MIME spoken here http://www.kciLink.com/home/khera/
------------------------------
Date: 23 Dec 97 00:37:16 GMT
From: systech@polarnet.com (Ken Irving)
Subject: Re: Perl for Win32 and COM Ports (Repost because I got absolutely no replies to the original)
Message-Id: <349f07bc.0@news.randori.com>
Looks like you're using the OO stuff, and setting "autoflush" in the process.
I've used the following non-OO code successfully, with the main difference
apparently being the use of syswrite() and sysread().
open (MODEM,"+> COM2:") or die "unable to open modem port";
binmode MODEM;
select MODEM;
$|=1;
select STDOUT;
syswrite(MODEM, "ATZ\r", 4);
sysread(MODEM, $echo, 5);
print $echo;
sysread(MODEM, $reply, 10);
print $reply;
You're sending "AT" to the modem, which may or may not respond with anything,
depending on how the modem's configured.
Ken
In article <349fc76b.3091055@news.demon.co.uk>, cfoster@cfoster.demon.co.uk
says...
>
>On Wed, 17 Dec 1997 15:50:36 -0800, see@my.sig (Don Groves) wrote:
>
>>In article <3498efb7.8881573@news.demon.co.uk>,
>>cfoster@cfoster.demon.co.uk says...
>>> I am trying to chat to a device connected to COM2:. I have tried
>>> various scripts, starting with
>>>
>>> open MODEM,"+>com2:";
>>> print MODEM "AT\n";
>>> $input = <MODEM>;
>>> print $input;
>>> close MODEM;
>>>
>>> then later ..
>>>
>>> use IO::Handle;
>>>
>>> open MODEM,"+>com2:";
>>> binmode MODEM;
>>> MODEM->autoflush(1);
>>>
>>> print MODEM "AT\n";
>>> $input = <MODEM>;
>>> print $input;
>>>
>>> close MODEM;
>>>
>>> Neither recieve anyting, though flashing lights on the modem would
>>> indicate that the print to MODEM is sending something.
>>>
>>> I can talk directly to the modem using Hyperterminal without any
>>> problems, so I must be doing something wrong.
>>>
>>> Any help would be appreciated.
>>>
>>
>>Try \r instead of \n.
>>
>
>Nope. That didn't make any difference.
--
Ken Irving, SysTech Control, systech@polarnet.com, 907.456.1694
------------------------------
Date: Mon, 22 Dec 1997 17:21:29 -0600
From: jyanni@weir.net
Subject: Perl lib version (5.5.004) ????
Message-Id: <882831808.1533476872@dejanews.com>
I am having trouble with the last steps of the perl 5.004 build. I am
running RH Linux 2.0.32 on i486 machine. I have installed all the latest
Redhat packages as of 12/22/97.
When at the './config.pm' piece (after make creates libperl.a), I receive
the following error:
[root@proxy perl5.004_04]# ./configpm Argument "5.5.004" isn't numeric at
../configpm line 19. Perl lib version (5.5.004) doesn't match executable
version (5.5.004) at lib/Con fig.pm line 7.
The reason for the error is that '5.5.004' is not a legal numeric value.
It is created by the perl env. variable '$]'. Why is this happening?
How can I fix this?
Thanks for ANY help!
Joe Yanni
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 22 Dec 1997 22:58:23 GMT
From: "Aruna Gorantla" <Aruna=Gorantla%CAE%PCPD=Hou@netgate.compaq.com>
Subject: Perl module POSIX.pm
Message-Id: <01bd0f2d$1a94b460$679f12ac@agorantla>
Hi,
Does anybody know if there is a perl module POSIX.pm available for NT? If
yes, where can
I find it. Thanks in advance.
Aruna.
------------------------------
Date: Mon, 22 Dec 1997 16:44:30 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: Possible bug with garbage collector?
Message-Id: <349EFB5D.B3E94421@mystech.com>
Ilya Zakharevich wrote:
> Currently the LHS of -> is an (sp?) lvalue. This may be changed in
> the future, since many people hate it.
>
> Nobody yet came with a patch, and since 5.005 is almost frozen,
> this most probably stay in 5.005.
>
> Ilya
Interesting. Thanks for the help!
-----------------------------
Mark S. Reibert, Ph.D.
Mystech Associates, Inc.
3233 East Brookwood Court
Phoenix, Arizona 85044
Tel: (602) 732-3752
Fax: (602) 706-5120
E-mail: reibert@mystech.com
-----------------------------
------------------------------
Date: Tue, 23 Dec 1997 01:14:53 +0100
From: Calle <rowanfan@algonet.se>
Subject: Q: Database for Perl on NT (something like msql)?
Message-Id: <349F027D.2550@algonet.removetoreply.se>
Does anyone know something that will work on an NT?
I want to have a database with some links and descriptions,
and it will be searchable via CGI.
Anyone tried to port msql to NT?
/calle
------------------------------
Date: Mon, 22 Dec 1997 18:04:01 -0500
From: Songtao Chen <songtao@nortel.ca>
Subject: Q: what does __ do ?
Message-Id: <349EF1E1.41C67EA6@nortel.ca>
Hi,
Simple question. What does __ do ?
It appears in a signal trap,
sub signal_trap
{
local($sig) = shift;
__;
print "caught signal $sig\n";
exit "$sig";
}
Thanks,
Songtao
songtao@nortel.com
------------------------------
Date: 22 Dec 1997 22:58:17 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Regular Expression Question - non greedy match
Message-Id: <67mra9$fm1$1@agate.berkeley.edu>
Keywords: just another new york perl hacker
In article <eli$9712221623@qz.little-neck.ny.us>,
Eli the Bearded <#@qz.to> wrote:
> Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
> > Eli the Bearded <#@qz.to> wrote:
> > > $r='#! rnews ';
> > > $count = s/$r\d+\n((?:(?!$r)#|[^#]+)+)/$r.(length $1)."\n$1"/gse;
> > How is it less error-prone than
> > /$r(\d+\n)(.+?)(?=$r|$)/
> > ?
>
> Well, other than your just adding a new set of parens that throw off
> the replacement count,
There is no new set of parens.
> I'd use \Z instead of $ to ensure the right
> anchoring if /m were ever added to the flags.
\Z is not much better than $. I would use \z, but since 5.005 will
not have it ;-), one is forced to use these abomination \Z(?!\n).
> I know your point was that "Here is a case were non-greedy regexps
> are not harmful, and in fact simplify things considerably." I know.
> There is very strong deliberate anchoring around the part that needed
> to be captured, which makes non-greedy matching safe. My point was
> to show that it could be solved without needing non-greedy matching.
The problem is that few people will be able to read your re, so check
that "it could be solved without needing non-greedy matching". I
could not.
Re's are unreadable from the start. One should not deliberately add
to this, unless necessary.
Ilya
P.S. Interested people may look in ./t/op/pat.t of >= 5.004_55 to see
the beast which matches "matching parens" (let's look... it is near
matchit). The only reason I wrote it is to check new (?{...}) engine,
this is not what I would like to have in production code (though it is
_almost_ readable).
P.P.S. Well, to decrease quoted/contents ratio, I may just include it
here:
m'
(
\(
(?{ $c = 1 }) # Initialize
(?:
(?(?{ $c == 0 }) # PREVIOUS iteration was OK, stop the loop
(?!
) # Fail: will unwind one iteration back
)
(?:
[^()]+ # Match a big chunk
(?=
[()]
) # Do not try to match subchunks
|
\(
(?{ ++$c })
|
\)
(?{ --$c })
)
)+ # This may not match with different subblocks
)
(?(?{ $c != 0 })
(?!
) # Fail
) # Otherwise the chunk 1 may succeed with $c>0
'xg;
------------------------------
Date: Mon, 22 Dec 1997 20:54:48 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Removing Spaces
Message-Id: <comdog-ya02408000R2212972054480001@news.panix.com>
Keywords: from just another new york perl hacker
In article <01bd0ee9$cf27c1e0$LocalHost@oasis>, "Ho Seng Yip" <cybercom@pacific.net.sg> wrote:
>I will like to ask how is it possible for me to remove spaces in the
>comment section of my mailform. I got some light on searching for spaces
>using Perl patterns, but the problem comes in on how I can delete the
>spaces after I have located them.
the substitute operator is your friend:
s/\s+/ /g; #collapse multiple whitespace.
if you are just starting out, you may wish to read the Llama book [1],
which discusses this sort of thing in chapter 7. there are also the
online documentation [2], and the manaul pages included with perl.
good luck :)
[1]
Learning Perl
Randal L. Schwartz & Tom Christiansen
ISBN 1-56592-284-0
<URL:http://www.oreilly.com>
[2]
<URL:http://www.perl.com>
--
brian d foy <comdog@computerdog.com>
Meta Meta FAQ <URL:http://computerdog.com/Meta_MetaFAQ.html>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Tue, 23 Dec 1997 10:07:25 +1100
From: David Leach <David.Leach@dpie.gov.au>
Subject: Re: seeking to a previous line?
Message-Id: <349EF2AD.42E65B35@dpie.gov.au>
David Leach wrote:
> How would I go about seeking 1 line back in perl? that is, I want to
> move the file pointer one line in reverse from whereever it may
> currently be. Possible?
If I'd read further into seek in my trusty camel book, I would have
noticed the function tell() would have answered my question for me (as
Tom Phoenix kindly pointed out to me!).
just fyi (the respondants of my initial posting) :-)
regards,
David.
------------------------------
Date: Mon, 22 Dec 1997 19:01:24 -0600
From: maverner@hotmail.com
Subject: Starting a Daemon in a CGI script
Message-Id: <882838582.1860698115@dejanews.com>
Hi,
I have a perl script in my cgi-bin file which is supposed to start a
daemon and then return a simple message.
My script is essentially:
if (!daemonRunning)
{
system("runDaemon.pl &");
}
print htmlHeader();
print "I'm back";
return 1;
The problem is my perl script never comes back from starting runDaemon.pl
The daemon does get started and the next time I run the script, it returns
a nice html page since the daemon is already running.
Is the "system" command the right way to launch a job asynchronously?
The Camel book seems to suggest this should work as far as I can tell.
My server is running NetBSD 1.2.
Thanks for any help.
Matt
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Mon, 22 Dec 1997 18:20:16 -0500
From: MrPc <tjbiuso@redrose.net>
To: Eli the Bearded <#@qz.to>
Subject: thanks a lot!...
Message-Id: <349EF5AE.5614A8E9@wish.u.knew>
Eli the Bearded wrote:
> In article <349AEBB6.AE9BFE00@redrose.net>, MrPc <...@....com> wrote:
>
> If you don't know how to use a search engine, just what do you
> think you are going to do with the source?
>
> Elijah
what kind of smart ass answer is this?!? i ask for help and what i get
is shit! i didn't mean to phrase my question like that, but that gave
you no right to give me such a lame response. i'm a beginner in perl,
and if i ask for help i don't expect caustic answers instead of a polite
explanation which i think i deserve (as any newbie does). chances are,
you're not as good of a visual basic programmer as i am, and if someone
asked you how subclassing in the win32s api is performed or what
interface polymorphism is, you wouldn't know where to begin! i advise
you to keep your hole shut unless you have something nice to say!
------------------------------
Date: Mon, 22 Dec 1997 20:51:11 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: thanks a lot!...
Message-Id: <comdog-ya02408000R2212972051110001@news.panix.com>
Keywords: from just another new york perl hacker
In article <349EF5AE.5614A8E9@wish.u.knew>, MrPc <tjbiuso@redrose.net> wrote:
>Eli the Bearded wrote:
>
>> In article <349AEBB6.AE9BFE00@redrose.net>, MrPc <...@....com> wrote:
>>
>> If you don't know how to use a search engine, just what do you
>> think you are going to do with the source?
>>
>> Elijah
>
>what kind of smart ass answer is this?!?
it's the kind of answer you get when you expect others to babysit you.
it is quite easy to find things on the internet on one's own, so
others tend to be rather indignant when one is too inconsiderate
to try to do so before asking for help.
count yourself lucky if Elijah posted before Tad did.
>i ask for help and what i get
>is shit!
once you calm down perhaps you realize that the answer was to use
a search engine to help you find the source that you were looking
for. you would be much more self sufficient that way, and wouldn't
have to wait for the good graces of others to continue with your
project. Elijah's answer does you more good than someone who
simply gives you the URL for some source.
>i didn't mean to phrase my question like that, but that gave
>you no right to give me such a lame response. i'm a beginner in perl,
>and if i ask for help i don't expect caustic answers instead of a polite
>explanation which i think i deserve (as any newbie does).
deserve? historically, that attitude hasn't made it very far
in this newsgroup.
>chances are,
>you're not as good of a visual basic programmer as i am, and if someone
chances are that Elijah doesn't consider anything with Visual
attached to it as programming. probably the same for anything
made by micro$loth. though your effort is tremendous, you're going
to need to work on your delivery if you want to flame others. it
takes practice you know. there might even be a flame FAQ online
somewhere.
>asked you how subclassing in the win32s api is performed or what
>interface polymorphism is, you wouldn't know where to begin!
he would probably start with a search engine *snork*. not that
those are difficult subjects. a better dart might have been
"how to program Hump the Wumpus in Procmail" - a far more difficult
task i'm told...
>i advise
>you to keep your hole shut unless you have something nice to say!
or what? i'd like to see this!
--
brian d foy <comdog@computerdog.com>
Meta Meta FAQ <URL:http://computerdog.com/Meta_MetaFAQ.html>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 22 Dec 1997 19:28:33 -0500
From: slinberg-bitme@crocker.com (Steve Linberg)
Subject: Trouble with default CGI-BIN directories under Perl
Message-Id: <slinberg-bitme-2212971928330001@projdirc.literacy.upenn.edu>
Kind people,
I'm stuck on something that must be insanely stupid. I have an NT box
running Server 4.0 and IIS 3.0. I'm using the most recent Activeware
Perl5. I have the following directory structure:
d:\inetpub
d:\inetpub\myscripts
d:\inetpub\wwwroot\etc
"myscripts" is aliased to "cgi-bin" with execute access. Accessing
scripts within that directory branch works fine, but the default or logged
directory is not what I expected.
When calling the following cgi from a web page:
d:\inetpub\cgi-bin\sub1\sub2\foo.pl
and try from inside foo.pl to reference a module in the same directory:
d:\inetpub\cgi-bin\sub1\sub2\bar.pm
... with the simple reference "bar.pm", foo.pl executes fine but I get
"file not found." A little sleuthing (reading the current directory
contents with OPENDIR) reveals that when the script executes, the logged
directory is always:
d:\inetpub\cgi-bin
not
d:\inetpub\cgi-bin\sub1\sub2
Huh? No wonder my scripts don't work. Moving this short test program to
different locations within the cgi-bin tree always produces the same
result.
So the question is:
How do I configure IIS and/or Perl to set the default directory for a
script to the directory it is contained in, rather than the cgi-bin root?
I don't know whu it's always setting the directory to \cgi-bin, even if
the script being called is several layers deep. Nothing in any of the
documentation I've been able to find has provided a clue to this.
Insights or answers lapped up like chocolate!
Steve Linberg
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 1525
**************************************