[6686] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 311 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 16 01:18:16 1997

Date: Tue, 15 Apr 97 22:00:23 -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, 15 Apr 1997     Volume: 8 Number: 311

Today's topics:
     Re: "Dummies" book any good? <critter@quack.kfu.com>
     Re: DBM Obsolete? <rob@netcentral.net.no.spam>
     DNS reverse lookup - gethostbyaddr() (Roland)
     Re: formatting large numbers (Gary Chambers)
     Re: Get a week number from a file <critter@quack.kfu.com>
     Re: how to use a system-installed Perl w/locally downlo (Eric D. Friedman)
     Re: how to use a system-installed Perl w/locally downlo (Terrence M. Brannon)
     Re: how to use a system-installed Perl w/locally downlo (Terrence M. Brannon)
     Re: Ousterhout and Tcl lost the plot with latest paper (Paul Wilson)
     Re: Ousterhout and Tcl lost the plot with latest paper (Richard A. O'Keefe)
     Re: Passing How Do I Send Parseable values via the Comm (Tad McClellan)
     Perl and recursion (Amol Kabe)
     Re: Perl parsing <critter@quack.kfu.com>
     Re: Q: Uniq'ing a list (Tad McClellan)
     Re: Reply to Ousterhout's reply (was Re: Ousterhout and <graham.matthews@maths.anu.edu.au>
     Re: Reply to Ousterhout's reply (was Re: Ousterhout and (Paul Wilson)
     Re: Reply to Ousterhout's reply (was Re: Ousterhout and (Richard A. O'Keefe)
     system(); problem <bartolonem@med.ge.not.com>
     Re: Unix and ease of use  (WAS: Who makes more ...) (jason olmsted)
     Re: Unix and ease of use  (WAS: Who makes more ...) (Ell)
     Re: What does "UNIX" stand for.. <dhmassie@erols.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 15 Apr 1997 20:20:44 -0700
From: "Charles F. Ritter" <critter@quack.kfu.com>
Subject: Re: "Dummies" book any good?
Message-Id: <3354458C.562EE27B@quack.kfu.com>

Tom Christiansen wrote:
> 
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc,
>     Terry Michaels <74331.3261@CompuServe.COM> writes:
> :I found the first edition of Programming Perl too difficult
> :for a beginner in Perl.
> 
> Have you looked at the second edition?
> 
> Nonetheless, attempting to learn Perl from its reference
> work may be similar to learning English with only a dictionary.
> 
> --tom
> --
>         Tom Christiansen        tchrist@jhereg.perl.com
> 
>             Finally, which rhymes with enough --
>             Though, through, plough, or dough, or cough?

The camel book is twice as interesting the second time through and ten
times as interesting on the third read.

Come to think of it... so is the dictionary. :-)
-- 
Charles Ritter

Microsoft NT - when they are finally finished it will be the best
documented unix operating system on the market.


------------------------------

Date: Tue, 15 Apr 1997 07:59:30 -0500
From: Rob Huffstedtler <rob@netcentral.net.no.spam>
Subject: Re: DBM Obsolete?
Message-Id: <33537BB2.4AF688F1@netcentral.net.no.spam>


You may not have the NDBM package for one reason or another.  I would
try one of the others, like GDBM, which is available at sunsite.unc.edu,
or BSD-DB (I really like this one, but they are changing the license, so
if you are going to use it for a commercial product, it may not be the
best choice for you).  It's available at 
mongoose.bostic.com/db/,  the latest version is 2.02, but it's quite
conceivable that you have a prior version already on your system.  for
reference, check chapter 7 of the blue camel or your various man pages.


Parillo wrote:
> 
> My Perl Doc in HTML format appears to say the DBM is obsolete, and
> has been replaced with tie and untie. However the example in the doc:
>     # print out history file offsets
>          tie(%HIST, NDBM_File, '/usr/lib/news/history', 1, 0);
>          while (($key,$val) = each %HIST) {
>              print $key, ' = ', unpack('L',$val), "\n";
>          }
>          untie(%HIST);
> does not seem to work for me (I think it may be realted to NDBM_File),
> while DBM still seems to work.
> 
> Any advice?


------------------------------

Date: Wed, 16 Apr 1997 02:17:59 GMT
From: roland@virtual.ch (Roland)
Subject: DNS reverse lookup - gethostbyaddr()
Message-Id: <3357306a.35070298@news.active.ch>

I'am trying desperatly to convert a IP-Address to the corresponding
hostname with a perl-script...
All my experiments with gethostbyaddr() just returning a empty string
and I cannot find any examples of how to do, where can I find some
information about ?

Thanks for any Hints !
Roland Schneider


------------------------------

Date: 16 Apr 1997 02:58:57 GMT
From: geecee@burbot.netquarters.net (Gary Chambers)
Subject: Re: formatting large numbers
Message-Id: <slrn5l8g3q.1bj.geecee@burbot.netquarters.net>

David...

