[7511] in Perl-Users-Digest
Perl-Users Digest, Issue: 1137 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 7 11:07:11 1997
Date: Tue, 7 Oct 97 08:00:24 -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 Tue, 7 Oct 1997 Volume: 8 Number: 1137
Today's topics:
Re: $x = $y || $z - dangerous assumption? <rootbeer@teleport.com>
Re: $x = $y || $z - dangerous assumption? <merlyn@stonehenge.com>
Re: $x = $y || $z - dangerous assumption? <merlyn@stonehenge.com>
Re: accursed error message <rootbeer@teleport.com>
Re: Another Perl vs C question <rootbeer@teleport.com>
Re: Cannot compile perl 5.004.03 under NEXTSTEP 3.3 (Matthew Seaman)
Re: chop from left to right (Will Morse)
Re: chop from left to right <merlyn@stonehenge.com>
Re: Coverting Flatfile *to* Excel <friedman@uci.edu>
Re: Determining if function exists in class (Michael Fuhr)
Re: file open <rootbeer@teleport.com>
Re: Filehandle to file name? <merlyn@stonehenge.com>
Re: Mail::Send module assistance request <gbarr@ti.com>
Re: Newbie ques: How to concatenate two strings? (Jeremy D. Zawodny)
Re: Newbie ques: How to concatenate two strings? (I R A Aggie)
Perl eq to C struct (Brian J.)
Re: Problem with getservbyname over PPP connection? <rootbeer@teleport.com>
Re: Q : Files using question <rootbeer@teleport.com>
re help needed (Thomas A. Loser)
Re: re help needed (Tad McClellan)
Re: Sorting values such as 1.1, 1.1.1, 2.1 into order (Matti Kinnunen)
Re: Sorting values such as 1.1, 1.1.1, 2.1 into order (Andrew M. Langmead)
use lib slows down completely: <monolith@CMU.EDU>
Re: use lib slows down completely: <Marty@capehatteras.net>
Re: Wanted: Wall/Schwartz book (1st ed) <merlyn@stonehenge.com>
Re: Why don't 'require' variables count towards "used o <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 5 Oct 1997 08:44:07 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Damian Conway <damian@cs.monash.edu.au>
Subject: Re: $x = $y || $z - dangerous assumption?
Message-Id: <Pine.GSO.3.96.971005083838.6565G-100000@usertest.teleport.com>
On 5 Oct 1997, Damian Conway wrote:
> Tom Phoenix <rootbeer@teleport.com> writes:
>
> >> my $x = shift || $default;
>
> >The Perl development team is working on a way that you could write
> >something like that which would assign the first defined item (rather than
> >the first true one) among its operands. With any luck, it'll be in a
> >future version of Perl.
>
> Not presuming to second-guess the Perl Gods (:-), but does it need to
> be anything fancier than:
>
> sub first_defined { map { return $_ if defined $_ } @_ }
>
> my $x = first_defined(shift, $default);
It might need to be fancier. Suppose you have this...
my $x = shift || &default();
This doesn't call &default() unless it's needed. But there's no way to
make a sub which evaluates only some of its arguments.
Not yet, at least... :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 05 Oct 1997 09:22:11 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Peter.J.Scott@jpl.nasa.gov
Subject: Re: $x = $y || $z - dangerous assumption?
Message-Id: <8cen6018p8.fsf@gadget.cscaper.com>
>>>>> "Peter" == Peter Scott <pjscott-remove-to-email@euclid.jpl.nasa.gov> writes:
Peter> The thing that bothers me about this - and maybe I'm
Peter> overreacting - is that if there *was* an argument, but it was
Peter> 0, $x will still get $default. Of course, I can handle this
Peter> case, assuming I really want a different action if the argument
Peter> is 0 (or ""):
Peter> $x = $default unless defined (my $x = shift);
Not quite. If you want a thoroughly robust idiom, use this:
my $x = @_ ? shift : $default;
Otherwise, you'll miss an "undef" that you just shifted off the array.
Imagine invoking &yoursub(undef, 3, 4)...
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 330 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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@ora.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: 05 Oct 1997 09:26:16 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: $x = $y || $z - dangerous assumption?
Message-Id: <8cbu1418if.fsf@gadget.cscaper.com>
>>>>> "Damian" == Damian Conway <damian@cs.monash.edu.au> writes:
Damian> Not presuming to second-guess the Perl Gods (:-), but does it need to
Damian> be anything fancier than:
Damian> sub first_defined { map { return $_ if defined $_ } @_ }
Ewwwww. My eyes hurt. map/grep in a void context is Bad Form,
especially when this one could have been done by foreach so much easier:
sub first_defined { for (@_) { return $_ if defined $_; } }
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 330 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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@ora.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: Mon, 6 Oct 1997 09:53:43 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: nectar quash transparent <bkelvis@yakko.cs.wmich.edu>
Subject: Re: accursed error message
Message-Id: <Pine.GSO.3.96.971006094900.10551L-100000@usertest.teleport.com>
On 5 Oct 1997, nectar quash transparent wrote:
> Modification of a read-only value attempted at (eval 203) line 11.
>
> apparently im mucking with something that doesnt want to be
> mucked with, but where is it at?
> Basically, what does the " at (eval 203) line 11" refer to?
That's line 11 of the 203rd call to eval. Which may not be much easier to
find. :-) But now you can try to (say) print each eval to a log file
before you run it, and see which one is complaining.
It's for this reason (among others) that most uses of eval STRING can be
converted to eval BLOCK, so you can catch errors more easily. Or you could
use another technique to avoid compilation at run time.
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sun, 5 Oct 1997 08:37:59 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: John Armsby <jaws@atl.mindspring.com>
Subject: Re: Another Perl vs C question
Message-Id: <Pine.GSO.3.96.971005082226.6565F-100000@usertest.teleport.com>
On Sat, 4 Oct 1997, John Armsby wrote:
> I have embraced perl to implement cgi scripts with one exception. I
> have a 3-4 meg ascii file which is 'searched' by the user inputing a
> query string which I 'strstr' one line at a time. When there is a
> string match, the script spits back the line in html...
> The entire script is probablly only about 300 lines or so. If I had
> written it in Perl, it would probably be a third of the size...
Why would the Perl script have to be so large? :-) The main loop would
look something like this, I imagine, and there's not much else that you'd
need unless the output format was quite fancy.
$str = lc $str; # Search string to lc
while (<FILE>) {
$_ = lc $_;
next if index($_, $str) == -1;
# Something to output $_ in some format...
}
> I recently upgraded the C code with incredible pain and suffering to
> output a simple html table. In perl this would have been trivial.
> In C (since I have become rusty) it was exceedingly unpleasant.
>
> I stuck with the C because I need speed to spit out the html. I
> thought (true or false) that Perl compiling would slow things down.
Perhaps you should check out the mod_perl extension to the popular Apache
webserver, which lets your script remain compiled in memory. Speedups of
100 to 1000 times (!) aren't unheard of.
But, in your case, I'd imagine that a good script in Perl would be pretty
much as fast as your C routine is, since the speed for searching a large
file like that is strongly limited by the speed of your I/O systems. (But
have you considered indexing the file? That could let you speed things
considerably, even if the index needed to be rebuilt periodically.)
> Are there any comments on this simple script as to whether i should
> rewrite the script in Perl and forsake C or stick to C? Is there a
> technical reason here or does it boil down to what is easiest for me?
I don't see any technical reasons why you couldn't do this in Perl. Good
luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 6 Oct 1997 18:03:43 GMT
From: Matthew_Seaman@plsys.co.uk (Matthew Seaman)
Subject: Re: Cannot compile perl 5.004.03 under NEXTSTEP 3.3
Message-Id: <61b95v$4vm$1@ironhorse.plsys.co.uk>
In <EHMDJp.2t9@RnA.NL> Gerben_Wierda@RnA.nl wrote:
> When compiling perl 5.004.03 under NEXTSTEP I get:
>
> `sh cflags libperl.a toke.o` toke.c
> CCCMD = cc -DPERL_CORE -c -DUSE_NEXT_CTYPE -arch m68k -arch i386
> -arch hppa -arch sparc -I/usr/local/include -O
> cc: Internal compiler error: program cc1obj got fatal signal 11
> *** Exit 1
> Stop.
>
> 1. Does anybody know what this error implies?
Yup. You've hit a compiler bug. For some reason toke.c is very good at
tickling compiler bugs.
> 2. Has anyone succesfully compiled perl 5.004.03 under NEXTSTEP 3.3?
Yes, sure. Under NS 3.3 I believe that if you set the optimization on toke.c
to zero, you can get that file to compile. You need to edit the file
`cflags':
ivyhouse:~/c/perl5.004_03:% diff -u cflags.orig cflags
--- cflags.orig Mon Oct 6 19:00:05 1997
+++ cflags Mon Oct 6 19:01:25 1997
@@ -84,7 +84,7 @@
scope) ;;
sv) ;;
taint) ;;
- toke) ;;
+ toke) optimize=-O0 ;;
usersub) ;;
util) ;;
*) ;;
There's probably a Configure variable you could set to achieve the same
effect,
but I never had the time to figure that one out.
Matthew
[Posted and Mailed]
--
Certe, Toto, sentio nos in Kansate nin iam adesse.
Matthew Seaman P&L Systems, 12 The Broadway, Amersham, Bucks., HP7 0HP, UK
Tel: +44 1494 432422 Fax: +44 1494 432478
------------------------------
Date: 7 Oct 1997 09:13:25 -0500
From: will@Starbase.NeoSoft.COM (Will Morse)
Subject: Re: chop from left to right
Message-Id: <61dg25$6sv$1@Starbase.NeoSoft.COM>
In article <61c18q$h52$1@news.wco.com>, Chris Toth <chris@mtnweb.com> wrote:
>Ok,
>
>I have a variable called $amount that gets its info from elsewhere and
>and the info it gets always has a $ sign in front of it, but I have to
>strip off the $ and just have the numercal value left, for example, lets
>say that $amount returns $ 43.38 I need to get $amount to return or
>become, just 43.38. To try and figure out how to do this I wrote this
>silly little test script which I thought would work:
>
>#!/usr/local/bin/perl
>$amount = "\$ 43.38";
>$amount = ~ s/\$//;
^
/|\
|
>$amount = $amount +1;
>print ($amount);
>
>but when I run it I get:
>
>4294967296
>
>instead of just 43.38
>
>Anyone know what I am doing wrong? Anyone have an elegant way of doing
>what I am trying to do? Examples are most apreciated. thanks ALL
>
>Chris
>
I think your problem is the extra space in between the = and ~.
I do not know why this does not produce a syntax error.
Will
--
# Copyright 1997 Will Morse. Internet repost/archive freely permitted.
# Hardcopy newspaper, magazine, etc. quoting requires permission.
#
# Gravity, # Will Morse
# not just a good idea, # Houston, Texas
# it's the law. # will@starbase.neosoft.com
#
# These are my views and do not necessarly reflect anyone else/
=========================================================================
By US Code Title 47, Sec.227(a)(2)(B), a computer/modem/printer
meets the definition of a telephone fax machine. By Sec.227(b)
(1)(C), it is unlawful to send any unsolicited advertisement to
such equipment, punishable by action to recover actual monetary
loss, or $500, whichever is greater, for EACH violation.
=========================================================================
------------------------------
Date: 07 Oct 1997 07:39:09 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: chris@mtnweb.com (Chris Toth)
Subject: Re: chop from left to right
Message-Id: <8c4t6t7i42.fsf@gadget.cscaper.com>
>>>>> "Chris" == Chris Toth <chris@mtnweb.com> writes:
Chris> #!/usr/local/bin/perl
Chris> $amount = "\$ 43.38";
Chris> $amount = ~ s/\$//;
Too much whitespace. Try "=~", not "= ~".
Chris> $amount = $amount +1;
Chris> print ($amount);
Chris> but when I run it I get:
Chris> 4294967296
Chris> instead of just 43.38
Yes. You are doing a bit complement of false, then adding 1 to that. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 329 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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@ora.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: 7 Oct 1997 13:41:17 GMT
From: "Eric D. Friedman" <friedman@uci.edu>
Subject: Re: Coverting Flatfile *to* Excel
Message-Id: <61de5t$fg4@news.service.uci.edu>
Keywords: excel database spreadsheet convert
In article <613j85$gtv@news.gvsu.edu>, Timothy Lux <tim@pbisweb.com> wrote:
<Hi:
[note: this has only the most tenuous relevance to Perl and so does
not belong here.]
<I don't want the user to have to do anything special... is there a way to open
<Excel and the file all from PERL? Or would the solution be to send the comma
<delimited file via email, and hope they know how to do it from that point on?
You could send by email or the web and let MIME headers indicate
to the client app that you're sending an excel document. Most browsers
have this mime-type already defined, and I iamgine many email
programs do too.
--
Eric D. Friedman
friedman@uci.edu
------------------------------
Date: 7 Oct 1997 07:19:25 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Determining if function exists in class
Message-Id: <61dcst$jj9@flatland.dimensional.com>
"Scott Plichta" <splichta@endeavortech.com> writes:
> I know that I can check for the existence of a functon as
> $func = "foo";
> &$foo() if (defined(&$foo)) ;
>
>
> What about when the method is part of a class/package?
If you're using Perl 5.004, look at the perltoot manual page
page and read the section "UNIVERSAL: The Root of All Objects."
It has the method you're looking for.
Hope this helps.
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Mon, 6 Oct 1997 09:47:46 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Rostislav Muchnik <muchnik@wpi.edu>
Subject: Re: file open
Message-Id: <Pine.GSO.3.96.971006094508.10551J-100000@usertest.teleport.com>
On Sun, 5 Oct 1997, Rostislav Muchnik wrote:
> I need create a program in pearl that will create a file
> and write something to it. I have to trigger that program from
> web page. How can I do that?
It's in the docs and FAQs. Start with the command 'perldoc'. Hope this
helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 07 Oct 1997 07:35:34 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Filehandle to file name?
Message-Id: <8c7mbp7ia1.fsf@gadget.cscaper.com>
>>>>> "Bart" == Bart Lateur <bart.mediamind@tornado.be> writes:
Bart> phenix@interpath.com (John Moreno) wrote:
>> Recently I wanted to delete a file using the filehandle. I found a work
>> around so that I didn't need to do this, but is it possible? Or is it
>> possible to get the file name from the filehandle?
Bart> I don't have the answer to your question, but anyway, I'd like to point
Bart> out that on most system you can't delete (or rename) a file that is
Bart> open. It won't work on my system anyway.
Really? That must be a non-Unix system. On nearly everything that
calls itself Unix or Unix-like, once the file is open, you can do
nearly anything with the name and it doesn't matter.
It would have helped if you had identified your "system".
Most of the readers of this newsgroup are on Unix-like boxes, hence
the broad general remark.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 329 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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@ora.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, 07 Oct 1997 07:55:21 -0500
From: Graham Barr <gbarr@ti.com>
To: John Simmons <strannik@strannik.com>
Subject: Re: Mail::Send module assistance request
Message-Id: <343A3139.99F1792B@ti.com>
John Simmons wrote:
>
> Hello,
>
> The pod documentation isn't clear to me on one point;
>
> Is it possible, using Mail::Send, to set a "From:" attribution?
There are two answers to that question, yes and no
> I note that two of the options are:
>
> $msg->set($header, @values);
> $msg->add($header, @values);
>
> But I'm not sure how this is actually used. Any examples or pointers to
> documentation more detailed than the pod would be greatly appreciated.
It is used differently depending on which underlying mailer you use.
If you use 'mail' then only the To, Cc, Bcc and Subject
headers are used. If you use 'sendmail' then all the headers
you add will be passed through.
Graham.
--
Originality is the ability to conceal your source.
------------------------------
Date: Tue, 07 Oct 1997 13:25:46 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: Newbie ques: How to concatenate two strings?
Message-Id: <343a318d.494489538@igate.hst.moc.com>
[cc'd automagically to original author]
On Tue, 07 Oct 1997 02:19:16 GMT, jglosz@san.rr.com (Joseph) wrote:
>AND THEN THERE SHALL BE CHAOS IN THE STREETS!!!!
>
>You just added your own noise, you dumb twit.
No. Tom's post was intelligent and relevant to the discussion at hand.
>Look at the other messages in this newsgroup. Exactly HOW MANY other
>questions are NOT answerable in the "fucking manual?" Maybe three?
So you've noticed.
>So you're saying this newsgroup should be limited to those three
>questions?
Well, in an ideal world, yes and no. People should not be asking
questions which they can and should find the answers to themselves.
However, this group is about more that Q & A.
>Still, you're going to get your way; you're going to get only
>"really good questions" on this NG from now on, and prevent it from
>"going straight to HELL", because I'm out of here. You've just
>reinforced my decision to standardize on ActiveX for our intranet.
Woohoo!
>So, you'll have a few less people polluting your newsgroup, because
>we're dropping all perl scripts as soon as practicable. That should
>make you all quite happy.
Actually, Tom is likely to as indifferent about your Intranet as I am.
What makes you believe otherwise?
>PS, please don't reply via email like you did for the last post.
>That's the hallmark of a general internet newbie. Nobody likes that.
I'd say that the available evidence contradicts you.
Jeremy
--
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio
http://www.marathon.com/
Unless explicitly stated, these are my opinions only--not those of my employer.
------------------------------
Date: Tue, 07 Oct 1997 09:41:08 -0400
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Newbie ques: How to concatenate two strings?
Message-Id: <-0710970941090001@aggie.coaps.fsu.edu>
In article <343a92e9.1638348@news-server>, jglosz@san.rr.com (Joseph) wrote:
+ So, you'll have a few less people polluting your newsgroup, because
+ we're dropping all perl scripts as soon as practicable. That should
+ make you all quite happy.
Actually, yes. You sound like a little kid who has thrown a fit and is
now going to go home with his toys.
As they say: don't let the door hit your ass on the way out.
James - followups...
--
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Tue, 07 Oct 1997 12:22:33 GMT
From: Brian@Kreation.com (Brian J.)
Subject: Perl eq to C struct
Message-Id: <343a2888.1082367@news.panix.com>
I was wondering if there is a way to create a structure, or in Pascal
a record? I also need an array of them.
Something like:
struct PCB ( $ioburst = 0, $cpuburst = 0, $jobnum = 0);
@PCBs (1..100] of PCB
so accessing them would look something like this:
$PCBs[2].$ioburst = 23;
I know its a mess, but you get the idea.
Brian Janice
Brian@Kreation.com
------------------------------
Date: Mon, 6 Oct 1997 09:56:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Creede Lambard <fearless@io.com>
Subject: Re: Problem with getservbyname over PPP connection?
Message-Id: <Pine.GSO.3.96.971006095444.10551M-100000@usertest.teleport.com>
On Sun, 5 Oct 1997, it was written:
> Does anyone know why the following line
>
> my($port) = (getservbyname('smtp', 'tcp'))[2];
>
> would generate a runtime exception over a PPP connection,
Does the corresponding call from C cause the same exception? If so, it's
the system's fault (or maybe the configuration's). If not, I'd say that's
a reportable bug that you could run perlbug upon. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Sun, 5 Oct 1997 09:00:52 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Efi Ivanir <ivanir@ilx334.iil.intel.com>
Subject: Re: Q : Files using question
Message-Id: <Pine.GSO.3.96.971005085947.6565J-100000@usertest.teleport.com>
On 5 Oct 1997, Efi Ivanir wrote:
> When I read file with :
>
> open(FILE,what-ever) ;
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check of the return value after opening a
file.
> while(<FILE>) {
>
> }
>
> Can I , In the middle of the while loop, go back one line ?
Yes, if you use seek (and perhaps also tell) which are documented in the
perlfunc(1) manpage. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Tue, 07 Oct 1997 08:09:36 -0400
From: tloser@valdemar.microserve.com (Thomas A. Loser)
Subject: re help needed
Message-Id: <tloser-0710970809360001@168.133.124.5>
I have been trying for several days now to write what *should* be a
simple expression.
Given something like: $fld = ' some test data ';
I simply need to strip off any leading and trailing spaces IF THEY EXIST
and retrieve the rest of the data as a single scaler. I thought this would
be simple - HA!
ANY help greatly appreciated!
TIA
-Tom Loser
--
imagine a world with no hypothetical situations
All opinions expressed here are mine and only mine - but you are welcome to borrow them if you like
------------------------------
Date: Tue, 7 Oct 1997 07:52:50 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: re help needed
Message-Id: <2bbd16.h31.ln@localhost>
Thomas A. Loser (tloser@valdemar.microserve.com) wrote:
: I have been trying for several days now to write what *should* be a
: simple expression.
: Given something like: $fld = ' some test data ';
: I simply need to strip off any leading and trailing spaces IF THEY EXIST
: and retrieve the rest of the data as a single scaler. I thought this would
: be simple - HA!
You thought right ;-)
--------------------
#!/usr/bin/perl -w
$fld = ' some test data ';
($nospaces = $fld) =~ s/^\s*|\s*$//g;
print "'$nospaces'\n";
# a faster way:
($nospaces = $fld) =~ s/^\s*//;
$nospaces =~ s/\s*$//;
print "'$nospaces'\n";
--------------------
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 07 Oct 1997 15:48:41 +0300
From: matti@universe.pc.helsinki.fi (Matti Kinnunen)
Subject: Re: Sorting values such as 1.1, 1.1.1, 2.1 into order
Message-Id: <lz201xkac6.fsf@universe.pc.helsinki.fi>
Sort::Versions - a perl 5 module for sorting of revision (and similar)
numbers
All files in this package are Copyright (c) 1996, Kenneth J. Albanowski.
All rights reserved. This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
This module allows easy sorting (via comparisons) of mixed text and numeric
strings, similar to the complex "version numbers" that many revision control
packages and shared library systems use. For an explanation of the
algorithm, it's easiest to look at these examples:
1.1 < 1.2
1.1a < 1.2
1.1 < 1.1.1
1.1 < 1.1a
1.1.a < 1.1a
1 < a
a < b
1 < 2
1 < 0002
1.5 < 1.06
search for version in
http://theory.uwinnipeg.ca/search/cpan-search.html
--
* matti.kinnunen@helsinki.fi *
* http://universe.pc.helsinki.fi/~matti/contact.html *
* +358-(0)40-593 50 91 but try first +358-(0)9-191 23978 *
------------------------------
Date: Tue, 7 Oct 1997 14:00:03 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Sorting values such as 1.1, 1.1.1, 2.1 into order
Message-Id: <EHopK3.LoE@world.std.com>
aml@world.std.com (Andrew M. Langmead) writes:
Apparently, this is the type of code that I write at 1:30 in the
morning, after watching a football game with friends.
># break each file name into its subsections
>for $file (@files) {
> s/\.html$//;
^^^^^^^^^^^^^^^ substitutes on $_ which is undefined, and does
not change in the loop.
> push @version, [ split /\./, $file ];
>}
This version, since the s/// has no effect, makes array elements like:
$version[2] = [ 1, 1, 'html' ];
and not:
$version[2] = [ 1, 1 ];
If the input are filenames in the same directory, (which they seem to
be) the result is the same. Since the filenames need to be unique,
there will always be a difference before we get to the final 'html'
element. And since there will be a difference before then, my
comparison subroutine will return before it gets to that element, and
we never get an "Argument isn't numeric" error.
maybe a better version would be:
for $file (@files) {
($sections) = $file =~ /(.*)\.html$/;
push @version, [ split /\./, $sections ];
}
which first extracts the sections numbers out of the filename, splits
those, and puts them in the array.
And maybe there would be a better name than @version, since these
aren't version numbers, but section and subsection numbers.
--
Andrew Langmead
------------------------------
Date: Tue, 7 Oct 1997 08:56:18 -0400
From: Aveek Datta <monolith@CMU.EDU>
Subject: use lib slows down completely:
Message-Id: <EoCX5mO00iVE01yUg0@andrew.cmu.edu>
I have a CGI script on a very popular server. Gets several hits per
second almost 24hours a day. Without any 'use' statements the load on
the machine < 2.
I access a database through DBI: load > 20 in under a minute after I
just add this one line 'use DBI' nothing else
I access a database through Mysqlperl: same with use Mysql
I add this 'use Carp' nothing else: load > 10 in under a minute
Why does use lib slow down the scripts so drastically? Anything I can do
to speed this up?
--- Re: spam sent on Sept 16 at 9pm or SO EST 'from me' was forged
------------------------------
Date: Tue, 7 Oct 1997 10:26:27 -0400
From: "Marty" <Marty@capehatteras.net>
Subject: Re: use lib slows down completely:
Message-Id: <343a4662.0@news.randori.com>
Ive experienced something similar to this myself. Is the script running as
fastcgi?? Can ya tell me more about the configuration??
And if ya find an answer and its not posted here please email me :)
(*)\||/(*)
| ~ ~ | Marty Poulin
( @ @ )
+-----oOOo-(<>)-oOOo------+-------------------------------------------+
| | There is an art, or rather a knack to |
| Marty@capehatteras.net | flying. The knack lies in learning how |
| http://capehatteras.net | to throw yourself at the ground and miss. |
| Oooo. | |
+----.oooO------( )------|-------------------------------------------+
( ) (_/
\_)
Aveek Datta wrote in message ...
>I have a CGI script on a very popular server. Gets several hits per
>second almost 24hours a day. Without any 'use' statements the load on
>the machine < 2.
>
>I access a database through DBI: load > 20 in under a minute after I
>just add this one line 'use DBI' nothing else
>
>I access a database through Mysqlperl: same with use Mysql
>
>I add this 'use Carp' nothing else: load > 10 in under a minute
>
>Why does use lib slow down the scripts so drastically? Anything I can do
>to speed this up?
>
>
>
>--- Re: spam sent on Sept 16 at 9pm or SO EST 'from me' was forged
>
------------------------------
Date: 05 Oct 1997 09:39:51 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: pas@unh.edu
Subject: Re: Wanted: Wall/Schwartz book (1st ed)
Message-Id: <8cafgo17vs.fsf@gadget.cscaper.com>
>>>>> "Paul" == Paul A Sand <pas@unh.edu> writes:
Paul> dks@mediaweb.com (dk smith) writes:
>> Amcurious. Why is this sentiment held by so many? Is there some good
>> content in the 1st edition that did not appear in the 2nd?
Paul> Yes. Most notably, a couple of chapters containing code snippets and
Paul> complete scripts for performing useful tasks. I appreciate that the
Paul> Perl5 Camel probably didn't have room for that content, and probably
Paul> the authors didn't have time to Perl5-ify the code, and probably they
Paul> wanted to make the book more clearly a reference tome than a tutorial,
Paul> etc., etc.
What? Have you been consulting the Psychic Friends Network again? :-)
But yes, it was I that made this executive decision as the lead writer
on the blue camel. I looked at the resources we had, and the
timeline, and those things fell below the cutline. We would have had
to delay the camel another six months again to add that material back
in, and that would have been intolerable, given the market pressure.
When you've got four writers that all have day jobs, it's a bit like
herding cats.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 330 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
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@ora.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: Sun, 5 Oct 1997 08:20:50 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Felix Morley Finch <felix@crowfix.com>
Subject: Re: Why don't 'require' variables count towards "used only once"?
Message-Id: <Pine.GSO.3.96.971005081340.6565E-100000@usertest.teleport.com>
On 4 Oct 1997, Felix Morley Finch wrote:
> I have a main file, xyzzy.pl:
>
> #!/usr/bin/perl -w
> require 'xyzzy-lib.pl';
> print $xyzzy1, "\n";
> exit 0;
> When I run ./xyzzy.pl, I get the complaint
>
> Name "main::xyzzy1" used only once: possible typo at ./xyzzy.pl line 3.
That's correct; at the end of the compile phase, Perl has seen that you've
used that variable only once, so it may be a typo. (Perl won't look at
xyzzy-lib.pl until runtime.) You can declare a variable with the use vars
pragma:
use vars qw/$xyzzy1/;
Now Perl sees that you're declaring it, so it's no problem.
If you want to have Perl notice the variables in xyzzy-lib.pl, consider
converting that to a module. Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
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 1137
**************************************