[8796] in Perl-Users-Digest
Perl-Users Digest, Issue: 2413 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 24 16:07:21 1998
Date: Fri, 24 Apr 98 13:00:34 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 24 Apr 1998 Volume: 8 Number: 2413
Today's topics:
$100 - PERL NEWSGROUP POSTER <techsoft@abcpages.com>
Re: Auto-generate HTML Tables (Jeff)
Re: Bug in list assign? <bmb@ginger.libs.uga.edu>
Re: Bug in list assign? (Andre L.)
Re: Bug in list assign? <jdporter@min.net>
Re: Bug in list assign? <jdf@pobox.com>
Re: Bug in list assign? <danboo@negia.net>
Re: Bug in list assign? <cmargoli@world.northgrum.com>
Re: Bug in list assign? <rootbeer@teleport.com>
Can an assignment and a substitution be done in one sta (Alfred von Campe)
Re: Can an assignment and a substitution be done in one (Earl Hood)
Re: Can I have a C++ program call a Perl program? <zenin@archive.rhps.org>
CPAN.pm error <kmiles@erols.com>
Re: Cron job and Date problem <gurun@acc.umu.se>
Re: Defending Perl (Ilya Zakharevich)
Re: Defending Perl (Ilya Zakharevich)
Re: Defending Perl (Ilya Zakharevich)
Re: Defending Perl <tchrist@mox.perl.com>
Re: foreach question <jdporter@min.net>
Re: fork and defunct process <vallon@pearl.fi.bear.com>
Re: fork and defunct process (Charles DeRykus)
Re: help with s/$foo/$bar/go; oddness <vallon@pearl.fi.bear.com>
Re: help with s/$foo/$bar/go; oddness (Peter Scott)
Re: help <lr@hpl.hp.com>
How to turn off warnings at *compile time*? (Peter Scott)
Re: Just a thought... <lr@hpl.hp.com>
Re: Just a thought... <tchrist@mox.perl.com>
Re: module usage (Earl Hood)
NEED HELP GRABBING RECORDS OUT OF TEXT FILE <ronb@schoolnotes.com>
NIS calls from Perl ??? <sassojo@sch.ge.com>
Re: NIS calls from Perl ??? <jdporter@min.net>
Perl classes or training <jason.lorsong@norfolkva.ncr.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 24 Apr 1998 15:04:59 -0700
From: Alexander Kovalenko <techsoft@abcpages.com>
Subject: $100 - PERL NEWSGROUP POSTER
Message-Id: <35410C8A.7314FB15@abcpages.com>
willing to pay for program which would work like formmail , but not send
e-mail , but rather post it to newsgroups..
if you can help me... reply back...
------------------------------
Date: Fri, 24 Apr 1998 18:54:12 GMT
From: jeffmcc@mindspring.com (Jeff)
Subject: Re: Auto-generate HTML Tables
Message-Id: <3540c6d5.20187397@news>
Open the file you want to use to create the tables.
Depending on what type of file you are using you'll do the following
in some fashion (the following is for a fixed length text file):
print "<html>\n";
print "<head>\n";
print "</head>\n";
print "<body>\n";
print "<table +any tags>\n";
open(F, $filename) || die "File can not be opened";
while (defined ($line = <F>)) {
@data = $line =~/(.{8})(.{10})(.{8})(.{30})(.{14})/;
print "<tr>\n";
print "<strong>\n";
print "<td> ",$data[0],"</td>";
print "<td> ",$data[1],"</td>";
print "<td> ",$data[2],"</td>";
print "<td> ",$data[3],"</td>";
print "<td> ",$data[4],"</td>";
}
print "</table>\n";
print "</body>\n";
print "</html>\n";
On Fri, 24 Apr 1998 11:12:06 -0600, johnvv@earthling.net wrote:
>Hello all,
>
>
> I have been making really groovy reports based on the HP glance product while
> using MLDBM and Freeze/Thaw ( or REFER, I like trucks and rednecks, more on
> that later ) and have been displaying with gnuplot and Gifgraph ( which I
> would very much like to see integrated ) garnished with bezier and linear
> regression.
>
> The static output (num of disks, cpus, memory ) files look very nice in
>tables
> within tables for the doubled bevel look and my question is this.
>
> Has anybody created a script which automagically genetrates tables from
> complex structures or flatfiles. I would be very nice to HREF the cells in
> the process.
>
> Its been two years since I touched cgi, I'll have more later.
>
> Thanx in advance, John van V. aka johnvv@hotmail.com or johnvv@earthling.net
>
>passme
>
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 24 Apr 1998 14:46:19 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Bug in list assign?
Message-Id: <Pine.A41.3.96.980424143855.11880A-100000@ginger.libs.uga.edu>
>From the (teal?) Camel book (p. 48):
"Another way to specify a literal list is with the qw (quote words) syntax
we mentioned earlier. This construct is equivalent to splitting a
single-quoted string on whitespace."
"List assignment in a scalar context returns the number of elements
produced by the expression on the right side of the assignment:"
Having quoted that, try this:
#!/usr/local/bin/perl -w
use strict;
my( $n, $fou );
$n = ($fou) = qw(a b c d); ### equiv to split?
print "$n\n"; # prints "2"
$n = ($fou) = split( " ", 'a b c d' ); ### equiv to qw?
print "$n\n"; # prints "2"
$n = ($fou) = ( 'a', 'b', 'c', 'd' );
print "$n\n"; # prints "4"
$n = ($fou) = f();
print "$n\n"; # prints "4"
sub f {
qw( a b c d );
} # end sub f
__END__
Perhaps there is a bug related to 'split'. Sorry, I didn't answer the
question; I'm just exploring it.
On 24 Apr 1998, Jonathan Feinberg wrote:
> Am I insane, or is this a bug?
>
> $n = (($foo) = qw(a b c)); # $n should get 3, no?
> print "$n\n"; # prints "2"
>
> This happened to me using GSAR's Win32 bindist, so I tried it on one
> of my Unices running 5.00404, and it happened there too. Am I going
> mad? Isn't list assignment in a scalar context supposed to evaluate
> to the number of elements in the RHS of the assignment?
>
> --
> Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
>
>
---
Brad Baxter, UGA
------------------------------
Date: Fri, 24 Apr 1998 14:55:14 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Bug in list assign?
Message-Id: <alecler-2404981455140001@dialup-685.hip.cam.org>
You are insane. :-)
This prints 3 as expected:
$n = @foo = qw(a b c); # $n = scalar(@foo)
print "$n\n";
I really don't know what you are trying to achieve by this:
$n = (($foo) = qw(a b c)); # $foo = 'a'
Understand that this assigns the value of the first element of list
('a','b','c') to the first - and only - element of list ($foo).
I don't have the wisdom to explain why $n equals 2 here, and not 1.
HTH,
A.L.
=============================
In article <1zunt90e.fsf@mailhost.panix.com>, Jonathan Feinberg
<jdf@pobox.com> wrote:
> Am I insane, or is this a bug?
>
> $n = (($foo) = qw(a b c)); # $n should get 3, no?
> print "$n\n"; # prints "2"
>
> This happened to me using GSAR's Win32 bindist, so I tried it on one
> of my Unices running 5.00404, and it happened there too. Am I going
> mad? Isn't list assignment in a scalar context supposed to evaluate
> to the number of elements in the RHS of the assignment?
>
> --
> Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Fri, 24 Apr 1998 19:01:56 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Bug in list assign?
Message-Id: <3540E320.302@min.net>
Jonathan Feinberg wrote:
>
> Am I insane, or is this a bug?
>
> $n = (($foo) = qw(a b c)); # $n should get 3, no?
> print "$n\n"; # prints "2"
>
> This happened to me using GSAR's Win32 bindist, so I tried it on one
> of my Unices running 5.00404, and it happened there too. Am I going
> mad? Isn't list assignment in a scalar context supposed to evaluate
> to the number of elements in the RHS of the assignment?
Sure looks like a bug to me.
$n = (($x,$y,$z) = qw(a b c)); # $n = 3
$n = (($x,$y ) = qw(a b c)); # $n = 3
$n = (($x ) = qw(a b c)); # $n = 2 !!!
$n = (($x ) = ('a','b','c')); # $n = 3
5.004_01
John Porter
------------------------------
Date: 24 Apr 1998 15:27:54 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Bug in list assign?
Message-Id: <wwcfge2d.fsf@mailhost.panix.com>
alecler@cam.org (Andre L.) writes:
> I really don't know what you are trying to achieve by this:
>
> $n = (($foo) = qw(a b c)); # $foo = 'a'
Your condescension contributes nothing to this discussion.
Not that it matters, but I was preparing a demonstration in an answer
to another post in this newsgroup. The point is that the behavior of
the above code differs from the specified behavior. Indeed, the above
code is modeled on code from perldata:
Array assignment in a scalar context returns the number of elements
produced by the expression on the right side of the assignment:
$x = (($foo,$bar) = (3,2,1)); # set $x to 3, not 2
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Fri, 24 Apr 1998 14:04:45 -0400
From: Dan Boorstein <danboo@negia.net>
To: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Bug in list assign?
Message-Id: <3540D43D.4FBC5779@negia.net>
Jonathan Feinberg wrote:
>
> Am I insane, or is this a bug?
>
> $n = (($foo) = qw(a b c)); # $n should get 3, no?
> print "$n\n"; # prints "2"
can't say that i know what the problem is, but it acts
differently if you don't use 'qw':
$n2 = (($foo) = qw(a b c));
$n3 = (($foo) = ('a', 'b', 'c'));
print "\$n2: $n2\n"; # print "2"
print "\$n3: $n3\n"; # print "3"
--
Dan Boorstein home: danboo@negia.net work: danboo@y-dna.com
"THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER."
- Cosmic AC
------------------------------
Date: Fri, 24 Apr 1998 19:31:08 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Bug in list assign?
Message-Id: <3540E87C.5EE3@world.northgrum.com>
Jonathan Feinberg wrote:
>
> Am I insane, or is this a bug?
>
> $n = (($foo) = qw(a b c)); # $n should get 3, no?
> print "$n\n"; # prints "2"
>
> This happened to me using GSAR's Win32 bindist, so I tried it on one
> of my Unices running 5.00404, and it happened there too. Am I going
> mad? Isn't list assignment in a scalar context supposed to evaluate
> to the number of elements in the RHS of the assignment?
>
According to the Blue Camel, the qw notation is the same as a split
on whitespace. For split, it says (p 221 in my copy) "When assigning
to a list, if LIMIT is omitted, Perl supplies a LIMIT one larger than
the number of variables in the list, to avoid unnecessary work."
So following the rule for what split does in list and scalar context,
split assigns 'a' to $foo and 2 to $a, and throws away 'b c'.
--
Charles G. Margolin DSSD Internal Information Services
cmargoli@world.northgrum.com Northrop Grumman Corp. 0624/23
margolin@acm.org Hawthorne, California 90250-3277
------------------------------
Date: Fri, 24 Apr 1998 19:52:06 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Bug in list assign?
Message-Id: <Pine.GSO.3.96.980424123923.5518o-100000@user2.teleport.com>
On 24 Apr 1998, Jonathan Feinberg wrote:
> Am I insane, or is this a bug?
>
> $n = (($foo) = qw(a b c)); # $n should get 3, no?
> print "$n\n"; # prints "2"
What's happening here is that qw// is implemented as a split (at least, it
is done this way in current versions of Perl; perhaps not in the future).
Split in a list context cheats: It peeks to see whether it's being
assigned into a literal list of scalars. If so, it implicitly sets the
third parameter of split to one more than the number of scalars, thereby
putting an upper limit on the number of fields it produces. In short, that
qw// is effectively this:
split /\s+/, 'a b c', 2
So, $n has the correct number of elements being assigned, two.
(Some people have been counting the number of contexts in Perl. I wonder
whether they've counted this one! :-)
Because the implementation of split may change in a future version of
Perl, you shouldn't count on this behavior. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 24 Apr 1998 18:59:18 GMT
From: alfred@hw.stratus.com (Alfred von Campe)
Subject: Can an assignment and a substitution be done in one statement?
Message-Id: <6hqne6$15q@transfer.stratus.com>
I often find myself wanting to assign the modified value of one
scalar to another. Something like this:
$foo = $bar;
$foo =~ s/x/y/;
Can this be done in one fell swoop?
Alfred
--
+------------------------------------------------------------+
| Phone: H: 978.448.6214, W: 508.490.6306, fax: 508.460.2888 \
| Mail: Alfred von Campe, 402 Lowell Road, Groton, MA 01450 \
| Email: alfred@hw.stratus.com \
+----------------------------------+-----------------------------+
| Why is common sense so uncommon? | I'd rather be flying N4381Q |
+----------------------------------+-----------------------------+
------------------------------
Date: 24 Apr 1998 19:04:45 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Can an assignment and a substitution be done in one statement?
Message-Id: <6hqnod$ju9@news.service.uci.edu>
[mail & posted]
In article <6hqne6$15q@transfer.stratus.com>,
Alfred von Campe <alfred@hw.stratus.com> wrote:
> $foo = $bar;
> $foo =~ s/x/y/;
>
>Can this be done in one fell swoop?
($foo = $bar) =~ s/x/y/;
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: 24 Apr 1998 19:51:04 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Can I have a C++ program call a Perl program?
Message-Id: <893447905.66175@thrush.omix.com>
[posted & mailed]
Bryan T Hoch <bth@acsu.buffalo.edu> wrote:
: Hi, I'm running a C++ program and i want to have it invoke a Perl program
: that i have written.
man fork
man exec
This is a C/C++ question. Running a perl program is no different
then any other program.
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: Fri, 24 Apr 1998 15:30:32 -0400
From: Kevin Miles <kmiles@erols.com>
Subject: CPAN.pm error
Message-Id: <3540E857.1478@erols.com>
I'm trying to use the CPAN.pm module on a TurboLinux 1.0 system.
# perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.36)
cpan> install Bundle::Apache
Use of uninitialized value at -e line 2139, <FIN> chunk 1.
Going to read /root/.cpan/sources/authors/01mailrc.txt.gz
Lockfile removed.
#
I'v tried deleting CPAN.pm and directories and reinstalling to no avail.
Any help would be appreciated.
Kevin Miles
------------------------------
Date: Fri, 24 Apr 1998 20:15:46 +0200
From: N i c l a s O l o f s s o n <gurun@acc.umu.se>
Subject: Re: Cron job and Date problem
Message-Id: <3540D6D2.D7A7AA4@acc.umu.se>
Alan Voorhees wrote:
> someone else wrote:
> > Like CGI scripts, cron jobs run in a different environment than you
> > may be expecting.
I haven't seen the answer above (news lag) but I would also like to
comment on it (if it wasn't answered any further?).
When you run cron jobs you really have to specify _absolute paths_ in
your perl-code.
> $data_file_path
Make sure that the path to the data file is absolute.
Cheers,
/Niclas
------------------------------
Date: 24 Apr 1998 19:01:05 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Defending Perl
Message-Id: <6hqnhi$o84$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <6hoein$ojk$1@csnews.cs.colorado.edu>:
> :Perl will run 200 times as slow as C for "most" things.
>
> +---------------------------------------------------+
> | +-----------------------------------------------+ |
> | | YOU'RE LYING. VISCIOUSLY. UNCONSCIONABLY. | |
> | +-----------------------------------------------+ |
> +---------------------------------------------------+
>
> Ignore that person.
Aha, and pigs fly.
Anyone with dejanews access can confirm that you participated in
discussions on 200x slowness of Perl. Yes, I remember that your
results were only 80x on your PPro200, but you have seen that most the
other guys get numbers around 200.
I do not understand what lying about Perl speed may achieve? Perl is
very good when you can make a Perl primitive to perform your task, but
this not possible for "most" things.
Ilya
------------------------------
Date: 24 Apr 1998 19:09:12 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Defending Perl
Message-Id: <6hqo0o$p4r$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <6hoekj$ojk$2@csnews.cs.colorado.edu>:
> :Perl is not compiled (even if you use perl2c translator).
>
> And there's another lie.
I can forgive you this accusation, since this is just a semantic
question.
But AFAIK, you claim you never read Perl source (hmm, maybe it was
Randal? Looks more probable ;-). Anyway, claiming that Perl is
compiled is similar to claiming that any Lisp program is already
compiled, since it is its own parse tree.
Compiling to a parse tree is only the *first* step of a *read*
compilation. Let us hope that after 5.005 is released people will
quickly hack perlcc to produce something more reasonable than a
compile-tree-loader-into-memory (looking into result of perlcc run I
see that the resulting file is *slightly* better than that - but not much).
Ilya
------------------------------
Date: 24 Apr 1998 19:14:40 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Defending Perl
Message-Id: <6hqob0$pvr$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to John Porter
<jdporter@min.net>],
who wrote in article <3540BA83.2A4E@min.net>:
> Ilya Zakharevich wrote:
> >
> > Perl will run 200 times as slow as C for "most" things. This is
> > confirmed by many independent benchmarks of different things.
>
> This from the same man who baldly asserted (in private
> correspondence) that <> (Perl) is faster than fgets (C).
I can claim it publically too.
Of course, *if*
$/ eq "\n",
*and*
you know what is the maximal length of your input lines,
the C library can do the same tricks as Perl does, and you can
optimize you C code to skip some of the things Perl does. In such a
case C will win.
With an arbitrary $/ I would think it is very hard to write a portable
C which would be as quick as Perl.
Ilya
------------------------------
Date: 24 Apr 1998 19:17:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Defending Perl
Message-Id: <6hqofl$so3$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
:Anyone with dejanews access can confirm that you participated in
:discussions on 200x slowness of Perl. Yes, I remember that your
:results were only 80x on your PPro200, but you have seen that most the
:other guys get numbers around 200.
Time to put your money where your mouth is, Ilya. Here's your challenge:
Write these simple programs in C, then write them in Perl, and time the
difference in runs.
TASK 1: Write a file copy program using I/O calls (not mmap).
There is no limit to the size of the files.
TASK 2: Write a program that reads all its input, then prints
out those input lines in the opposite order they
were read in. There is no limit to the number of
input records, nor of their lengths.
TASK 3: Write a word frequency counter. Read stdin, and produce
a list of unique words and the frequency they occurred at the
end of the run. There is no limit to the size of the input
file, the length of a line, the number of different words,
nor the size of each.
I can write each of those in Perl in less than five minutes each,
probably in five minutes for all of them. And they won't run
200 times slower than your version. I'll be generous and give you
10 times as long to write the C versions as I took to write the
Perl ones. And they'd better run 10x faster.
Guess what?
They won't.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
Hi, this is Ken. What's the root password?
------------------------------
Date: Fri, 24 Apr 1998 18:22:34 GMT
From: John Porter <jdporter@min.net>
Subject: Re: foreach question
Message-Id: <3540D9E6.5A4E@min.net>
Gilly (kEQNql) wrote:
>
> foreach (sort (@filelist)) { .. }
>
> Does it sort each time during the loop? or only once?
Just once. It's important to remember that the iterand of
a foreach loop gets fully evaluated into a list, before the
foreach loop ever gets its hands on it. Usually this is what
you want, but it can be a problem if the resulting list takes
up an unexpectedly large amount of memory. An alternative is
while, which evaluates its iterand in a scalar context
repeatedly (until it evaluates to false).
hth,
John Porter
------------------------------
Date: 24 Apr 1998 14:45:57 -0400
From: Justin Vallon <vallon@pearl.fi.bear.com>
Subject: Re: fork and defunct process
Message-Id: <x6eg1j3m522.fsf@pearl.fi.bear.com>
(This is really a Unix issue)
The <defunct> process (aka a zombie process) just means that the
parent process has not asked about the state of its child. Adding
a wait() cleans these processes up. You get a defunct process for
every child that has exited, for which status has not been returned
to the parent (via wait, etc).
Zombie processes take up no resources, besides a single entry in the
process table (typically). The child has exited.
If you have a long-running server that creates many children, you
should wait(), possibly with NODELAY or variants, to clean up
your zombies. Otherwise, I would not worry about it.
Of course, if you need to wait() for the child to complete at some
point (completion of a long-running job, or you're creating a
pipeline), that'll clean up your zombie process as well.
It only (typically) occurs when a server (parent) creates children
and is not concerned if (when) the children exit, and whether they
are successful or not.
brunke@dkrz.de (Lutz Brunke) writes:
> I have writen a small program that does a fork. The parent sleeps
> for 60 seconds the child for 30 seconds, then both processes exit.
> After 30 seconds 'ps' shows that the child is <defunct>. Why is
> the child process not terminating properly?
--
-Justin
vallon@bear.com
------------------------------
Date: Fri, 24 Apr 1998 18:32:39 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: fork and defunct process
Message-Id: <ErxKuG.DJH@news.boeing.com>
In article <6hpl4j$d13$1@alster.dkrz.de>, Lutz Brunke <brunke@dkrz.de> wrote:
>I have writen a small program that does a fork. The parent sleeps
>for 60 seconds the child for 30 seconds, then both processes exit.
>After 30 seconds 'ps' shows that the child is <defunct>. Why is
>the child process not terminating properly?
>
>demo program:
>if(fork()) {
> sleep 60;
> exit 0;
>}
>sleep 30;
>exit 0;
>
>ps after 45 seconds:
> me 680 679 0 0:00 <defunct>
> me 679 443 0 10:41:51 pts/4 0:00 perl fork.pl
>
perldoc -f fork and look for the section:
"If you fork() without ever waiting on your children, you
will accumulate zombies...."
HTH,
--
Charles DeRykus
------------------------------
Date: 24 Apr 1998 14:36:08 -0400
From: Justin Vallon <vallon@pearl.fi.bear.com>
Subject: Re: help with s/$foo/$bar/go; oddness
Message-Id: <x6eiunzm5if.fsf@pearl.fi.bear.com>
xie@netcom.com (Sheppard) writes:
...
You can (also) use quotemeta:
local $pattern = "|";
local $var = "This|is|a|test";
local $replace = ",";
local $quotepattern = quotemeta $pattern;
$var =~ s/$quotepattern/$replace/g;
print "$var\n";
=>
This,is,a,test
--
-Justin
vallon@bear.com
------------------------------
Date: 24 Apr 1998 18:40:32 GMT
From: psf@euclid.jpl.nasa.gov (Peter Scott)
Subject: Re: help with s/$foo/$bar/go; oddness
Message-Id: <6hqmb0$mn7@netline.jpl.nasa.gov>
You want the regex in a substitution to come from a variable which
might contain regex metacharacters which you don't want treated as such.
Just use \Q and it'll backslash 'em for you. In your example:
$copy =~ s/\Q$token/$new_token/go;
--
This is news. This is your | Peter Scott, NASA/JPL/Caltech
brain on news. Any questions? | (psf@euclid.jpl.nasa.gov)
Disclaimer: These comments are the personal opinions of the author, and
have not been adopted, authorized, ratified, or approved by JPL.
------------------------------
Date: Fri, 24 Apr 1998 12:22:34 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: help
Message-Id: <6hqoq7$oi5@hplntx.hpl.hp.com>
Brent Michalski wrote in message <35407D00.FBCA1872@inlink.com>...
...
>print '<INPUT NAME="GoOn" TYPE="submit" VALUE="Go On"> \n'; # OK
...
>There are others, but these will work, take your pick...
>
>Brent
>Perl Freak
Sorry, Brent, this one won't work (at least, not the way desired).
Within single quotes, \n does *not* produce a new-line character. It
produces the two characters backslash and n.
Llama p. 33, Blue Camel p. 39, etc., etc.
A later post (from Jonathan R. Seagrave) implied as much, but perhaps
beginners should be reminded explicitly.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 24 Apr 1998 18:37:08 GMT
From: psf@euclid.jpl.nasa.gov (Peter Scott)
Subject: How to turn off warnings at *compile time*?
Message-Id: <6hqm4k$mn7@netline.jpl.nasa.gov>
(Some days, it seems that the more I learn about Perl, the less I
know...)
Got a script that uses FindBin from CPAN. FindBin uses Cwd and calls
subroutines from it during a BEGIN block.
The Cwd in 5.004_04 is not -w friendly; the script outputs
Use of uninitialized value at /afs/jpl/group/fil/uai/perl/lib/Cwd.pm line 117.
several times. "Aha!" I thought, "I know the answer to this one; instead of
use FindBin;
I'll say
BEGIN {
local $^W = 0;
use FindBin;
}
" No such luck. As the FAQ says, $^W controls run-time warning printing.
And of course this is compile-time.
So how could I control compile-time warning printing?
In the mean time, I guess I'll just hack on Cwd.pm to stop Perl complaining...
--
This is news. This is your | Peter Scott, NASA/JPL/Caltech
brain on news. Any questions? | (psf@euclid.jpl.nasa.gov)
Disclaimer: These comments are the personal opinions of the author, and
have not been adopted, authorized, ratified, or approved by JPL.
------------------------------
Date: Fri, 24 Apr 1998 11:59:56 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Just a thought...
Message-Id: <6hqnfk$nro@hplntx.hpl.hp.com>
Ed Jamison wrote in message ...
...
>I don't view the current method of keeping time as religious as much as
i
>view it as a widely accepted method of keeping time, which was adopted
>because of a major event. ...
Nowadays, many scholars and others try to divorce the notation from
religious significance by referring to "BCE" (Before the Common Era) and
"CE" (Common Era).
...
>... When AD, BC were first introduced
>someone had to make the decision to count backward from whatever to 0
and
>then from 0 to 1998 and beyond.
Actually, they were not that smart at all. There is no year 0! The
year after 1 BCE is 1 CE. Just another snarl in computing time
differences.
BTW, does this thread have anything to do with Perl?
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 24 Apr 1998 19:33:37 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Just a thought...
Message-Id: <6hqpeh$so3$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"Larry Rosler" <lr@hpl.hp.com> writes:
:Nowadays, many scholars and others try to divorce the notation from
:religious significance by referring to "BCE" (Before the Common Era) and
:"CE" (Common Era).
I disbelieve. And considering that the majority of Americans
are at least nominally Christian, I don't see this changing.
Unless you live in Israel or the Soviet Union,
BC and AD are pretty here to stay, even if it offends you.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"Help save the world!" --Larry Wall in README
------------------------------
Date: 24 Apr 1998 18:22:50 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: module usage
Message-Id: <6hql9q$ikv@news.service.uci.edu>
In article <6hqimq$dqd$1@Mars.mcs.net>, Leslie Mikesell <les@MCS.COM> wrote:
>In article <Pine.GSO.3.96.980424075558.5518V-100000@user2.teleport.com>,
>Tom Phoenix <rootbeer@teleport.com> wrote:
>>
>>Of course, it's (virtually always) better to use a module which implements
>>the proper algorithm - which is somewhat different than you describe.
>>Other advantages to using a module: a module should be debugged (so you
>>don't have to worry about mistakes in that part of the algorithm),
>
>I haven't quite been convinced of the advantages of modules and
>making one script depend on lots of other parts to do relatively
>simple things. Perhaps I just don't know how to work with modules
>correctly so I'm open to advice. The key phrase above is
>'should be debugged'...
I believe Tom P. is stated that the standard modules have been
used and tested quite extensively, so chance of bugs are small.
So if something is wrong with your problem, it is more likely
due to something you did, and not what a module does.
>What do you do when you have scripts
>using nested modules that don't quite work, and if you need to
>change an interface to fix them, how do you track down all of the
>scripts on the system that are going to break as a result?
If the module in question is part of the standard module set that comes
with Perl, then you cannot just change function/method interfaces
without potential affecting other programs. If you can verify
a bug with a module, you should send a bug report to the author
of the module and/or use the perlbug utility.
If you need a solution write away, then you may have to write something
yourself. Or, take a copy of the module and modify it to fix the bug
(if you know how to fix it). Then place it in your own perl lib area
(to avoid affecting other Perl programs and developers). Set up your
program to look there first so it loads your fixed version over the
bugging version. BTW, if you know how to fix the bug in a module,
sending a patch in the bug report is very helpful.
As for the "simple things" issue, I have tendency to do it myself if it
is simple, even if a module is available. Usually, it is because I am
unaware (or forgot) at the time that there is a module that can perform
the given task. Or the use of the module is unnecessary when a regular
operators will suffice. For example, I still use open() alot instead
of the filehandle module. I have never used the directory handle
module. The *dir() operators are sufficient for me.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: 24 Apr 1998 19:34:49 GMT
From: "Ron B." <ronb@schoolnotes.com>
Subject: NEED HELP GRABBING RECORDS OUT OF TEXT FILE
Message-Id: <01bd6fb8$1a93c780$356256d1@ms256735>
Hi,
I have a text file with 90,000 lines. Each line contains a 100 byte record
with fields separated with the | character. One of the fields contains
numbers and the whole file is sorted by this field in ascending order.
I would like any suggestions on how I can reach into this file and select
only those records where this certain field is equal to some specific
number.
Thank you.
Ron
------------------------------
Date: Fri, 24 Apr 1998 13:51:11 -0400
From: "John Sasso, Jr" <sassojo@sch.ge.com>
Subject: NIS calls from Perl ???
Message-Id: <3540D10F.6314@sch.ge.com>
How can one do YP (NIS) system calls from Perl (e.g. yp_all, yp_master,
yp_first, etc... - from UNIX man pages)? I've been doing them
rather half-baked by running commands such as ypcat and ypmatch from
the `` (backticks). Thanks.
--john
------------------------------
Date: Fri, 24 Apr 1998 19:14:04 GMT
From: John Porter <jdporter@min.net>
Subject: Re: NIS calls from Perl ???
Message-Id: <3540E5F8.6ABC@min.net>
John Sasso, Jr wrote:
>
> How can one do YP (NIS) system calls from Perl (e.g. yp_all, yp_master,
> yp_first, etc... - from UNIX man pages)? I've been doing them
> rather half-baked by running commands such as ypcat and ypmatch from
> the `` (backticks). Thanks.
The first thing to do when this kind of need crops up
is to check the CPAN. Did you do that? I rather think not,
or you would have seen
Net::NIS
hth,
John Porter
------------------------------
Date: Fri, 24 Apr 1998 15:21:46 -0400
From: "Jason Lorsong" <jason.lorsong@norfolkva.ncr.com>
Subject: Perl classes or training
Message-Id: <01bd6fb5$919b9c20$465c5499@vanorflorsoj.norfolkva.ncr.com>
I am looking for classes for Perl. I prefer a beginners class. I have
found many
Courses but I would like to hear some feedback on any courses anyone has
attended
and their views on the courses.
Jason
------------------------------
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 2413
**************************************