>If I have a price say over 999 , e.g.
>1000.87 or 1345.65 or 5467.00 how do I format so - 
>1,000.87 1,345.65 and 5,467.00 .

Some time ago, I was kindly given a Perl hints file by someone, and I,
regretfully, don't remember his name.  Here's a solution to your
problem:

sub commify {
    local($_) = shift;
    1 while s/^(-?\d+)(\d{3})/$1,$2/;
    return $_;
}

I hope this helps...

-- 
GeeCee/NQ

// ---------------------------------
// Gary Chambers
// NetQuarters, Incorporated
// geecee@netquarters.net
// ---------------------------------



------------------------------

Date: Tue, 15 Apr 1997 20:12:31 -0700
From: "Charles F. Ritter" <critter@quack.kfu.com>
Subject: Re: Get a week number from a file
Message-Id: <3354439F.4D37C858@quack.kfu.com>

Steffen Beyer wrote:
> 
> Petr Prikryl <prikryl@dcse.fee.vutbr.cz> wrote:
> > Nathan V. Patwardhan (nvp@shore.net) wrote:
> > >John Jiang (jiangj@bnr.ca) wrote:
> 
> > >:    How can I get a week number of the time when a file is
> > >: created. The week number would be something like what we got from
> > >: shell "date -u +%W". Thanks.
> 
> > >You can't get the creation date of a file, but you can get last-modified,
> > >date, etc., which are explained in perlfunc.pod in the section dealing
> > >with stat().
> 
> > ...and then you can convert using localtime(). You will obtain also the
> > day in the week as 0..6 number and the day in the year. You have to calculate
> > week number yourself (probably some package does this).
> 
> The module "Date::DateCalc" does it, for instance.
> 

But if modules scare you and your on a unix machine you could iterate
over the array returned by the system "cal" command. "cal" returns this:

     April 1997
Su Mo Tu We Th Fr Sa 
       1  2  3  4  5
 6  7  8  9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30

#!/usr/bin/perl -w

open(CAL,"cal |") or die "Your not using unix are you?\n";

$your_date = 4;

while(<CAL>) {

$your_week_is = $. - 2;

    print "$your_week_is\n" if /$your_date/;
}

or something along these lines (You need to be more careful with the
match criteria).

-- 
Charles Ritter

Microsoft NT - when they are finally finished it will be the best
documented unix operating system on the market.


------------------------------

Date: 16 Apr 1997 02:16:56 GMT
From: friedman@medusa.acs.uci.edu (Eric D. Friedman)
Subject: Re: how to use a system-installed Perl w/locally downloaded modules
Message-Id: <5j1cqo$e4b@news.service.uci.edu>

[mailed, posted]

In article <ysizbu7fvrec.fsf@bufo.usc.edu>,
Terrence M. Brannon <brannon@bufo.usc.edu> wrote:
>
>I am not superuser, yet I wish to use the system-installed Perl with
>modules I get from CPAN and store in my lcal directory? Is there some
>way to set this up?
>
>This would be a good FAQ.

Agreed, I propose the following:

=head2 How do I install modules that aren't part of the standard distribution?

If you have write privileges for your copy of perl, the following steps
are generally all that's required:

       perl Makefile.PL # optionally "perl Makefile.PL verbose"
       make
       make test        # optionally set TEST_VERBOSE=1
       make install     

Users without sufficient privileges to install modules for the entire
system can install personal copies of any module by changing the first
line above to something like this:

       perl Makefile.PL PREFIX=~/perllib # perllib is just an example;
                                         # name it whatever you want

Note that scripts which use modules installed with this second method
will need to explicitly include them in @INC:

       use lib '/path/to/my/perllib';

