[10063] in Perl-Users-Digest
Perl-Users Digest, Issue: 3656 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 7 23:07:11 1998
Date: Mon, 7 Sep 98 20:00:17 -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 Mon, 7 Sep 1998 Volume: 8 Number: 3656
Today's topics:
Re: a better read()? (Martien Verbruggen)
Died at line x? (Ken Williams)
Re: Died at line x? <rick.delaney@shaw.wave.ca>
Re: getting the dimensions of images? <nguyend7@msu.edu>
Re: getting the dimensions of images? (Martien Verbruggen)
Re: HELP NEEDED!! <nguyend7@msu.edu>
Re: How do I extract last line from multiline string? (Tim Gim Yee)
Re: lowercasing (Larry Rosler)
Re: My cool DIRTTY PICS page (Martien Verbruggen)
Re: Perl Programmer Needed <merlyn@stonehenge.com>
Re: Perl Programmer Needed <Richard@WowMe.com>
Re: Perl Programmer Needed <merlyn@stonehenge.com>
Re: Perl Programmer Needed <Richard@WowMe.com>
Re: Perl Source Needed <tchrist@mox.perl.com>
Perl WIN32: Looking for a TCP/UDP Connection <stevenmc@home.com>
Re: reading a file backward (Abigail)
Re: reading a file backward <tchrist@mox.perl.com>
s/// on config file problem (David Michael Kusters (none))
Re: s/// on config file problem <rick.delaney@shaw.wave.ca>
ssi exec error... (CA Aspiras)
Re: Text::CSV parsing sporadically (Martien Verbruggen)
URGENT HELP!!! <MegaManz@email.msn.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 08 Sep 1998 02:19:30 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: a better read()?
Message-Id: <Su0J1.333$oa3.1884@nsw.nnrp.telstra.net>
In article <35F3587C.A73A8C37@freewwweb.com>,
Sam Wang <samwang@freewwweb.com> writes:
> i'm talking about LENGTH. as i recall, you have to set this.
Make it incredibly large. perl won't mind. As long as you have enough
memory to accomodate for the longest thing you'll read, there won't be
a problem. If you are bound by memory, then you'll just have to read
bit^Wpiece by piece.
Can you maybe break up your reads in blocks? Are you trying to read
unformatted stuff? Is it formatted in any way?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: Tue, 08 Sep 1998 01:50:41 GMT
From: tekkin@hotmail.com (Ken Williams)
Subject: Died at line x?
Message-Id: <6t22db$95s@cabernet.niagara.com>
Is there a switch for perl that tells it not to send this message to stdout or
sterr and just die silently?
------------------------------
Date: Tue, 08 Sep 1998 02:42:52 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Died at line x?
Message-Id: <35F49B2F.F256FA74@shaw.wave.ca>
[posted & mailed]
Ken Williams wrote:
>
> Is there a switch for perl that tells it not to send this message to
> stdout or sterr and just die silently?
You mean in something like this?
open FILE, 'foo' or die;
If so you could substitute die with exit. Or try
open FILE, 'foo' or die "\n";# dogs can still hear this
perldoc -f die
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: 7 Sep 1998 23:58:48 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: getting the dimensions of images?
Message-Id: <6t1rvo$h8u$2@msunews.cl.msu.edu>
jamesht <jamesht@idt.net> wrote:
: I need to get the dimentions of images from a script, so I can insert
: them into an html page. How would I do this?
Try going and opening the image in your browser. It'll show the size
in the title of the page. If your too lazy to do this, just leave
them blank.
--
Dan Nguyen | There is only one happiness in
nguyend7@msu.edu | life, to love and be loved.
http://www.cse.msu.edu/~nguyend7 | -George Sand
------------------------------
Date: Tue, 08 Sep 1998 02:52:25 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: getting the dimensions of images?
Message-Id: <JZ0J1.679$oa3.1884@nsw.nnrp.telstra.net>
In article <35F4686C.83A10EDC@idt.net>,
jamesht <jamesht@idt.net> writes:
> I need to get the dimentions of images from a script, so I can insert
> them into an html page. How would I do this?
You can get dimensions of most image formats by using the module
Image::Size. It's available from CPAN
(http://www.perl.com/CPAN/modules/). It might already be installed.
Try
# perldoc Image::Size
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd. | password?
NSW, Australia |
------------------------------
Date: 7 Sep 1998 23:56:52 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: HELP NEEDED!!
Message-Id: <6t1rs4$h8u$1@msunews.cl.msu.edu>
Roberto <uov01026@correo.uniovi.es> wrote:
: Hi everybody, I'm a spanish student of Computing sciences.
: I've done a perl course this summer and I have to do a project in perl.
Try doing your own homework rather then begging for help here.
--
Dan Nguyen | There is only one happiness in
nguyend7@msu.edu | life, to love and be loved.
http://www.cse.msu.edu/~nguyend7 | -George Sand
------------------------------
Date: Tue, 08 Sep 1998 02:30:10 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: How do I extract last line from multiline string?
Message-Id: <35f49122.291145716@news.oz.net>
On Mon, 7 Sep 1998 17:44:50 +0200, "Stephane Barizien"
<NOSPAM.stephane.barizien@ocegr.fr> wrote:
>I have a string that contains something like
>
>a\nb\nc\nd\n
>
>(output from Net::Telnet::waitfor, FWIW)
>
>I want to extract the last "line" ("d" in my example) to a var
>and keep the rest in the original variable.
>
>I've tried:
>
>chop ($x);
>$x =~ s/\n([^\n]+)\\z//m;
>$y = $1;
You don't need to substitute, [^\n] is wordy, you probably were
thinking \Z, and the /m modifier wouldn't have helped.
$last_line = $1 if "a\nb\nc\nd\n" =~ /(.*)$/;
>P.S. One nice thing about Perl re's is that you can do ANYthing.
>One bad thing is that it can take you an unknown amount of time to find out
>HOW.
$last_line = (split "\n", "a\nb\nc\nd\n")[-1]; # Look, mom! No RE!
Don't be surprised if your mom corrects you :)
------------------------------
Date: Mon, 7 Sep 1998 16:59:51 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: lowercasing
Message-Id: <MPG.105e1350e353b01f989835@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <6t1m7u$enc$1@power42t.hkbu.edu.hk> on 7 Sep 1998 22:20:46
GMT, Mr. Chow Wing Siu <wschow@Comp.HKBU.Edu.HK> says...
>
>
> Hi, here is what I need by PERL.
>
> THIS IS MY EXAMPLE ONE. (Uppercase)
>
> This Is My Example One. (Lowercase except the first char)
>
> Thanks.
>
> - --
> PGP PUBLIC KEY: https://www.comp.hkbu.edu.hk/~wschow/pgp.html
> ... <snip of line noise>
Please don't post this gibberish in the future.
Mike Stok has answered 'For simple definitions of "word"'. For a more
complex definition of "word", read the following via
<URL:http://www.dejanews.com>:
Re: Converting to Uppercase to some Lower Case
Author: Craig Berry
Email: cberry@cinenet.net
Date: 1998/08/29
Forums: comp.lang.perl.misc
Message-ID: <6ra8hn$mec$1@marina.cinenet.net>
NNTP-Posting-Date: Sat, 29 Aug 1998 07:42:00 MDT
Organization: Cine Communications,Internet Access,Los
Angeles;310-301-4500
References: <903388079.157935@gate.part.net>
--
Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 08 Sep 1998 02:38:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: My cool DIRTTY PICS page
Message-Id: <yM0J1.666$oa3.1884@nsw.nnrp.telstra.net>
In article <35F42E90.E1601B69@fccjmail.fccj.cc.fl.us>,
"Bill Jones, FCCJ Webmaster" <webmaster@fccjmail.fccj.cc.fl.us> writes:
> Nathan V. Patwardhan wrote:
>>
>> 278345@msn.com wrote:
>> : Check out my new home page with free xxx pics.
>>
>> DIRTTY? Maybe this is some kind of new I/O or maybe it's something
>> that has to do with your browser, but either way it doesn't have
>> anything to do with Perl! Hope this helps!
>>
>> --
>> Nate Patwardhan|root@localhost
>
>
> No, DIR-TTY is a new file directory structure that wastes lots of space
> while causing mindless browsing that, in turn, causes a total loss
> in personal productivity.
Isn't that the new integrated IE4 stuff in NT? Have MS changed the
name of their 'operating system'?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: Mon, 07 Sep 1998 23:56:31 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Perl Programmer Needed
Message-Id: <8cyarvpjdu.fsf@gadget.cscaper.com>
>>>>> "Richard" == Richard <Richard@WowMe.com> writes:
Richard> We are looking for a Perl programmer who is familiar with
Richard> ActiveState's WinDos Perl on NT server. It would be project
Richard> based work from home. We are a small company and probably
Richard> could not afford an expert. But none of our needs should
Richard> require one. If you are interested in making some extra
Richard> money in your spare time, please reply to author.
I know this may be hard-to-obtain information, but job postings have
not been encouraged in the technical discussion groups for, oh, say,
nearly two decades now. Please put job postings into groups with
"jobs" in the name. I'm pretty sure this is what the stuff in
"new.announce.newusers" says as well (the operating handbook for
Usenet).
I'm saying this publicly so that anyone searching this group by
dejanews will see this. Of course, the next poster reading this will
probably be someone that doesn't read the group before they post as
well. <sigh>
I'm frankly a little tired of people that don't read the manual before
they post to Usenet.
Just another guy who's beating a dead horse apparently, :-)
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Tue, 08 Sep 1998 00:47:46 GMT
From: "Richard" <Richard@WowMe.com>
Subject: Re: Perl Programmer Needed
Message-Id: <S8%I1.2689$JW5.8001506@news.rdc1.md.home.com>
Randal,
I think you are majorly overreacting. Notice, we are a small company.
We have some technical issues we need help with in Perl. Since this group
is for getting help with Perl programming, I came here to ask. If you
really felt this strongly about it, you could have sent me an email asking
me not to do it again. Instead, you decided to use your power to post to
"make an example" of us. I have been using Usenet for almost a decade now.
Not as long as your two decades, but enough time to be able thoughtful and
respectful of the other Usenet users. So far you are the only one who has
flamed me for this. Had you done it via email, I would not be upset, I
would simply stop asking in this group. However, what you did is
embarrassing and has me quite upset. I have had nothing but good response
from my post. It was HONEST, STRAIGHTFORWARD and BENEFITS OTHERS. If you
want to flame someone publicly, flame the people who fill up usenet with
their "get-rich-quick" schemes and adult related content. If you want to
tell someone they committed a social faux pua, have the decency to tell them
via email. Doing it publicly like this only serves to boost your ego by
showing you knew something someone else doesn't know. Do you feel better by
causing me embarrassment? Did it help further some personal cause of yours?
What did you gain from doing this? What have I lost? In a few days your
message will be expired. So will mine. In the meantime, I was able to find
people trying to earn an HONEST dollar and I will get my Perl problems
solved. You can now sleep well at night knowing you embarrassed someone
trying their damndest to earn a living and run and HONEST BUSINESS.
Richard
Randal Schwartz wrote in message <8cyarvpjdu.fsf@gadget.cscaper.com>...
>>>>>> "Richard" == Richard <Richard@WowMe.com> writes:
>
>Richard> We are looking for a Perl programmer who is familiar with
>Richard> ActiveState's WinDos Perl on NT server. It would be project
>Richard> based work from home. We are a small company and probably
>Richard> could not afford an expert. But none of our needs should
>Richard> require one. If you are interested in making some extra
>Richard> money in your spare time, please reply to author.
>
>I know this may be hard-to-obtain information, but job postings have
>not been encouraged in the technical discussion groups for, oh, say,
>nearly two decades now. Please put job postings into groups with
>"jobs" in the name. I'm pretty sure this is what the stuff in
>"new.announce.newusers" says as well (the operating handbook for
>Usenet).
>
>I'm saying this publicly so that anyone searching this group by
>dejanews will see this. Of course, the next poster reading this will
>probably be someone that doesn't read the group before they post as
>well. <sigh>
>
>I'm frankly a little tired of people that don't read the manual before
>they post to Usenet.
>
>Just another guy who's beating a dead horse apparently, :-)
>
>--
>Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
>Keywords: Perl training, UNIX[tm] consulting, video production, skiing,
flying
>Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger
merlyn@teleport.com)
>Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
>Quote: "I'm telling you, if I could have five lines in my .sig, I
would!" -- me
------------------------------
Date: Tue, 08 Sep 1998 01:41:47 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Perl Programmer Needed
Message-Id: <8c90jvpeig.fsf@gadget.cscaper.com>
>>>>> "Richard" == Richard <Richard@WowMe.com> writes:
Richard> Instead, you decided to use your power
Richard> to post to "make an example" of us.
Richard, I apologize. I replied to your message because it
was conveniently within my "followup" buffer.
I should have clearly posted a message that was generic that said "I
have recently noticed an increase in the job postings here. Please
stop." Along with most of the content of my prior message.
NONE of this was specifically targetted at you.
NONE of it.
Richard> I have been using Usenet for almost a decade now. Not as
Richard> long as your two decades, but enough time to be able
Richard> thoughtful and respectful of the other Usenet users.
Well, maybe it was targetted at you then. :-) Why did you think you
could violate the Usenet rules so easily?
Richard> So far you are the only one who has flamed me for this.
Richard> Had you done it via email, I would not be upset, I would
Richard> simply stop asking in this group.
You mean "in all groups except those permitted by the operating
manuals"? Or do you mean "until I get flamed by another person in
another group"? <sigh>
And that I'm the only one maybe means I'm the only one that takes the
time to care about what happens to Usenet. Even *in* the misc
groups. :)
Richard> Doing it publicly like this only serves to boost your ego
Richard> by showing you knew something someone else doesn't know.
Oddly enough, if you've been around for "almost a decade", how come
you didn't know already? I think I hit a good nerve here. :)
Richard> Do you feel better by causing me embarrassment?
Nope. That's not why I did it.
Richard> Did it help further some personal
Richard> cause of yours?
Not unless you define "keeping Usenet going" as a personal cause.
It's actually very impersonal. There are a set of guidelines that
have been created since 1980. To submit a post, you should be abiding
by those rules. I take those rules very seriously. Maybe you should
as well, if you've really been around "for almost a decade".
Richard> What did you gain from doing this? What
Richard> have I lost? In a few days your message will be expired. So
Richard> will mine.
As I said, it was for Dejanews. I'm tired of having dozens of
inappropriate job postings here, instead of in the groups they belong.
I've not seen enough public compaints, so I expect the problem
is that no-one sees anyone else taken to task for it.
Imagine for a moment that I had sent you mail, and that *you* had
stopped. This would not solve it for the next guy. But this public
exchange will hopefully be noticed by at least a dozen other people,
and maybe 10-20% of the postings will stop. Maybe.
Richard> In the meantime, I was able to find people trying
Richard> to earn an HONEST dollar and I will get my Perl problems
Richard> solved. You can now sleep well at night knowing you
Richard> embarrassed someone trying their damndest to earn a living
Richard> and run and HONEST BUSINESS.
Again, not my intent. As I said, my mistake here was in following up
to *your* message. But thanks for the dialog. It helps illustrate to
the others exactly how difficult this job is. :)
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Tue, 08 Sep 1998 01:54:47 GMT
From: "Richard" <Richard@WowMe.com>
Subject: Re: Perl Programmer Needed
Message-Id: <H70J1.2692$JW5.8027958@news.rdc1.md.home.com>
When I read the first sentence, I started to back off my initial assessment
that you are desperately in need of an ego boost. Then I read on and
realized you are literally STARVING for an ego boost. Well, here I am.
I'll be your little target. You can pick on me and get it all out of your
system and make yourself feel so much better for trying to prove your point.
My point still stands, I not only didn't hurt anyone by my post, I am
helping others. HONESTLY. Perhaps if you flame me enough you will stay off
some other HONEST SMALL BUSINESSES trying to offer money to people who want
to use their HARD LEARNED talents to put FOOD on their table and clothes on
their kids backs. Like in my own case!
Richard
Randal Schwartz wrote in message <8c90jvpeig.fsf@gadget.cscaper.com>...
>>>>>> "Richard" == Richard <Richard@WowMe.com> writes:
>
>Richard> Instead, you decided to use your power
>Richard> to post to "make an example" of us.
>
>Richard, I apologize. I replied to your message because it
>was conveniently within my "followup" buffer.
>
>I should have clearly posted a message that was generic that said "I
>have recently noticed an increase in the job postings here. Please
>stop." Along with most of the content of my prior message.
>
>NONE of this was specifically targetted at you.
>
>NONE of it.
>
>Richard> I have been using Usenet for almost a decade now. Not as
>Richard> long as your two decades, but enough time to be able
>Richard> thoughtful and respectful of the other Usenet users.
>
>Well, maybe it was targetted at you then. :-) Why did you think you
>could violate the Usenet rules so easily?
>
>Richard> So far you are the only one who has flamed me for this.
>Richard> Had you done it via email, I would not be upset, I would
>Richard> simply stop asking in this group.
>
>You mean "in all groups except those permitted by the operating
>manuals"? Or do you mean "until I get flamed by another person in
>another group"? <sigh>
>
>And that I'm the only one maybe means I'm the only one that takes the
>time to care about what happens to Usenet. Even *in* the misc
>groups. :)
>
>Richard> Doing it publicly like this only serves to boost your ego
>Richard> by showing you knew something someone else doesn't know.
>
>Oddly enough, if you've been around for "almost a decade", how come
>you didn't know already? I think I hit a good nerve here. :)
>
>Richard> Do you feel better by causing me embarrassment?
>
>Nope. That's not why I did it.
>
>Richard> Did it help further some personal
>Richard> cause of yours?
>
>Not unless you define "keeping Usenet going" as a personal cause.
>It's actually very impersonal. There are a set of guidelines that
>have been created since 1980. To submit a post, you should be abiding
>by those rules. I take those rules very seriously. Maybe you should
>as well, if you've really been around "for almost a decade".
>
>Richard> What did you gain from doing this? What
>Richard> have I lost? In a few days your message will be expired. So
>Richard> will mine.
>
>As I said, it was for Dejanews. I'm tired of having dozens of
>inappropriate job postings here, instead of in the groups they belong.
>I've not seen enough public compaints, so I expect the problem
>is that no-one sees anyone else taken to task for it.
>
>Imagine for a moment that I had sent you mail, and that *you* had
>stopped. This would not solve it for the next guy. But this public
>exchange will hopefully be noticed by at least a dozen other people,
>and maybe 10-20% of the postings will stop. Maybe.
>
>Richard> In the meantime, I was able to find people trying
>Richard> to earn an HONEST dollar and I will get my Perl problems
>Richard> solved. You can now sleep well at night knowing you
>Richard> embarrassed someone trying their damndest to earn a living
>Richard> and run and HONEST BUSINESS.
>
>Again, not my intent. As I said, my mistake here was in following up
>to *your* message. But thanks for the dialog. It helps illustrate to
>the others exactly how difficult this job is. :)
>
>--
>Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
>Keywords: Perl training, UNIX[tm] consulting, video production, skiing,
flying
>Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger
merlyn@teleport.com)
>Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
>Quote: "I'm telling you, if I could have five lines in my .sig, I
would!" -- me
------------------------------
Date: 8 Sep 1998 02:20:59 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl Source Needed
Message-Id: <6t24ab$eg1$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Michael Hodge <mhodge@netcom.ca> writes:
:Can anyone point out a reliable source for "good" Perl source? What I
:would prefer to do is learn by example.
There are examples of this in
http://www.perl.com/CPAN-local/authors/Tom_Christiansen/scripts/
The code for the Perl Cookbook is also fetchable from the Camel Critique page.
--tom
--
/* Force them to make up their mind on "@foo". */
--Larry Wall, from toke.c in the v5.0 perl distribution
------------------------------
Date: Tue, 08 Sep 1998 00:42:50 GMT
From: "Steven McPherson" <stevenmc@home.com>
Subject: Perl WIN32: Looking for a TCP/UDP Connection
Message-Id: <e4%I1.7587$OJ1.14435265@news.rdc1.sfba.home.com>
Hi all-
Just wondering if there is a method to looking for a tcp/udp connection on
any port ? I would like to design this in such away so that if connection
is made to any tcp/udp port that I can log that info. I know that there are
many commercial tcp/udp wrappers available, but buying something just
wouldn't be any fun.
I can do the logging, once I have the data. However I need the method for
looking on all ports for the connection.
Thanks,
Steve
stevenmc@home.com
------------------------------
Date: 8 Sep 1998 00:48:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: reading a file backward
Message-Id: <6t1uta$4ug$1@client3.news.psi.net>
Tom Christiansen (tchrist@mox.perl.com) wrote on MDCCCXXXIII September
MCMXCIII in <URL: news:6t113a$4qi$1@csnews.cs.colorado.edu>:
++ [courtesy cc of this posting sent to cited author via email]
++
++ In comp.lang.perl.misc,
++ lr@hpl.hp.com (Larry Rosler) writes:
++ :file instead of an array of line offsets, or am I hallucinating? How is
++ :this approach different from indexing a database file to provide speedy
++ :random access, except that here the index is created on the fly in
++ :memory?
++
++ Did you measure this?
++
++ # Test1 -- use the store and backup way
++ @lines = <>;
++ for ($i = $#lines; $i >= 0; $i--) {
++ print $lines[$i];
++ }
++
++ # Test2 -- use the offset and seek way
++ $FILE = shift;
++ open FILE or die $!;
++ for ($addr = 0; <FILE>; $addr = tell) {
++ $offset[$.] = $addr;
++ }
++ for ($i = $#offset; $i > 0; $i--) {
++ seek(FILE, $offset[$i], 0) or die $!;
++ print scalar <FILE>;
++ }
++
++
++ Here are the results:
[ tests based on /etc/termcap ]
I'm not impressed by those figures. /etc/termcap is a relative small
file; too small to make a difference. It does matter if you're reading
a 150 Mb file.
++ Your approach is slower, Larry. :-)
Speed is not the only thing that matters. Memory as well - specially
considering that Perl doesn't give memory back to the OS.
I have one problem with Larry's approach. Storing indices of a really big
file still gives a really big array. And a relatively large startup time;
you need to scan through the entire file.
I would keep a pointer to the start of the last line I read, then, when
requiring the next line, read in small block backwards, searching for
a newline (or whatever $/ is set to), then return the appropriate string.
The advantage is no preprocessing time, and only constant extra memory.
The disavantage is (possible) multiple sysreads to get a next line.
What's "best" will largely depend on the size of the file you are processing.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: 8 Sep 1998 01:48:38 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: reading a file backward
Message-Id: <6t22dm$d6c$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
lr@hpl.hp.com (Larry Rosler) writes:
:What I posted originally was a simple existence proof that contradicted
:Jonathan Stowe's assertion, which I then quoted from the Bighorn Sheep
:(that won't go over as well as the Llama or the Camel, I fear), anyway
It's the Ram Book.
:The Perl Cookbook, Recipe 8.4, p. 282: "You *must* read the lines into
:memory, then process them in reverse order. Needless to say, this
:requires at least as much available memory as the size of the file."
I think you are taking this too strongly. I was trying to provide a nice
simple solution. Notice the simple solution beats the fancy one
in time. Here are words of wisdom from Rob Pike:
* Rule 1. You can't tell where a program is going to spend its time.
Bottlenecks occur in surprising places, so don't try to second
guess and put in a speed hack until you've proven that's where the
bottleneck is.
* Rule 2. Measure. Don't tune for speed until you've measured, and even
then don't unless one part of the code overwhelm the rest.
* Rule 3. Fancy algorithms are slow when n is small, and n is usually
small. Fancy algorithms have big constants. Until you know that
n is frequently going to be big, don't get fancy. (Even if n does
get big, use Rule 2 first.) For example, binary trees are always
faster than splay trees for workaday problems.
* Rule 4. Fancy algorithms are buggier than simple ones, and they're
much harder to implement. Use simple algorithms as well as simple
data structures. The following data structures are a complete list
for almost all practical programs:
array
linked list
hash table
binary tree
* Of course, you must also be prepared to collect these into compound
data structures. For instance, a symbol table might be implemented as a
hash table containing linked lists of arrays of characters.
There are of course many ways of ``reading a file backwards'', one of
which is to implement a shadow version as a doubly linked list on disk.
That's certainly not my recommendation. I just wanted something simple.
Note also that the I/O system is highly optimized for forward reading.
That's why it does look-ahead. If you run backwards in the file, you
thrash it -- just like the Vax-killers of old that would murder VM by
doing the same thing in memory.
--tom
--
I hope to get Perl 5 out this summer, for certain values of summer.
-- <1993Jun5.052825.3897@netlabs.com>
------------------------------
Date: 8 Sep 1998 00:44:49 GMT
From: dkusters@monet.artisan.calpoly.edu (David Michael Kusters (none))
Subject: s/// on config file problem
Message-Id: <6t1um1$qev$1@cscnews.csc.calpoly.edu>
I'm reading in a config file that, among other things, can use
environment variables by using ${}'s (such as ${HOME}). For
example, here are a few lines in a sample config file:
set home = ${HOME}
set project = ${HOME}/${PROJECT}
set foo = ${HOME} ${PROJECT}
set bar = ${HOME}_${PROJECT}
set moo = ${HOME}asdffdsa${PROJECT}
To evaluate the ${}'s into environment variables, I am using the
following substitution on each line:
s'\$\{(\S+)\}'$ENV{ $1 }'eg;
This works for home and foo, but not project, bar, or moo. Whenever
two or more ${}'s are on the same line and no space seperates them,
then I get the following error:
Use of uninitialized value at /home/dkusters/bin/fcs/tests/depend line
152, <fConfigFile> chunk 57.
Where depend is my script and fConfigFile is the filehandle I am using.
In the above example, project, bar, and moo are all set to nothing.
Please email responses as I am not a regular here. Thank you for your
help.
--
Dave Kusters dkusters@calpoly.edu
Software Developer CAD Research Center, San Luis Obispo, CA
Practice kind acts of randomness and beautiful acts of senility.
------------------------------
Date: Tue, 08 Sep 1998 02:27:23 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: s/// on config file problem
Message-Id: <35F49784.156C3F2E@shaw.wave.ca>
[posted & mailed]
David Michael Kusters (none) wrote:
>
...
> set home = ${HOME}
> set project = ${HOME}/${PROJECT}
>
> set foo = ${HOME} ${PROJECT}
> set bar = ${HOME}_${PROJECT}
> set moo = ${HOME}asdffdsa${PROJECT}
>
> To evaluate the ${}'s into environment variables, I am using the
> following substitution on each line:
>
> s'\$\{(\S+)\}'$ENV{ $1 }'eg;
>
> This works for home and foo, but not project, bar, or moo.
>
That's because \S+ is acting greedy so you're trying to substitute stuff
like
$ENV{'HOME}/${PROJECT'}
$ENV{'HOME}_${PROJECT'}
$ENV{'HOME}asdffdsa${PROJECT'}
Brush up on perlre. A few solutions:
s'\$\{(\S+?)\}'$ENV{ $1 }'eg; # ? makes non-greedy
s'\$\{([^}]+)\}'$ENV{ $1 }'eg;# [^}] match non-'}'s
s'\$\{(\w+)\}'$ENV{ $1 }'eg; # \w is probably sufficient for
# environment variables
> Please email responses as I am not a regular here.
Become a semi-regular, at least. You would see this type of thing quite
frequently. Speaking of which, see also perlfaq6, "What does it mean
that regexps are greedy? How can I get around it?"
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Tue, 08 Sep 1998 00:06:29 GMT
From: saints@jps.net (CA Aspiras)
Subject: ssi exec error...
Message-Id: <35f46caa.1504258@news.jps.net>
hi!
i'm new to perl and i'm trying to make a random line picker script for
my webpage to be executed via ssi -- using this tag:
<!--exec cgi="/cgi-bin/rand_line.pl"-->
code:
###########################
$datafile = "/home/usr22/www/data/random1.dat";
open (FILE, "$datafile") || die "Can't open $datafile\n":
@file = <FILE>;
close (FILE);
$lines = join('', @file);
@lines = split(/\n/, $lines);
srand(time ^ $$);
$line = rand(@lines);
print "Content-type: text/html\n\n";
print $lines[$line];
exit;
###########################
this code works fine. but using this single script across multiple
datafiles is a problem. so, i tried modifying the code to accept some
kind of input -- now using this ssi tag:
<!--exec cgi="/cgi-bin/rand_line.pl?random1.dat"-->
new code:
###########################
$file = $ENV{'QUERY_STRING'};
$datafile = "/home/usr22/www/data/$file";
open (FILE, "$datafile") || die "Can't open $datafile\n":
@file = <FILE>;
close (FILE);
$lines = join('', @file);
@lines = split(/\n/, $lines);
srand(time ^ $$);
$line = rand(@lines);
print "Content-type: text/html\n\n";
print $lines[$line];
exit;
###########################
somehow, the tag gives me the usual error:
[an error occurred while processing this directive]
and somehow the code works when i type the command line in this
format::
http://www.mycom.com/cgi-bin/rand_line?random1.dat
so, <!--exec cgi="/cgi-bin/rand_line.pl?random1.dat"--> doesn't work
but http://www.mycom.com/cgi-bin/rand_line?random1.dat works.
can somebody tell me what's wrong here?
thanks.
-cesar
------------------------------
Date: Tue, 08 Sep 1998 02:26:39 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Text::CSV parsing sporadically
Message-Id: <zB0J1.539$oa3.1884@nsw.nnrp.telstra.net>
In article <19980907053944.4128.qmail@nym.alias.net>,
steve@inature.com.au (Steve Vertigan) writes:
> July-August-September like British summer 150 - 260C. East access to Gold
This is the problem. Text::CSV documentation states:
# perldoc Text::CSV
CAVEATS
This module is based upon a working definition of CSV format
which may not be the most general.
1 Allowable characters within a CSV field include 0x09
(tab) and the inclusive range of 0x20 (space) through
0x7E (tilde).
That degree character falls outside the range. I spotted it because I
recently had the same problem. I don't know why this restriction was
imposed.
You could have a look at the Text::CSV_XS module which mentions that
it is 8 bit clean.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: Mon, 7 Sep 1998 18:15:50 -0700
From: "Harsha Jayasekera" <MegaManz@email.msn.com>
Subject: URGENT HELP!!!
Message-Id: <ueZkaWs29GA.220@upnetnews03>
I am struggling to install a Forum script on a unix server. Could someone
please help me
install it? Please mail me at harsha@megagames.com
Thanks a bunch!
Harsha
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3656
**************************************