[8955] in Perl-Users-Digest
Perl-Users Digest, Issue: 2572 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 12 19:10:04 1998
Date: Tue, 12 May 98 16:00:50 -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, 12 May 1998 Volume: 8 Number: 2572
Today's topics:
Re: A bug in localtime() <spp@ds.net>
Re: ambiguous use resolved ? <rootbeer@teleport.com>
CPAN.pm: install failing; problem with gzip? blah_oicu812@yahoo.com
Re: Does Perl have a IDE?I don't like command line. (Greg Bacon)
Re: Does Perl have a IDE?I don't like command line. (Greg Bacon)
Re: Does Perl have a IDE?I don't like command line. (Michael J Gebis)
Re: Does Perl have a IDE?I don't like command line. <tchrist@mox.perl.com>
Re: Does Perl have a IDE?I don't like command line. (Ilya Zakharevich)
Re: Does Perl have a IDE?I don't like command line. (Ilya Zakharevich)
Re: Does Perl have a IDE?I don't like command line. (Stuart McDow)
Re: Does Perl have a IDE?I don't like command line. <ljz@asfast.com>
Re: Does Perl have a IDE?I don't like command line. (Kevin Reid)
Re: Does Perl have a IDE?I don't like command line. <tchrist@mox.perl.com>
Re: Does Perl have a IDE?I don't like command line. <tchrist@mox.perl.com>
Re: Does Perl have a IDE?I don't like command line. (Stuart McDow)
Re: formats of arbitrary length ? <tchrist@mox.perl.com>
Re: Friday-night Problem, Week 20 ... :) (Tad McClellan)
Re: Grieving our dying community <birgitt@order.booktraders.com>
IPC::Open3 mem leak mayank@ibm.net
Re: Is if ($a="something") a bad style? <coryj@**NOSPAM**i-check.net>
Re: Is if ($a="something") a bad style? <rootbeer@teleport.com>
Re: Is if ($a="something") a bad style? <upsetter@shore.net>
Re: Is if ($a="something") a bad style? <yong@shell.com>
Re: Is if ($a="something") a bad style? (Mark-Jason Dominus)
Re: Is if ($a="something") a bad style? <lr@hpl.hp.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 12 May 1998 14:40:06 -0400
From: Stephen P Potter <spp@ds.net>
To: Alex Dong Li <ali@genet.sickkids.on.ca>
Subject: Re: A bug in localtime()
Message-Id: <35589786.4A65FF52@ds.net>
Alex Dong Li wrote:
> Secondly, yes, I got 4 for May. I am just curious: if 0 is for January, but
> why not 0 for the first day of a month too? Why the second day is 2?, not
> offset to 1?
Perl implements localtime() and such as calls to the underlying C
routine.
The C routine is based on a structure that defines some things (such as
month)
as "since" (months since January, hence January is 0), and other things
(day) as
"of the" (day of the month, 1-31). This is mostly because of arrays
(and enums)
being 0 based in C, and things like month often being used in a list
context for
conversion purposes ($month[0] = Jan ... $month[11] = Dec). You'll note
that
days are rarely used in such a context.
-spp
------------------------------
Date: Tue, 12 May 1998 21:00:09 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Phil R Lawrence <prl2@lehigh.edu>
Subject: Re: ambiguous use resolved ?
Message-Id: <Pine.GSO.3.96.980512135918.21974S-100000@user2.teleport.com>
On Tue, 12 May 1998, Phil R Lawrence wrote:
> I received an error:
> Ambiguous use of {params} resolved to {"params"} at blah blah...
I think you can get that only if there's a sub or built-in with that name.
Do you have a sub ¶ms, by chance? Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 12 May 1998 22:20:00 GMT
From: blah_oicu812@yahoo.com
Subject: CPAN.pm: install failing; problem with gzip?
Message-Id: <6jahuf$92c$1@nnrp1.dejanews.com>
Perl V5.004_02
Windows NT 4.0
I have RTFM
I seem to be having a problem with CPAN.pm, but it's probably related more to
gzip than the module (judging by the error message). Below is what I get when
trying to install a module:
cpan> install MARKM/Text-Soundex-2.12.tar.gz
Running make for MARKM/Text-Soundex-2.12.tar.gz
Fetching with LWP:
ftp://ftp.archive.de.uu.net/pub/programming/languages/perl/CPAN/authors/id/MAR
KM/Text-Soundex-2.12.tar.gz
CPAN: MD5 loaded ok
Fetching with LWP:
ftp://ftp.archive.de.uu.net/pub/programming/languages/perl/CPAN/authors/id/MAR
KM/CHECKSUMS
Checksum for P:\.cpan\sources\authors\id\MARKM\Text-Soundex-2.12.tar.gz ok
gzip: stdout: Invalid argument
taperead: 6 The handle is invalid.
Set tape Position: Tape API returned 6 The handle is invalid.
tapeclose: Error rewinding the tape
gzip: stdout: Broken pipe
Can't spawn "cmd.exe": No such file or directory
Package comes without Makefile.PL.
Writing one on our own (calling it MARKM/Text-Soundex-2.12.tar.gz)
had problems unarchiving. Please build manually
Running make test
Make had some problems, maybe interrupted? Won't test
Running make install
Make had some problems, maybe interrupted? Won't install
__END__OF__OUTPUT__
In case it has to do with the CPAN configuration file, I've included it here:
# This is CPAN.pm's systemwide configuration file. This file provides
# defaults for users, and the values can be changed in a per-user
# configuration file. The user-config file is being looked for as
# ~/.cpan/CPAN/MyConfig.pm.
$CPAN::Config = {
'build_cache' => q[10],
'build_dir' => q[p:\.cpan\build\.],
'cpan_home' => q[p:\.cpan\.],
'ftp' => q[C:\WINNT\system32\ftp],
'ftp_proxy' => q[],
'getcwd' => q[cwd],
'gzip' => q[c:\perl\bin\gzip.exe],
'http_proxy' => q[],
'inactivity_timeout' => q[0],
'index_expire' => q[1],
'inhibit_startup_message' => q[0],
'keep_source_where' => q[p:\.cpan\sources\.],
'lynx' => q[],
'make' => q[c:\perl\bin\dmake.exe],
'make_arg' => q[],
'make_install_arg' => q[],
'makepl_arg' => q[],
'ncftp' => q[],
'no_proxy' => q[],
'pager' => q[more],
'shell' => q[cmd.exe],
'tar' => q[c:\perl\bin\tar.exe],
'unzip' => q[o:\pkzip\pkunzip.exe],
'urllist' => [q
[ftp://ftp.archive.de.uu.net/pub/programming/languages/perl/CPAN/]],
'wait_list' => [q[wait://ls6.informatik.uni-dortmund.de:1404]],
};
1;
__END__
There is no user configuration file. Both gzip and tar exist where the config
says they do.
I hope I've included all the information someone may need.
Anybody got a clue?
Thanks in advance.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 12 May 1998 20:54:25 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jacu1$65p$5@info.uah.edu>
In article <3559b854.1174735@news.tornado.be>,
bart.mediamind@tornado.be (Bart Lateur) writes:
: Greg Bacon wrote:
: >Programming languages aren't and should never be everyday things.
:
: Oops. I program everyday.
Everyone's not a programmer.
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: 12 May 1998 20:53:03 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jacrf$65p$4@info.uah.edu>
Please be careful with your quoting. You incorrectly attributed much of
the quoted content of that article.
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: 12 May 1998 21:01:01 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jadad$65k@mozo.cc.purdue.edu>
gbacon@cs.uah.edu (Greg Bacon) writes:
}In article <6j9vhj$8v@mozo.cc.purdue.edu>,
} gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
}: Nope, I wouldn't have put it in quotes if I had meant that. I mean
}: that that some people just don't think "I need help, thus I
}: should go the the command line, or a separate program, or whatever."
}What's not to understand? You request the manual page on a subject, the
}program finds it, formats it, and displays it. Tuits are far too
}precious to waste on trying to cater to such a low denominator.
Let me put put forth an example: When I have the honor to work on a Windows
machine, and I want to change a configuration detail, my first thought
is "Pull up vi and edit the config file." Unfortunately, this is not
the Windows way. I get frustrated, while a Win-head goes "Pull up
regedit, go to HKEY_UBERFROZ_BACKWASH and edit the value for
MustCrash."
It makes perfect sense for someone used to that system, but to a
programmer used to the Unix Way, it seems incredibly backwards. My
point is, many programmers are used to an IDE, and the command line
just doesn't click with them. Sure, they get it eventually, but not
until after wasting bandwidth.
}: }Programming languages aren't and should never be everyday things.
}:
}: That's a very witty but content-free response.
}The fact of the matter is that despite what some would have you believe,
}programming is an art that requires years of training and practice to
}master. Would you allow an untrained surgeon to perform an invasive
}procedure on you? Scalpels aren't and should never be everyday things.
}It just doesn't make any sense to refer to a programming language as an
}everyday thing.
Help me, I'm in hell. I'm saying "A Perl IDE with a clever help
system might increase the percentage of folks who read the
documentation." I refered to an excellent book about design, and
pointed out that a flood of questions might indicate that the help
system might not be optimal. I never claimed the language should
change, or be dumbed-down, in any way.
Programming languages are not an everyday thing, but help systems
should be. Perldoc is an oddity for non-unix programmers. They can
understand it, but it clashes, and will continue to be ignored
forever.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: 12 May 1998 21:14:10 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jae32$red$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
:Programming languages are not an everyday thing, but help systems
:should be. Perldoc is an oddity for non-unix programmers. They can
:understand it, but it clashes, and will continue to be ignored
:forever.
Then so too shall they.
--tom
--
Like Dennis' love note about rk05s, early Berkeley tapes cane with a
suggestion from Bill Joy that "this is a tape of bits," meaning there was no
guarantee of anything, and that complaints should be directed to /dev/null.
--Andy Tannenbaum, "Politics of UNIX," Washington, DC USENIX Conference, 1984
------------------------------
Date: 12 May 1998 21:57:16 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jagjs$1lu$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Greg Bacon
<gbacon@cs.uah.edu>],
who wrote in article <6ja7si$65p$3@info.uah.edu>:
> In article <6ja1lg$5ab$1@mathserv.mps.ohio-state.edu>,
> ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> : Yes, when I'm on Solaris, I'm forced to use some broken way like
> : pfind'ing (grep is absolutely useless unless you know how deep you
> : need to search) if I need to lookup DOCs.
>
> What do you have against man -k or apropos? I guess you've missed
> tcgrep which has been posted to clpm at least twice and is also
> available on the CPAN. I can also mail you a copy if you'd like. It's
> written entirely in Perl and has an option for descending recursively
> into directories (plus other niceties).
All these are just solutions to problems *which should not have
arised* in the first place (like implementing an elaborate ingenious
copy-on-write scheme which 99.99% of time is used to avoid overheads
of fork/exec).
Note that after writing pfind I have almost no need for specialized
tools, like "your" tcgrep is. You get a warm fuzzy feeling of Perl
syntax together with concise syntax of specialized tools. But it
still a PITA to go overboard (type pfind command line to find all the
relevant pages, then start perldoc/man to access them) just to read
docs.
Here is the scoop: if you are a talanted programmer, and are not
afraid of the PITA, then you may find whatever you want in Perl docs.
I do not think such a situation is acceptable. It may be unavoidable
on inferior systems - this is why I use pfind+perldoc on Solaris.
(But note that there is no such situation in the port of Perl I
maintain.)
Hope this helps,
Ilya
------------------------------
Date: 12 May 1998 22:05:39 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jah3j$2cp$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 <6ja9g8$j68$1@csnews.cs.colorado.edu>:
> I recommend using things like find+grep, or tcgrep, or linux man with its
> -K flag, or my man with -g or its lqtext support, or agrep with errors,
> or gnu grep with -C, etc. Then of course there's glimpse, which is
> hard to fault. The possibilities are limited only by the imagination
> of the programmer.
Yes, to read Perl documentation you need *first* to get fluent with
a) perldoc
b) linux man with its -K flag
c) agrep or tcgrep
d) glimpse
(and I think any 3 of these are not enough). Get real.
> You're a programmer, Ilya. I don't understand what your problem is.
I have no problem. I'm absolutely cool about the fact that on *nix
you cannot make most frequently needed things easily. I can do them
anyway, and am able to endure the associated PITA.
We are not discussing me. You are discussing the *fact* that Perl
documentation *cannot be made* easily available on *nishish systems.
Why discuss this fact? No discussion will fix it.
I do not know... Hhad anybody tried the CDE help system, is it
possible to cook something usable out of it? It does not look pretty,
but I did not investigate how much you can do inside the books.
Ilya
------------------------------
Date: 12 May 1998 22:08:57 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jah9p$5r2$1@ns1.arlut.utexas.edu>
Birgitt Funk <birgitt@order.booktraders.com> writes:
> Stuart McDow wrote:
> >
> > Well, sure it is. And so is C, sh, awk, sed, BASIC, FORTRAN, Lisp,
> > etc.
> >
>
> So, which language is then left for the new generation of incoming
> programming students ?
C, sh, awk, sed, BASIC, FORTRAN, Lisp, C++, etc.
There is no one language that makes is easier to learn programming
concepts. Different languages are good at doing different things,
handling different paradigms. But basic programming concepts are basic
programming concepts. If one hasn't got a grasp of them, it doesn't
matter what language is used.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"Look for beauty in roughness, unpolishedness"
------------------------------
Date: 12 May 1998 18:11:29 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <ltsomf2l7y.fsf@asfast.com>
gbacon@cs.uah.edu (Greg Bacon) writes:
> In article <ltemy048jl.fsf@asfast.com>,
> Lloyd Zusman <ljz@asfast.com> writes:
> : [ ... ]
>
> : (3) I have given this kind of technical help to people for over
> : 20 years and I have never had even one of these people become
> : dependent on my help or to develop some sort of "the world
> : owes me a living" attitude. [ ... ]
>
> I'm railing against the people who already have the ``handouts,
> please?'' attitude.
I find that this group of people is an extremely small minority of
those who ask for technical help. You may have had other experiences,
however, and hence, YMMV.
> : As for why I am not categorically opposed to a Perl IDE:
> :
> : (1) I truly believe that most people who would want to use an
> : IDE would not use it instead of man, perldoc, or grep, but
> : rather, in conjunction with these tools.
>
> Why? We're not trapped on DOS machines these days. Keep two xterms
> open; one for hacking, one for man and grep.
Some people still prefer IDE's. It's not for you or me to decide what
is most desirable for others.
> : (2) Even though I personally do not generally use IDE's, I know
> : a lot of people who are more productive using such things
> : to help develop code.
>
> It's all a matter of what you're used to. Perl was fathered by a Unix
> hacker, after all. Had Larry been a Microsoft weenie, Perl would
> probably be full of wizards and menus and general protection faults.
Instead, it's full of auto-configuration scripts, smart download tools
(CPAN.pm), several hundred details-hiding modules, and other things
that make life easier for Perl users. If someone wanted to write an
IDE, it would be just one more tool to add to this list.
> : (3) It is quite possible for a person to use an IDE and still learn
> : the language in question to the same level of proficience and
> : compentency as those people who shun IDE's.
>
> Crutches are best used only in the case of injury. I don't know of
> anyone who advocates learning to walk using crutches.
What criteria do you use to label an IDE "crutches", but not things
like the auto-configuration script or the hundreds of modules in CPAN?
> : [ ... ]
> :
> : The language need not change one iota simply due to someone's choice
> : of writing an IDE. IDE's did not water down C++. IDE's did not water
> : down Smalltalk. IDE's did not water down APL. IDE's did not water
> : down Java.
>
> I'd rather the tuits of the capable few be spent on improving the
> language itself and not in creating crutches to attract even more FAQ
> askers.
Then would you be in favor of no one ever writing another CPAN module,
and instead, spending the effort on improving the language even more?
This way, everyone could use the resulting language improvements to
write and rewrite their own socket modules, math routines, parsers,
etc. in "raw Perl" without having to use all those crutches that
people have contributed to the module archives.
I know that my last statement was a bit facetious, but I think you see
my point ... even if you might disagree. Again, I reiterate my
earlier question: what criteria do you use to label an IDE "crutches",
but not things like the auto-configuration script or the hundreds of
modules in CPAN?
--
Lloyd Zusman ljz@asfast.com
perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'
------------------------------
Date: Tue, 12 May 1998 18:14:43 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <1d8x2gu.3rk9j8qogqvwN@slip166-72-108-6.ny.us.ibm.net>
Greg Bacon <gbacon@cs.uah.edu> wrote:
> In article <1d8vlqy.e1xil01v1oakcN@slip-32-100-246-98.ny.us.ibm.net>,
> kpreid@ibm.net (Kevin Reid) writes:
> : However, it would be nice if either:
> : 1. The Jump To... item, when no text is selected, would bring up a
> : dialog box asking for a line number to jump to, OR
> : 2. The editor window optionally showed line numbers.
>
> Hmm.. vi solves both problems:
>
> 1. ESC:<line>
> or
> ESC<line>g
> or
> /regex
>
> 2. ESC:set number
Yes, I use it - _when I am using a UNIX system_. When I use a Macintosh,
I use MacPerl. And I would like this functionality in MacPerl.
--
Kevin Reid. | Macintosh.
"I'm me." | Think different.
------------------------------
Date: 12 May 1998 22:18:16 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jahr8$3d2$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:
:You are discussing the *fact* that Perl
:documentation *cannot be made* easily available on *nishish systems.
:Why discuss this fact? No discussion will fix it.
/*
* "...we will have peace, when you and all your works have perished--and
* the works of your dark master to whom you would deliver us. You are a
* liar, Saruman, and a corrupter of men's hearts." --Theoden
*/
Ilya, you are absolutely, irrevocably full of it. I do not accept your
premise, and thus your conclusion is irrelevant. Why must you continue
to spread these horrid lies? The documentation is easy to find and
use and navigate, and those for whom it is not should not be here.
*PLONK*
--tom
--
OOPS! You naughty creature! You didn't run Configure with sh!
I will attempt to remedy the situation by running sh for you...
--Larry Wall in Configure from the perl distribution
------------------------------
Date: 12 May 1998 22:19:58 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jahue$3d2$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
kpreid@ibm.net (Kevin Reid) writes:
:Yes, I use it - _when I am using a UNIX system_. When I use a Macintosh,
:I use MacPerl. And I would like this functionality in MacPerl.
Why are you holding others responsible for your choice of a
tool-challenged system?
--tom
--
Von Neumann: "Anyone attempting to generate random numbers by
deterministic means is, of course, living in a state of sin."
------------------------------
Date: 12 May 1998 22:15:11 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jahlf$6qk$1@ns1.arlut.utexas.edu>
I hate to quote myself, but I forgot something.
smcdow@arlut.utexas.edu (Stuart McDow) writes:
>
> But basic programming concepts are basic programming concepts. If
> one hasn't got a grasp of them, it doesn't matter what language is
> used.
And, if one *does* have a grasp of basic programming concepts, it
doesn't matter what language is used. (For the most part, that
is. Some languages make doing certian things very difficult.)
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
"Look for beauty in roughness, unpolishedness"
------------------------------
Date: 12 May 1998 22:22:31 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: formats of arbitrary length ?
Message-Id: <6jai37$3d2$4@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
wimmel@sgihalle10.informatik.tu-muenchen.de (Guido Wimmel) writes:
:I'm writing a PERL script which generates Java
:Code, and I'm using PERL Formats to specify
:code templates, and a control program that
:provides the code templates with data.
Seems to be you should probably be using printf instead,
or maybe the Text::Template module. Formats are for fixed width
things.
That said, you are welcome to regard the following.
--tom
#!/usr/bin/perl
#
# tgent -- retrieve a termcap entry, formatted for
# this window size, or the -w width if given
# read from /etc/termcap, or -f file, or stdin if isn't_atty
# tchrist@perl.com 9/17/93
############################################
# CONFIGURATION SECTION
$DEF_WIDTH = 80;
$DEF_FILE = '/etc/termcap';
#############################################
main: {
&parse_args;
&getwinsz;
&open_input;
&run_filter;
&gen_format;
&find_entries;
exit;
}
#############################################
sub usage {
die "usage: $0 [-f tcapfile] [-w width] entry ...\n";
}
#############################################
sub parse_args {
require 'getopts.pl';
&Getopts("df:w:") || &usage;
&usage unless @ARGV;
@wanted{@ARGV} = (1) x @ARGV;
}
#############################################
sub getwinsz {
$cols = 0;
if ($opt_w) {
$cols = $opt_w;
return;
}
if (-t STDOUT) {
($rows, $cols) = split(' ', `stty size`);
# still might be 0?
}
$cols = $DEF_WIDTH unless $cols;
}
#############################################
sub open_input {
$FILE = do {
if ($opt_f) { $opt_f }
elsif (-f STDIN) { "<&STDIN" }
else { $DEF_FILE }
};
open (FILE) || die "can't open $FILE: $!";
}
#############################################
sub gen_format {
$cols -= 3;
$format = "format STDOUT = \n";
$format .= '^' . '<' x $cols . "\n";
$format .= '$entry' . "\n";
$format .= "\t^" . "<" x ($cols-8) . "~~\n";
$format .= '$entry' . "\n";
$format .= ".\n";
print STDERR $format if $opt_d;
eval $format;
die "bad format:\n$format\n$@" if $@;
$: = ":";
}
#############################################
sub find_entries {
LINE: while (<FILE>) {
next LINE if /^#/;
chop;
if ( /\\$/ ) {
chop;
$_ .= <FILE>;
redo LINE;
}
s/:\s*:/:/g;
$entry = $_;
NAME: for (split(/\|/, (split(/:/,$_,2))[0])) {
if ($wanted{$_}) {
write;
next LINE;
}
} # for name
} # while line
}
#############################################
sub run_filter {
if ($pid = open(CHILD, "|-")) {
open(STDOUT, ">&CHILD") || die "can't dup child to stdout: $!";
$| = 1;
return;
}
die "can't fork: $!" unless defined $pid;
$| = 1; $\ = "\n";
$saveline = '';
while (<STDIN>) {
chop;
s/\s+$//;
s/^\t([^:])/\t:$1/;
print /^\S/ ? $saveline : "$saveline\\" if $saveline;
$saveline = $_;
}
print $saveline if $saveline;
exit;
}
--
When I was a boy I was told that anybody could become President. Now
I'm beginning to believe it.
--Clarence Darrow
------------------------------
Date: Tue, 12 May 1998 15:04:37 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Friday-night Problem, Week 20 ... :)
Message-Id: <l0aaj6.5cd.ln@localhost>
Tina Marie Holmboe (tina@scandinaviaonline.se) wrote:
: die("Unable to [$Command], $!\n") if ( ! open(PTR, "$Command|") ) ;
: However: snippet #2 showed an uncharacteristic ability to actually never
: die. This was the source of much annoyment until a certain small light
: started flashing. More experienced Perl'ers will, now, start guffaw'in.
The rawest of newbies is also guffaw'in if they are conscientious
enough to have had a look at the Perl FAQs...
;-)
from perlfaq8:
"Why doesn't open() return an error when a pipe open fails?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 12 May 1998 17:33:53 -0400
From: Birgitt Funk <birgitt@order.booktraders.com>
Subject: Re: Grieving our dying community
Message-Id: <3558C041.CAAD465E@order.booktraders.com>
Nathan V. Patwardhan wrote:
[snip]
>
> : You should not forget that we can't go to school to learn Perl. We are
>
> You're kidding, right?
I don't think so. In the whole Washington D.C. metropolitan area
there is not one university who teaches Perl in their curriculum or
uses Linux for teaching unix system administration, shell programming,
network administration etc. Why ?
And hasn't it been said over and over again that programming is
a skill you learn for years by doing and not in a three-day course
costing some thousand dollars ? (Given, these are U.S. conditions
and they may be unique in the world).
The same people, who complain about that they don't want to teach for
free, should work constructively to teach and being paid for it in a way
which responds to the demand and the nature of how it needs to be
taught. It has to be affordable. It's not done.
> There
> Actually, I'd rather just discuss Perl or applications written in
> Perl. Way back when, people argued *about* code but didn't ask for
> handouts, because they did their homework. About two years ago, this
> place became a helpdesk -- just about overnight.
>
So, why don't you change it to a school with low cost tuition to
teach programming using the Perl language ? The demand is so
obviously there.
> Then again, I don't know when people starting viewing Usenet as this
> alternative to tutelage or formal education, but I believe that most
> of the people who are around this group NEVER came here to teach for
> *free*.
And I believe that most people who are pointed to this Usenet group
and who are not old timers, never expected to be taught for *free*.
They may have been pushed or forced to ask for a quicky solution.
They might not even like it.
Birgitt Funk
------------------------------
Date: Tue, 12 May 1998 22:48:16 GMT
From: mayank@ibm.net
Subject: IPC::Open3 mem leak
Message-Id: <6jajjh$ckf$1@nnrp1.dejanews.com>
Hi,
Either I'm missing something, or I've come upon a memory leak in
IPC::Open3.
I have a small script called open3_test that essentially loops over a call to
open3 in the package IPC::Open3. Since it needs something to open, I wrote a
small script called prog that does a bit of printing and exits. Both scripts
are included below.
The size in memory of open3_test increases steadily during execution. This is
with perl5.003 on a DEC, perl5.004_63 on a DEC, and perl5.003 on Solaris
(haven't tried anything else yet). Either I'm neglecting to clear some
resource (though I consulted my camel book, the IPC::Open3 docs, and the
perlipc man page), or something is going on internally.
FYI - when I remove the open3 call and replace it with a series of steps that
send the STDOUT and STDERR of 'prog' to files, followed by opening read file
handles to those files, there is no increase in the size in memory.
Aside -- There's a real application of this; this is just my test case. In
the real application, there is a significant speed loss as the process loops
over input data. Also, we do use select/sysread to avoid blocking, as the
docs suggest.
I appreciate any and all help and/or flames (I don't mind being called
clueless if I'm given a clue at the same time!).
-Mayank Thanawala
mayank@ibm.net
open3_test
-----------------------------------------
#!/usr/local/bin/perl5
use IPC::Open3;
while (1)
{
open3(\*WTR, \*RDR, \*ERR, "prog");
print WTR "Hello\n";
print "WRITER fileno: ", fileno(WTR), "\n";
close WTR;
print "READER fileno: ", fileno(RDR), "\n";
print "ERROR fileno: ", fileno(ERR), "\n";
while (<RDR>) {
print "Reader: $_";
}
while (<ERR>) {
print "Error: $_";
}
close RDR;
close ERR;
system ("ps -o command,rssize,nswap -A | grep open3_test | grep -v grep");
# that works for DEC OSF v 3.2; different commands on different OS's to
# get size in memory
}
prog
--------------------------------
#!/usr/local/bin/perl5
$_ = <STDIN>;
print "STDOUT: $_\n";
warn "STDERR: $_\n";
exit 0;
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Tue, 12 May 1998 14:46:27 -0700
From: "Cory Johnson" <coryj@**NOSPAM**i-check.net>
Subject: Re: Is if ($a="something") a bad style?
Message-Id: <6jafvs$db4@sjx-ixn5.ix.netcom.com>
In perl the "=" is just an assignment operator. To validate a variable with
a string, try this:
if ($a eq "something") {... ...}
or if it's a numerical value:
if ($a == "something") {... ...}
Hope this helps
~Cory Johnson~
Yong Huang wrote in message <3558B46B.C6ED1244@shell.com>...
>In C, we often say
>if (a="something")
>But in Perl, a warning is given. I want to shorten
<SNIP>
------------------------------
Date: Tue, 12 May 1998 22:30:58 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Yong Huang <yong@shell.com>
Subject: Re: Is if ($a="something") a bad style?
Message-Id: <Pine.GSO.3.96.980512152628.21974X-100000@user2.teleport.com>
On Tue, 12 May 1998, Yong Huang wrote:
> In C, we often say
> if (a="something")
> But in Perl, a warning is given.
Yes, because you probably didn't mean to do an assignment inside of an
if-test. Generally, you type that when you meant to use an equality test.
But perl is pretty smart about that warning; it shouldn't show up from
almost any likely valid code under recent versions of perl. Are you using
an old version of perl, or are you assigning a constant? Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 12 May 1998 22:34:52 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Re: Is if ($a="something") a bad style?
Message-Id: <6jaiqc$kse@fridge.shore.net>
Yong Huang <yong@shell.com> wrote:
: In C, we often say
: if (a="something")
: But in Perl, a warning is given. I want to shorten
What warning is given? I use that syntax all the time when I want to
assign to a variable and evaluate that value in the same statement.
--Art
: $a="something"; #"something" could be &mysub which may return nothing
: if ($a) {...
: into one statement:
: if ($a="something") {...
: Is this a bad style? Thanks for advice.
: Yong
: Email:yong@shell.com
--
National Ska/Reggae Calendar: www.ziplink.net/~upsetter/ska/calendar.html
Boston Ska Home Page: www.ziplink.net/~upsetter/ska/index.html
------------------------------
Date: Tue, 12 May 1998 17:43:32 -0500
From: Yong Huang <yong@shell.com>
Subject: Re: Is if ($a="something") a bad style?
Message-Id: <3558D094.D7DDC4ED@shell.com>
Since I receive a couple of kind messages that misunderstood what I meant
(due to
my fault!), I want to clarify my point.
I want to do assignment and in the same step (at least at the programmer's
first sight), check to see if the string is null. The C style, that is,
if (!(fd=open("mydata.txt",r+)) { printf "Can't open the file "...
looks elegant and neat. That's why I want to know if this is thought of as
neat in Perl
too.
Thanks.
Yong Huang
Yong Huang wrote:
> In C, we often say
> if (a="something")
> But in Perl, a warning is given. I want to shorten
>
> $a="something"; #"something" could be &mysub which may return nothing
>
> if ($a) {...
>
> into one statement:
>
> if ($a="something") {...
>
> Is this a bad style? Thanks for advice.
>
> Yong
> Email:yong@shell.com
------------------------------
Date: 12 May 1998 18:48:14 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Is if ($a="something") a bad style?
Message-Id: <6jajje$bvv$1@monet.op.net>
In article <3558B46B.C6ED1244@shell.com>, Yong Huang <yong@shell.com> wrote:
>In C, we often say
>if (a="something")
>Is this a bad style?
I think it's bad style in C also. I used to write this:
if (p = malloc(...)) {
}
but I decided that it was better to write this:
if ((p = malloc(...)) != NULL) {
}
or this:
p = malloc(...);
if (p) {
}
The `=' is just too deceptive.
------------------------------
Date: Tue, 12 May 1998 15:44:28 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Is if ($a="something") a bad style?
Message-Id: <6jajc1$e72@hplntx.hpl.hp.com>
[posted and emailed]
Yong Huang wrote in message <3558B46B.C6ED1244@shell.com>...
>In C, we often say
>if (a="something")
>But in Perl, a warning is given. I want to shorten
>
>$a="something"; #"something" could be &mysub which may return
nothing
>
>if ($a) {...
>
>into one statement:
>
>if ($a="something") {...
>
>Is this a bad style? Thanks for advice.
>
>Yong
>Email:yong@shell.com
It is not bad style -- provided the operand that is assigned is a
variable. In the case you show, it is a constant, and that is what is
producing the warning.
Try
if ($a = $b) { ... }
Assign the value of $b to $a, then test for TRUE. No warning.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
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 2572
**************************************