Some modules (LWP, for example) perform install time tests to see if
you already have other modules on your system.  In the event that 
you've installed those other modules in a private `perllib' (or whatever
you're calling it), you'll need to include the appropriate use lib
directives in Makefile.PL or set the environment variable PERL5LIB
to point to your `perllib.'

HTH,
Eric
-- 
Eric D. Friedman
friedman@uci.edu


------------------------------

Date: 15 Apr 1997 20:37:52 -0700
From: brannon@bufo.usc.edu (Terrence M. Brannon)
Subject: Re: how to use a system-installed Perl w/locally downloaded modules
Message-Id: <ysiz912jvdsa.fsf@bufo.usc.edu>

friedman@medusa.acs.uci.edu (Eric D. Friedman) writes:

> 
>        use lib '/path/to/my/perllib';
this part failed

brannon@sand /felix/terry/scripts/perl : gzip -dc Data-Flow-0.04.tar.gz | tar xvf -
blocksize = 40
x Data-Flow-0.04/
x Data-Flow-0.04/Changes, 175 bytes, 1 tape blocks
x Data-Flow-0.04/Flow.pm, 6979 bytes, 14 tape blocks
x Data-Flow-0.04/Makefile.PL, 233 bytes, 1 tape blocks
x Data-Flow-0.04/MANIFEST, 45 bytes, 1 tape blocks
x Data-Flow-0.04/test.pl, 2126 bytes, 5 tape blocks
brannon@sand /felix/terry/scripts/perl : cd Data-Flow-0.04
brannon@sand /felix/terry/scripts/perl/Data-Flow-0.04 : perl Makefile.PL PREFIX=~/perllib
Checking if your kit is complete...
Looks good
Writing Makefile for Data::Flow
brannon@sand /felix/terry/scripts/perl/Data-Flow-0.04 : make
cp Flow.pm ./blib/lib/Data/Flow.pm
AutoSplitting Data::Flow (./blib/lib/auto/Data/Flow)
Manifying ./blib/man3/Data::Flow.3
brannon@sand /felix/terry/scripts/perl/Data-Flow-0.04 : make install
Installing /export/freeway/brannon/perllib/lib/site_perl/./Data/Flow.pm
Installing /export/freeway/brannon/perllib/lib/site_perl/./auto/Data/Flow/autosplit.ix
Installing /export/freeway/brannon/perllib/man/man3/./Data::Flow.3
Writing /export/freeway/brannon/perllib/lib/site_perl/alpha-dec_osf/auto/Data/Flow/.packlist
/bin/sh: /export/freeway/brannon/perllib/lib/alpha-dec_osf/5.003/perllocal.pod: cannot create
make: *** [doc_site_install] Error 1
brannon@sand /felix/terry/scripts/perl/Data-Flow-0.04 : perl -v

This is perl, version 5.003 with EMBED
        built under dec_osf at Apr 16 1997 20:24:47
        + suidperl security patch

Copyright 1987-1996, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.

brannon@sand /felix/terry/scripts/perl/Data-Flow-0.04 : perl -de 42
Stack dump during die enabled outside of evals.

Loading DB routines from perl5db.pl patch level 0.94
Emacs support available.

Enter h or `h h' for help.

main::(-e:1):   42
  DB<1> use Data::Flow '/export/freeway/brannon/perllib'
Can't locate Data/Flow.pm in @INC at (eval 4) line 2, <IN> chunk 1.
BEGIN failed--compilation aborted at (eval 4) line 2, <IN> chunk 1.

  DB<2> use Data::Flow '/export/freeway/brannon'
Can't locate Data/Flow.pm in @INC at (eval 6) line 2, <IN> chunk 2.
BEGIN failed--compilation aborted at (eval 6) line 2, <IN> chunk 2.

  DB<3> use Data::Flow '/export/freeway/brannon/perllib/lib/site_perl'
Can't locate Data/Flow.pm in @INC at (eval 8) line 2, <IN> chunk 3.
BEGIN failed--compilation aborted at (eval 8) line 2, <IN> chunk 3.

  DB<4> print join ("\n",@INC)
/felix/terry/install/perl/lib/alpha-dec_osf/5.003
/felix/terry/install/perl/lib
/felix/terry/install/perl/lib/site_perl/alpha-dec_osf
/felix/terry/install/perl/lib/site_perl
 .
  DB<5> 



-- 
o============o  Sending  unsolicited commercial e-mail (UCE) to this address
 Legal Notice   is indication of your consent to pay me $120/hour for 1 hour
o============o  minimum for professional proofreading & technical assessment.
terrence brannon * brannon@kappa.usc.edu * http://rana.usc.edu:8376/~brannon


------------------------------

Date: 15 Apr 1997 20:39:15 -0700
From: brannon@bufo.usc.edu (Terrence M. Brannon)
Subject: Re: how to use a system-installed Perl w/locally downloaded modules
Message-Id: <ysiz7mi3vdpe.fsf@bufo.usc.edu>

friedman@medusa.acs.uci.edu (Eric D. Friedman) writes:

> 
>        use lib '/path/to/my/perllib';

but it works to the default directory:


brannon@sand /felix/terry/scripts/perl/Data-Flow-0.04 : perl Makefile.PL 
Writing Makefile for Data::Flow
brannon@sand /felix/terry/scripts/perl/Data-Flow-0.04 : make install
Manifying ./blib/man3/Data::Flow.3
Installing /felix/terry/install/perl/lib/site_perl/./Data/Flow.pm
Installing /felix/terry/install/perl/lib/site_perl/./auto/Data/Flow/autosplit.ix
Installing /felix/terry/install/perl/man/man3/./Data::Flow.3
Writing /felix/terry/install/perl/lib/site_perl/alpha-dec_osf/auto/Data/Flow/.packlist
Appending installation info to /felix/terry/install/perl/lib/alpha-dec_osf/5.003/perllocal.pod
brannon@sand /felix/terry/scripts/perl/Data-Flow-0.04 : perl -de 42
Stack dump during die enabled outside of evals.

Loading DB routines from perl5db.pl patch level 0.94
Emacs support available.

Enter h or `h h' for help.

main::(-e:1):   42
  DB<1> use Data::Flow

  DB<2> brannon@sand /felix/terry/scripts/perl/Data-Flow-0.04 : 


-- 
o============o  Sending  unsolicited commercial e-mail (UCE) to this address
 Legal Notice   is indication of your consent to pay me $120/hour for 1 hour
o============o  minimum for professional proofreading & technical assessment.
terrence brannon * brannon@kappa.usc.edu * http://rana.usc.edu:8376/~brannon


------------------------------

Date: 15 Apr 1997 22:50:57 -0500
From: wilson@cs.utexas.edu (Paul Wilson)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <5j1ib1$kp3@roar.cs.utexas.edu>

In article <5j12ue$9ib@srv13s4.cas.org>,  <lvirden@cas.org> wrote:
>
>According to Alexey Goldin   <a-l-e-x-e-y@o-d-d-j-o-b.u-c-h-i-c-a-g-o.e-d-u>:
>
>:Have you tried SIOD? CLISP?
>
>I know that I've not tried either of these.  In fact, I've never
>seen an app that embedded either of these.  however, I've seen
>several hundred that embedded Tcl - including the latest version of
>nvi.  Since I prefer to use apps that share the same embedded language
>when possible, use of tcl works for me at this time.

Larry,

   This seems like the only reasonable argument that people have raised
and one I have some grudging respect for.

   I haven't seen much in the way of defenses of Tcl per se as a language,
but people like Tk and Expect, and like the fact that Tcl is embeddable
and has a simple (albeit crude) foreign function call interface.  None
of these are things that can't be done with much better languages---even
small ones.  (And they'll generally run 30-1000 times faster than
Tcl, so you can write most of your app in a friendly interactive
language, if you want to, without much performance loss relative to C.)

   Ousterhout has declined to defend his argument that a scripting
language should not be a reasonable language for general-purpose programming.
Everyone else seems to think it would be nice, including many Tcl users
who write whole apps, or most of their apps, in Tcl.

   Ousterhout's argument that Tcl's terseness is due to deep facts
about the language design (string representation of code, dynamic 
typing) seems to have been rebutted with no counter-rebuttals.

   Several other questions have arisen that Ousterhout has ignored.

   In all of this, it seems that the Ousterhout has opted out of
serious discussion, and interestingly, few Tcl fans have defended
Tcl in these areas.  The main defense seems to be that "I use it
already, and other people use it already, so we're going to stick
with it and recommended it to others, whether or not it's fundamentally
lame."  (Sorry to put it in such an extreme way, but that's pretty much
how I see it.)

   My impression is that Sun made a similar marketing-based decision, 
killing several very interesting and worthwhile language project, just
keeping Java (which isn't horrible) and Tcl.  They had more market share
or mind share than, say, Self.  (The orphaning of Self was really sad.)

   (BTW, I don't generally buy the "right tool for the job" argument
about the proliferation of languages.  There may be no single language
that's perfect for everything, but I think we need to focus on a 
few that have fairly broad applicability.  Some languages are simply 
more powerful than others, and often simpler, easier to use, and
faster than weaker languages.  You can have a fairly small and powerful
toolkit, instead of a proliferation of weak and uselessly different tools.)

   One semi-reasonable argument is that Tcl is a handy language for
writing 1- to 20-line scripts.  But most people seem to think you
need extra discipline and/or kludged-up abstraction facilities such 
as [incr tcl] to get very far beyond that.  And the advantage seems
to go away if you're not familiar with the UNIX shell programming
paradigm.  (Most programmers are not, because they don't use UNIX,
and many UNIX programmers have never learned to script competently
because UNIX shell languages are unnecessarily arbitrary and inscrutable.)

   In the Tcl group I've seen postings that say things like "I tend to
lose it around 1000 to 2000 lines" and "heck, I lose around 500 lines".
This seems really relevant because Tcl may have advantages for UNIX
shell hackers writing 5-or-10 line one-offs.  It seems that most
programming effort goes in to programs one to three decimal orders
of magniture larger.

   There was a posting in this thread to the effect that "I wrote my
whole app in Tcl and it was great---all I had to do was go out
and get a much faster processor."  I think many people would consider
that a failure for Tcl, because in just about any other language it would
probably have run at least 10x faster, and been just fine on the original
machine.

   So the bottom line is that Ousterhout seems to have bailed, and 
other Tcl fans don't seem to be defending Tcl against several serious 
technical criticisms.  Is that because they don't have good answers
(except for market-share arguments), or just that they lost interest
in the flamewar?

   In case it's not clear, I'm not saying that everybody should just
drop Tcl right now in favor of (say) Smalltalk or Scheme or Gofer
or Python or Perl.  I do wonder whether Tcl is too weak to have
good prosects in has a chance in the longer run.  Many of its advantages
for UNIX, X, and C are greatly reduced on Windows or the Mac and Java.

   I think Tcl will be mainly a niche language, with much less appeal
outside its own turf---and serious competition in home games, too---and 
I think it's reasonable to consider switching to a language with better 
long-term prospects which isn't as popular right now, because we don't
want to get trapped in a dead end.

-- 
| Paul R. Wilson, Comp. Sci. Dept., U of Texas @ Austin (wilson@cs.utexas.edu)
| Papers on memory allocators, garbage collection, memory hierarchies,
| persistence and  Scheme interpreters and compilers available via ftp from 
| ftp.cs.utexas.edu, in pub/garbage (or http://www.cs.utexas.edu/users/wilson/)      


------------------------------

Date: 15 Apr 1997 17:33:35 +1000
From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <5ivb0f$ch$1@goanna.cs.rmit.edu.au>


Bryan Oakley <oakley@healthcare.com> writes:
>To me, the biggest drawback in embedding lisp in a commercial
>product is that list pretty much requires a text editor that knows a
>little about lisp syntax.

Ok, hands up all the people who *can't* get
 - a free vi clone (stevie, vim, vile)
 - a free Emacs lookalike (jove, top, emacs)
 - a programmer's editor such as "alpha" (which ironically uses tcl)
All the DOS, Windows, OS/2, UNIX, and VMS users have their hands down.

The editor I use knows
 - how to move forward over an S-expression
 - how to move into the next S-expression
 - how to move backwards over an S-exression
 - how to copy/cut S-expressions
 - how to switch S-expressions
 - how to autoindent to the same column as the previous line
   (the autoindent function copies leading comment symbols too)
 - how to put matching brackets around the next/previous N S-expressions
 - how to highlight the matching left bracket when a right bracket of
   any type is entered.

The total cost is 5030 characters of C *source code*.
Not lines:  characters.
And all of these things are also used (with the appropriate syntax
table) when editing C or Fortran or Pascal or Ada or Java or HTML
(treat <> as brackets; it helps a lot).  This editor does _not_ know
how to pretty-print Lisp.  I've written a fair bit of Lisp code with
it without any trouble.  This isn't rocket science!  Even vi can do
a lot of these things, and the newer vi clones can do quite a bit.

Here's the punch-line:  TCL has all those nested curly braces.
Can you seriously imagine editing TCL with an editor that doesn't
know about TCL quotation marks and curly braces?  Well, the editor
I use _can_ handle these things, and the code it handles them _with_
*IS* the code it uses for Lisp!
 - move forward over a "string" or {block}
 - move into the next {block}
 - move backward over a "string" or {block}
 - copy/cut a "string" or {block}
 - switch strings/block
 - autoindent
 - put matching braces around things to make a block
 - highlight the matching { when a } is entered
You need the *same* things for editing TCL that you do for editing Lisp.
It is a very tiny matter of programming to write one set of code that
handles both, simply by switching a small syntax table (I know because
I've done it).  Those 5030 characters of C are just as useful/necessary
for TCL as they are for Lisp.

So where is the advantage of TCL over Lisp?
Not in the editor, that's for certain sure!
-- 
Will maintain COBOL for money.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.


------------------------------

Date: Tue, 15 Apr 1997 20:10:21 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Passing How Do I Send Parseable values via the Command Line
Message-Id: <tt81j5.qkv.ln@localhost>

Richard Schlief (richard.schlief@telops.gte.com) wrote:
: Whenever I write pl scripts I always have the HTML form already
: developed.  I have a need where I will have the script before the HTML
: form and I need to be able to pass the standard HTML STDIN info on the
                                     ^^^^^^^^^^^^^^^^^^^^^^^
: command line.  What is the syntax for that?


That format is described as part of the Common Gateway Interface
(aka CGI).

This, however, is not the CGI newsgroup!

I think you will have better luck getting answers to CGI questions
in a newsgroup that has some connection to the CGI.

c.l.p.m is not such a newsgroup.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


------------------------------

Date: Wed, 16 Apr 1997 02:09:06 GMT
From: kabe@netcom.com (Amol Kabe)
Subject: Perl and recursion
Message-Id: <kabeE8pKn7.7nD@netcom.com>
Keywords: scope recursion perl



I seem to be having problems with scope when I try to do a recursive call
to a perl function.  Could someone please explain why I get the following
error 

Use of uninitialized value at ./listaliases line 15.
Use of uninitialized value at ./listaliases line 15.


	I am running the following configuration 
This is perl, version 5.003 with EMBED
        built under solaris at Dec 27 1996 14:07:40
        + suidperl security patch


	Here is the script that I am trying to run.  What I am trying to do
is to write something that will print out all the aliases and who is on
them.  As a next step I wan to be able to print out all the aliases that a 
particular user is on.

******************   begin script **************************


#!/usr/local/bin/perl -w 

$debug = 3;

sub check_aliases {


    my (%aliases, $alias, $members) = @_; 
    my ($new_members,$member);


    if ( $debug == 3) {

	print STDERR "\n\n IN FUNCTION check_aliases \n";
	print STDERR "ALIAS - $alias   MEMBERS - $members ";
	print STDERR "\n\n";
	print STDERR "Checking\n";

    }



    foreach $member (sort split(/:/,$members) ){


	if ( $debug == 3 ) {
	    print STDERR "In the loop for $member";
	}

	if ( $aliases{$member} ) {

	    if ( $aliases{$member} == $alias ) {

		next;

	    }

	    $new_members .= check_aliases(%aliases,$member, 
						$aliases{$member});
	    $new_members .= ":";

	}
	else {

	    $new_members .= $member;
	    $new_members .= ":";

	    if ( $debug == 2 ) {
		print STDERR "\nAdding $member";
	    }

	}

    }


    if ( $debug == 2 ) {
	print "\nReturning $new_members\n";
    }
    return $new_members;

}


open (ALIASES,"/bin/ypcat -k aliases|");


while (<ALIASES>) {

    chop;

    ($alias,$members) = split(/\s+/m,$_,2);

    $members =~ s/,/:/g;


    $aliases{$alias} = $members;


    if ($debug == 1) {

	print STDERR "\n\n";
	print STDERR "Alias : $alias";
	print STDERR "\n";
	print STDERR "Members : $members";
	print STDERR "\n";

    }


}

close (ALIASES);

if ( $debug == 2 ) {

    foreach $alias ( sort keys (%aliases) )  {

	$debug_members = $aliases{$alias};
	print STDERR "\n";
	print STDERR "Alias $alias, Members $debug_members";
	print STDERR "\nSplitting $alias\n";

	foreach $member ( sort split(/:/,$debug_members) ) {

	   print STDERR "${member} :";

	}


    }

}

foreach $alias (sort keys (%aliases) ) {

   $test_members = "";
   $members = $aliases{$alias};

   if ( $debug ==3 ) {
       
       print "\n\n For alias $alias members are $members \n";

    }

   $test_members .= check_aliases(%aliases, $alias, $members);

   if ( $debug == 3 )  {

       print "OLD - $alias contains $members \n";
       print "NEW - $alias contains $test_members\n";

    }


}



******************   end script   **************************


-- 

	Amol Kabe  		-oO0Oo-			kabe@netcom.com     
	         "we can speak of an object as a blessed thingy." 
			Programming Perl, 2nd ed. 


------------------------------

Date: Tue, 15 Apr 1997 19:57:08 -0700
From: "Charles F. Ritter" <critter@quack.kfu.com>
Subject: Re: Perl parsing
Message-Id: <33544004.49B40D57@quack.kfu.com>

Jayne Meiners wrote:
> 
> If I am looking for one character out of a string.
> It doesn't matter if it is in the beginning, middle,
> or end.
> All I want to know is if it exists, what is the parsing
> sequence I need.
> 
> This is the form I would like to have it:
> 
> if (<that_x_character_exists>) {
> 
>  print "<that_x_character_exists>";
> 
> }
> 

This should work:

if ($string =~ /<that_x_character_exists>/) {

    print "<that_x_character_exists>\n";
}

or: 

print "<that_x_character_exists>\n" if ( $string =~
/<that_x_character_exists>/ );

or:

print "<that_x_character_exists>\n" if /<that_x_character_exists>/;

 ...but only if your matching $_.

What is $_ you ask?

-- 
Charles Ritter

Microsoft NT - when they are finally finished it will be the best
documented unix operating system on the market.


------------------------------

Date: Tue, 15 Apr 1997 20:18:00 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Q: Uniq'ing a list
Message-Id: <8c91j5.snv.ln@localhost>

Andreas Steffan (deas@rrz.uni-hamburg.de) wrote:

: Would someone please be so kind and tell me how to uniq a list
: in perl without using the UNIX 'uniq' command ?
                                  ^^^^


Duh. 

Try doing a grep for 'uniq' in the perl FAQ:


faq.4:=head2 How can I extract just the unique elements of an array?
faq.4:simulating uniq(1)'s behavior of removing only adjacent
faq.4:each element is unique in a given array:
faq.4:=head2 How can I get the unique keys from two hashes?
faq.4:the uniquifying the array problem described above.  For example:
faq.4:    @uniq = keys %seen;
faq.4:    @uniq = keys %{{%foo,%bar}};
faq.4:    @uniq = keys %seen;


See anything that looks familiar in there?

Sheesh!



: PS: Please also reply via email.

I don't do that for Frequently Asked Questions.

That is why the Frequently Asked Questions list was developed.

You are expected to check it BEFORE posting here!
                             ^^^^^^^^^^^^^^

Have some manners man!


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


------------------------------

Date: Wed, 16 Apr 1997 13:00:33 +1000
From: Graham Matthews <graham.matthews@maths.anu.edu.au>
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <335440D1.5762@maths.anu.edu.au>

Graham Matthews (graham.matthews@maths.anu.edu.au) wrote:
> || Ok thats fair enough, but for me it raises another question, a question
> || that goes to the heart of why people think JO's article is just
> || advertising hype. Why did JO chose to represent everything as a string?
> || Why not everything as a number. Why not everything as a list? The latter
Charles Lin wrote:
>     If one had to choose a single type for everything, a string is a
> pretty good choice.   Why not a number?  How would you represent a
> string with a number?   You can represent a number with a string.
> Just put quotes around it. 

Oh come on -- if you have a a finite alphabet then there is a bijection
between
the natural numbers and strings over that finite alphabet. For example
if you N
symbols in your alphabet, A ..., then AA is represented by N+1.

graham
-- 
                       I was gonna be your Romeo
                      You were gonna be my Juliet
                  These days you don't wait on Romeos
                    You wait on that welfare cheque


------------------------------

Date: 15 Apr 1997 23:07:09 -0500
From: wilson@cs.utexas.edu (Paul Wilson)
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <5j1j9d$kq9@roar.cs.utexas.edu>

In article <335440D1.5762@maths.anu.edu.au>,
Graham Matthews  <graham.matthews@maths.anu.edu.au> wrote:
>Charles Lin wrote:
>>     If one had to choose a single type for everything, a string is a
>> pretty good choice.   Why not a number?  How would you represent a
>> string with a number?   You can represent a number with a string.
>> Just put quotes around it. 
>
>Oh come on -- if you have a a finite alphabet then there is a bijection
>between the natural numbers and strings over that finite alphabet. For 
>example if you N symbols in your alphabet, A ..., then AA is represented 
>by N+1.

This is, of course, a long-established and deep theoretical result,
but I think for these purposes it's pretty much irrelevant, or trivially
true of most existing implementations already, depending on how you look
at it.

The real issue is not whether you can create a correspondence between
the natural numbers and anything you want, but whether you can do it
efficiently.  It's just easier to use pointer-linked data structure
representations than to maintain such a mapping to the naturals in any 
obvious and direct way.

Of course, most languages do maintain a mapping from language-level
objects such as strings and records---a string or record value is
represented as a pointer to the string or record, and that pointer
is represented as something like a virtual address (an integer offset
from the beginning of the address space), maybe tagged or whatever at 
the implementation level, and usually abstracted into an "object reference"
at the language level, rather than being exposed as a raw address.

-- 
| Paul R. Wilson, Comp. Sci. Dept., U of Texas @ Austin (wilson@cs.utexas.edu)
| Papers on memory allocators, garbage collection, memory hierarchies,
| persistence and  Scheme interpreters and compilers available via ftp from 
| ftp.cs.utexas.edu, in pub/garbage (or http://www.cs.utexas.edu/users/wilson/)      


------------------------------

Date: 15 Apr 1997 17:55:13 +1000
From: ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe)
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <5ivc91$3vu$1@goanna.cs.rmit.edu.au>


Douglas Seay <seay@absyss.fr> writes:
>I'll agree that they aren't ivory tower languages, and that the language
>specification may have been created hand-in-hand with the tool, but I
>don't see how that makes them less of "languages".  This m ight be
>ancient history, but was there a formal specification of COBOL, FORTRAN
>or APL before the first implementation?]

COBOL	- yes.  (COBOL was "designed by committee".)
Fortran	- I _think_ the answer is 'yes'.
APL	- most certainly!  Iverson's book preceded the implementation.

Well, the specifications may not be up to _today's_ formal specifications,
but they were as formal as anything around at the time except perhaps
McCarthy's papers.

>PS - The syntax of perl5 is actually simplier than perl4.  The thing
>that got bigger was the libraries.  But since it is no longer "cute", I
>couldn't expect you to keep up with it.

The syntax may be simpler, but the manuals got a whole lot bigger, and
some of the perl4 code I had bought stopped working.

-- 
Will maintain COBOL for money.
Richard A. O'Keefe; http://www.cs.rmit.edu.au/%7Eok; RMIT Comp.Sci.


------------------------------

Date: Mon, 14 Apr 1997 16:22:16 -0500
From: Mike Bartolone 5-4266 <bartolonem@med.ge.not.com>
Subject: system(); problem
Message-Id: <3352A008.41C6@med.ge.not.com>

I've been fighting with a perl script for over a month now. The
script compiles and runs just fine. When the script runs, it makes a
system(); call like this:

system("$ENV{'EXEHOME'}/program $params");

program $params produces an output file. It works just fine if I make
that call from the command line. I have checked and EXEHOME is in the
environment like it needs to me, along with a few other ENV vars.

For a long time we didn't know why we were getting no data in our
output file. Today, in some fine print, though, I discovered this
in the Programming PERL book, under 'system':

Note that argument processing varies depending on the number of
arguments, as described for exec.

I checked under exec and found this:

If there is more than one argument in LIST, or if LIST is an array with
more than one value, the function calls C's execvp(3) routine with the
arguments in LIST. If there is only one scalar argument, the argument is
checked for shell metacharacters. If there are any, the entire argument
is passed to "/bin/sh -c" for parsing. If there are none, the argument
is split into words and passed directly to execvp(3) in the interest of
efficiency.

So, I looked at my code again. The whole thing is in double quotes, so,
for the system call, it looks like one argument..it has shell meta's
(the $ in $params), so the whole thing is passed to "/bin/sh -c" for
parsing. I tried this by calling program like this:

/bin/sh -c program $params

(Yes, I set $params). This fails. I then typed this:

program $params

that seems to work just fine!

In place of the system call, I have tried the following commands:

`$ENV{'EXEHOME'}/program $params`
system('/usr/3p/bin/program $params');


and various other combinations of single quotes, double quotes, back
quotes, no quotes. I cannot get it to work!

So, does anyone know how to get my external program to run from within
my perl script?


-- 
                            | Man is without a doubt the most
                            | interesting fool there is.  Also the
bartolonem@med.ge.com       | most eccentric. He hasn't a single
         or                 | written law, in his Bible or out of it,
bartolon@execpc.com         | which has any but just one purpose and
                            | intention -- to limit or defeat a law
                            | of God.                     Mark Twain


------------------------------

Date: 16 Apr 1997 03:51:30 GMT
From: olmstj@phat-media.com (jason olmsted)
Subject: Re: Unix and ease of use  (WAS: Who makes more ...)
Message-Id: <5j1ic2$d0$5@news.gte.net>

On 15 Apr 1997 19:02:40 GMT, "Tim Behrendsen" <tim@a-sis.com> wrote:

>
>Jettero Heller <heller@nacs.net> wrote in article <5j06j7$hoh@tracy.nacs.net>...
>> Tim Behrendsen (tim@a-sis.com) wrote:
>> : I don't accept excuses for my employees, I don't accept excuses
>> : for myself, and I don't accept them for Larry Wall.  There is no
>> : excuse for code without comments.  Period.
>> 
>> Oh yes there is. If the code is written for the author only (as is
>> the case with perl) then he/she *does not* need to comment didly!
>> Don't try to push *your* personal coding beliefs on other people.
>> If you can't accept other peoples coding styles, then don't look at
>> their code! Larry Wall, Brian Kernighan, or myself *DO NOT* answer
>> to you in regards to our code, so basically we don't care what you
>> want us to do!
>
>I hope this was a joke.
>
>If not, whether you answer to me or not is irrelevent.  Of course
>you can do whatever you want with your code.  That doesn't change
>the fact that uncommented code released publically for a significantly
>complex program is shamefully bad engineering.
>
>And I'm not claiming perfection, either.  I have made many style
>changes over the years when I've noticed that others didn't seem to
>be able to follow what I was doing well.  I didn't whine and whimper
>and get defensive about it.  Being a good engineer means evolving
>through experience, and screaming "Wahh!  Don't criticize my code!"
>does not do much for self-improvement.
>

I know of instances when code was released without comment into the
public domain as it was meant to complement a book.  If you bought the
book, you got the commentary of what was happening, otherwise you were
free to use the code, but fend for yourself.

My point is that just because code is released without comments does
not mean that it doesn't exist somewhere else with it.  For the
majority of instances, the intened audience of comments is yourself.
Are you going to know what the hell your were thinking two years ago
or even two months ago?  As continue to program, one would hope that
our skills would improve and that we would grow - thus causing us to
look back and wonder, "what was I thinking, this looks really
backassed?".

If you think you don't need to comment - great, I just hope you got it
right the first time and never encounter a bug or a need to improve
upon yourself.

jason olmsted
olmstj@phat-media.com
http://www.phat-media.com/olm


------------------------------

Date: 16 Apr 1997 04:02:28 GMT
From: ell@access5.digex.net (Ell)
Subject: Re: Unix and ease of use  (WAS: Who makes more ...)
Message-Id: <5j1j0k$cad@news3.digex.net>

jason olmsted (olmstj@phat-media.com) wrote:
:
: My point is that just because code is released without comments does
: not mean that it doesn't exist somewhere else with it.  For the
: majority of instances, the intened audience of comments is yourself.
: Are you going to know what the hell your were thinking two years ago
: or even two months ago?

Isn't that part of the reason for comments, so that you can recall what
sections of code are about?

Elliott


------------------------------

Date: Tue, 15 Apr 1997 22:41:58 -0500
From: dave massie <dhmassie@erols.com>
Subject: Re: What does "UNIX" stand for..
Message-Id: <33544A86.6F10F221@erols.com>


unix is a pun.  the developers (ritche, et. al.) had been working on a 
dod project building an operating system called multix.

they were thinking they wanted to build a smaller operating system for
their own use.  so, if it was smaller than multix, it must be unix.

UNIx, get it?

Al Christians wrote:
> 
> If you don't stand for something, you'll stand for anything.
> 
> Al


------------------------------

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 311
*************************************

home help back first fref pref prev next nref lref last post