[10992] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4592 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 8 15:17:14 1999

Date: Fri, 8 Jan 99 12:00:16 -0800
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, 8 Jan 1999     Volume: 8 Number: 4592

Today's topics:
    Re: "internal server error" (John Moreno)
    Re: Gratuitous warnings when statting files with newlin <hniksic@srce.hr>
    Re: Gratuitous warnings when statting files with newlin <hniksic@srce.hr>
    Re: How do I find the path of the script calling me? <sdatta@lucent.com>
    Re: HTML::Parser documentation or examples <joe@vpop.net>
    Re: More efficient way to program this? Maybe Daemon? (M.J.T. Guy)
    Re: NT/ActivePerl/File::Copy/Network Drive/AT command = <James@newsguy.com>
    Re: Perl Criticism <mcampbel@netcom.com>
        Perl export misbehaving? riderd@my-dejanews.com
    Re: Perl uses in NT <ldrigger@olemiss.edu>
        perldoc broke? <dewitt@jlab.org>
    Re: perldoc broke? (M.J.T. Guy)
    Re: regexp and broken MY reference (M.J.T. Guy)
    Re: Sorting by 2 fields dturley@pobox.com
        Spawning a perl script from a perl script (Lyle Merdan)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 8 Jan 1999 14:58:47 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: "internal server error"
Message-Id: <1dlbgyf.16q60yx1d7my9N@roxboro0-055.dyn.interpath.net>

Tony Greenwood <paxton@cyberstrider.org> wrote:

>  
>   Hey!  phenix@interpath.com (John Moreno) 
> >Tony Greenwood <paxton@cyberstrider.org> wrote:
> >
> >> >> >Let's see.... you don't have -w, you don't have "use strict", you do
> >> >> 
> >> >> Niether do I.. what do they do ?
> >> >
> >> >Gives warning message on suspect code and enforces a stricter syntax.

-snip-

> >> >> >everything yourself instead of using modules written by people with a
> >> >> 
> >> >> Same here.. I still don't understand what a module is or how to use
> >> >> them
> >> >
> >> >"use" them and then call their functions, fairly simple.
> >> 
> >> I said I don't know how to use them.. your answer to use them is
> >> therefore a little confusing
> >
> >"use" is similar to the C #include (or at least that's good enough to
> >get you started in the right direction).
> >
> >use CGI;
> 
> How could I know ?.. I think you sort of answered me but presumed I
> would know... I didn't...thus it would obviously look like you are
> telling me to use it wouldn't it ?...can you see that ?

Sorry, that's why I put it in quotes -- to indicate that I wasn't just
saying USE them but instead to use the format "use module", I didn't at
that time know how much perl knowledge or general programming knowledge
you had.  I assumed the wrong amount.
 
> >is probably what was being referred to, in the above modules statement.
> >
> So would I have the module and upload with a cgi or would the module
> already be there as standard. This is an important bit and I would
> like more info on the subject.. if the answer is to go look it up on
> the web then that kinda negates the use of this newsgroup.. but we
> shan't get into that old chestnut eh :)

"A" CGI is a bit of a oxymoron -- cgi stands for "common gateway
interface", so what is usually meant by "a cgi" is "a script or program
that uses cgi", which I can't parse into the first sentence above.

I believe the CGI module comes with the more recent distributions, if
not it can be ftp'd from the cpan which has just about all of the
publicly available modules.

> >> >> I "think" I have the appropriate enviroment though so I am one up on
> >> >> the original poster :)
> >> >
> >> >Trying to learn perl by doing CGI programming (especially for someone
> >> >with no programming experience) is like trying to learn to ride a
> >> 
> >> I have ten years programming experience... you are having a bad day
> >> arn't you
> >
> >No, and this wasn't directed at you -- you I assumed were learning by
> >doing regular programming (and that that was what you were referring to
> >when saying that you were using the appropriate environment).
> 
> I saw environment as having my own server and having a server and perl
> on my machine at home, the ability to test out my work with ease.. ie:
> not having to ask others to test it, we both looked at that one
> differently.

Well, doing it with your own server is more like learning while on the
top of a table -- possible, but unnecessarily difficult (assuming that
"server" is referring to a web or file server and not just to possessing
a computer capable of running either).

In other words, dump the idea of doing cgi scripts until after you've
got the basics of the language down fairly well.

> >> I see humour goes right over your head...Whoooosh!
> >
> >Sometimes.
> 
> :)
> 
> 
> >> >> BTW it isn't sarcasm.. I really don't know the answers to the above..
> >> >> .
> >> >Then you need to read some more.
> 
> Is that as apposed to asking in here ?

Yes.  Perl comes with copious amounts of documentation, enough so that
someone who has any regular programming experience should be able to
learn the basics just from it.  

perlfaq7.pod has the question and answer:
How do I create a module?

A module is a package that lives in a file of the same name.  For
example, the Hello::There module would live in Hello/There.pm.  For
details, read in the perlmod manpage.  You'll also [...]

And in perlmod.pod you'd find the answer to the both the question as to
how to create a module and how to use one.

There are thousands of pages of documentation which comes with a
complete perl distribution, this is an invaluable resource, you need to
take advantage of it.

> >> I agree, I just hope I don't have to read bad mannered posts too often
> >
> >What you need to read isn't post, bad mannered or good.  What you need
> >to read is the perl documentation and maybe a book or two.
> 
> Again you must have presumed I knew.. a sweeping statement like "use"
> or "read" isn't quite going to hack it for us newbies is it.... I have
> been directed to books on the subject TBH and I am awaiting them to
> arrive.. meanwhile I have thousands of messages posted to this
> newsgroup to reference to and a good global search option in
> forte.agent... 

"use"ing a module is a pretty basic thing, not quite on the level of
"how do I set a variable to a certain value", but basic enough that you
won't find many examples of people answering the question.

-snip-

> >The sigdash is how newsreaders recognize that what follows is a sig,
> 
> My apologies... the above was sarcasm........Whoosh again :))

Sorry, I hate trimming sigs, believing that is something better done by
my newsreader, instead of eating up my time.  I don't find leaving out
the sigdash very funny.
 
> >Either you are jerking me around or you took it for an attack for some
> 
> I did take it as an attack actually and I can and do openly apologise
> most strongly as it seems that wasn't the case.. but your post held
> absolutely no answers to the questions I posted....just snippets that
> under the circumstances where easily taken the wrong way
> 
> >reason, I don't know why you'd do either.
> 
> Look at your post from the point of view of someone who knows
> nothing.. like me :)

It's hard to judge the state of someone's ignorance (or knowledge if you
prefer it always being the lesser of the two), from just one post,
without a explicit "I know nothing, /nothing/".

-- 
John Moreno


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

Date: 08 Jan 1999 19:55:31 +0100
From: Hrvoje Niksic <hniksic@srce.hr>
Subject: Re: Gratuitous warnings when statting files with newlines
Message-Id: <kigaezty4po.fsf@jagor.srce.hr>

gward@thrak.cnri.reston.va.us (Greg Ward) writes:

> Hrvoje Niksic <hniksic@srce.hr> wrote:
> > I noticed a strange thing today.  This runs without warnings:
> > 
> >     perl -we '(-d "foo")'
> > 
> > However, this prints out a warning:
> > 
> >     perl -we '(-d "foo\nbar")'
> >     --> Unsuccessful stat on filename containing newline at -e line 1.
> 
> This sure looks like a feature to me.  Note that if the directory
> named "foo\nbar" actually exists, you get no warning -- the
> "spurious" warning only happens if -d fails.  Makes sense.

Not in my application.  For me the stat checks whether the file
already exists, to avoid overwriting it.  For me the *normal* (more
frequent) case is that the stat-operator returns zero.

Warning me of that is of no use to me.  Is there a way to turn off
that specific warning?  Is there an exact list of what `-w' does?

> > Of course, I can remove `-w', but I don't want to do that -- `-w' is
> > useful and I normally want to use it.
> 
> A little-known feature is that you can temporarily turn off -w in
> sections of code known to be naughty:
[...]

I've done my homework; I know that.  The problem is that my code looks 
like this:

if (-e $new)
  {
    if (-d $new)
      {
        ... some code ...
      }
    ... some more code ...
  }

The `local $^W = 0' trick doesn't look all that nice anymore, does it?


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

Date: 08 Jan 1999 19:57:12 +0100
From: Hrvoje Niksic <hniksic@srce.hr>
Subject: Re: Gratuitous warnings when statting files with newlines
Message-Id: <kig7luxy4mv.fsf@jagor.srce.hr>

mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:

> Not quite - -w doesn't like *failing* stat-related operators.  So in
> the common case where the file exists, you don't get a warning.

For me the much more common case is that file *doesn't* exist.  It
especially stands for files with newlines in it.  Meaning that my
script spews warnings all over.

> >Of course, I can remove `-w', but I don't want to do that -- `-w' is
> >useful and I normally want to use it.
> 
> As Greg points out, you can switch it off locally.

See my response to Greg.


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

Date: Fri, 08 Jan 1999 13:10:40 -0600
From: Sujay Datta <sdatta@lucent.com>
Subject: Re: How do I find the path of the script calling me?
Message-Id: <36965830.8C78A9D3@lucent.com>

Aamer:

use File::Basename;
print STDERR dirname($0), "\n";
print STDERR basename($0), "\n";

in script B.
also check for other features in "File"
sujay datta

aazeemi@hotmail.com wrote:
> 
> Howdy All,
> 
> Pardon me if this question has been asked before.
> 
> I have two perl scripts - A and B.
> 
> Script A calls script B.  Script A lives in multiple locations.  From within
> script B, how can I find the pathname of script A which just called me?
> 
> I would appreciate a reply directly to my email address.
> 
> Thanks for you help in advance,
> Aamer Azeemi
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own


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

Date: Fri, 08 Jan 1999 19:55:06 GMT
From: "Joseph McDonald" <joe@vpop.net>
Subject: Re: HTML::Parser documentation or examples
Message-Id: <uotl2.87$pg.705744@nnrp2.ni.net>


Check out "Web Client Programming With PERL"  It's pretty good:
http://www.amazon.com/exec/obidos/ASIN/156592214X/o/qid=915825227/sr=2-1/002
-5132589-0044227

-joe

Mark A. Pitman <mpitman@phelpsdodge.com> wrote in message
news:3695552d.0@anode.phelpsd.com...
>Are there any good books, or websites with decent docs and examples of the
>HTML::Parser module?  I am trying to write a script that takes an HTML file
>and places "<B></B>" tags around all occurances of a specific word.  I can
>do that, but I am trying to use HTML:Parser to avoid placing the bold tags
>inside of other html tags.  I am not a Perl guru (obviously) so I am having
>a little trouble with the object-orientedness of this module.  Any help
>would be great!
>
>Mark
>
>




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

Date: 8 Jan 1999 19:04:31 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: More efficient way to program this? Maybe Daemon?
Message-Id: <775krv$et5$1@pegasus.csx.cam.ac.uk>

In article <775hmo$fin$1@nnrp1.dejanews.com>,  <nkaiser@my-dejanews.com> wrote:
>Yes, but the problem is that I can't afford to miss 1 minute. I sorta has to
>be like an inetd program. It should "wake-up" whenever a file is put in a
>certain directory and handle it. (which will be pretty often).

If the "wake-up" event is associated with I/O, you may be able to use
the (four argument form of) select().   See

      perldoc -f select

But I suspect that you actually need to poll the directory.   So you _have_
to execute code at regular intervals.   It's just a matter of choosing
how long you sleep() for, to get a compromise between response time for
the "wake-up" and CPU consumption.

See also the perlfaq8 entry

     =head2 How can I sleep() or alarm() for under a second?


Mike Guy


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

Date: 8 Jan 1999 10:36:54 -0800
From: James Needles <James@newsguy.com>
Subject: Re: NT/ActivePerl/File::Copy/Network Drive/AT command = unsuccessful
Message-Id: <775j86$o3o@edrn.newsguy.com>

In article <3695c836.0@145.227.194.253>, "Martin says...
>
>The other alternative is to set the network share you are accessing as a
>null share - it involves a registry edit of
>HKLM\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters\NullSessionSh
>ares. The obvious drawback is that this exposes that share to access by
>potentially anybody.
>
>HTH
>
>Martin Doxsey
>
>
>


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

Date: Fri, 8 Jan 1999 19:34:00 GMT
From: UG <mcampbel@netcom.com>
Subject: Re: Perl Criticism
Message-Id: <yzhsbtk9y2xj.fsf@netcom15.netcom.com>

topmind@technologist.com writes:

> >> What I'm saying is the leeky approch is the correct one, you may not
> like it but it is so usefull that it is neccery. <<
> 
> Correct One!????
> Show me an example of where it is so indespensable!!!

$counter = $index = $how_many_have_I_seen = 0;

-- 


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

Date: Fri, 08 Jan 1999 19:38:02 GMT
From: riderd@my-dejanews.com
Subject: Perl export misbehaving?
Message-Id: <775mqq$kgo$1@nnrp1.dejanews.com>

I was hoping someone out there could shed some light on a problem I am having.
Could you also kindly send any response to my e-mail address since I am having
problems reading newsgroups from my site.

Here's the scenario:

I have two packages:
  test1 has two functions exported from it: func1() and func3().
  test2 has one function exported from it:  func2().

func1() calls func2() and func2() calls func3() back in the test1 package.

I invoke func1() from a script called test.pl: Here's a little picture of what
is happening:

                 test1 package              test2 package
test.pl--------> func1()------------------> func2()
                                              |
                 func3()<---------------------|

Here's the output from the test script:

in test.pl
calling test1::func1
in test1::func1
calling test2::func2
in test2::func2
calling test1::func3
Undefined subroutine &test2::func3 called at /home/riderd/test2.pm line 18.

PROBLEM: test1::func3() is imported by the test2 package and exported by the
test 1 package but PERL thinks it should find it in the test2 package.  Does
anyone have a good explanation or could this be a bug?

Please see files below if you would like to recreate this problem.

    thanks,
       dave (riderd@immunex.com)

#### FILE: test.pl
#!/usr/local/bin/perl

use test1 qw(func1 func3);

print "in test.pl\n";
print "calling test1::func1\n";
func1();
exit(0);

#### FILE: test1.pm
package test1;

use strict;

use vars qw(@ISA @EXPORT_OK);
use test2 qw(func2);

require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(func1 func3);

######################################################################
sub func1
        {
        print "in test1::func1\n";
        print "calling test2::func2\n";
        func2();
        }

######################################################################
sub func3
        {
        print "in test1::func3\n";
        }

1;

#### FILE: test2.pm
package test2;

use strict;

use vars qw(@ISA @EXPORT_OK);
use test1 qw(func1 func3);

require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(func2);

######################################################################
sub func2
        {
        print "in test2::func2\n";
        print "calling test1::func3\n";
        func3();
        }

1;

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 08 Jan 1999 12:40:48 -0600
From: Les <ldrigger@olemiss.edu>
Subject: Re: Perl uses in NT
Message-Id: <36965130.99395AC5@olemiss.edu>

Alain Martineau wrote:

> I think he's asking why he should read it. How Perl would help his NT
> administration tasks. I wonder.

My mistake. I got that book mixed up in my head with Oreilly's
Windows NT User Administration which gives examples on modifying
the registry, managing ACL's, along with other user management tasks.


> I use Perl for CGIs on an NT web server, but could I use it  for system
> administration as I can on Unix ?

I am a newbie to the *nix world but I'm already heavily dependent on some
of the many command line tools available there, such as grep for one. I
don't
understand why M$ doesn't provide better tools. They are essential for
getting
things done. On the other hand, with the net commands, the NT Resource Kit
tools, and Perl of course, a lot can be accomplished.


> And I keep hearing that not all APIs required to administer
> are published by Microsoft.

They probably aren't.


> Can you for instance write a program to
> create/modify/delete users using public information?

Definitely. IMHO the perl modules Win32::NetAdmin and Win32::AdminMisc
are indispensable for NT user mgmt.


Les Driggers



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

Date: Fri, 08 Jan 1999 13:51:25 -0500
From: Shane Dewitt <dewitt@jlab.org>
Subject: perldoc broke?
Message-Id: <369653AD.44DF@jlab.org>

i see alot of references to this magical thing called perldoc so itried
it out myself by typing:

perldoc perldoc

and the answer is: Illegal variable name. is my perldoc broke or
something or am i missing something?

im using:
 152 >perl -v

This is perl, version 5.003 with EMBED
        built under hpux at May  6 1997 13:57:44
        + 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.

on hpux 9.xx


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

Date: 8 Jan 1999 19:12:14 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: perldoc broke?
Message-Id: <775lae$f95$1@pegasus.csx.cam.ac.uk>

In article <369653AD.44DF@jlab.org>, Shane Dewitt  <dewitt@jlab.org> wrote:
>i see alot of references to this magical thing called perldoc so itried
>it out myself by typing:
>
>perldoc perldoc
>
>and the answer is: Illegal variable name. is my perldoc broke or
>something or am i missing something?

perldoc works for me under perl5.003:

% perl5.003/bin/perldoc perldoc



PERLDOC(1)     User Contributed Perl Documentation     PERLDOC(1)



NAME
     perldoc - Look up Perl documentation in pod format.

  [snip]

Are sure you have perldoc in your PATH?   It should be in the same
directory as the perl binary itself.

Otherwise, it looks like you have a mis-installed Perl.   But you'll need
to give us more information to diagnose that.

And perl5.003 is rather long in the tooth now, and has CERT advisories
against it.    You'd be better off installing an up-to-date Perl.


Mike Guy


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

Date: 8 Jan 1999 18:56:09 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: regexp and broken MY reference
Message-Id: <775kc9$enf$1@pegasus.csx.cam.ac.uk>

Marty Landman  <marty@catnmoose.com> wrote:
>FOA thanks for previous replies pointing me to the Perl FAQ for symbolic
>substitution in a regexp.  This has lead me to another misunderstanding
>I'd appreciate clearing up.  Here's my  code:
>
> open (Signon,"$Signon") || die "cannot open  sign-on file $!\n";
> my $HTML;
> $HTML .= $_ while <Signon>;
> no strict;
> $HTML =~ s/\$(\w+)/${$1}/g;
> use strict;

Since 'use strict' is lexically scoped, I'd prefer to write the last
three lines as

  { no strict;
    $HTML =~ s/\$(\w+)/${$1}/g;
  };

>--    I found that use strict gave compile errors so I turned it off for
>the substitution.  Is this proper thinking?

Not according to the Use Strict Thought Police.   (But you don't _have_
to listen to them.)    As a general point, symbolic references are
a Bad Thing.    Mark-Jason Dominus explains what disasters can befall in

    http://www.plover.com/~mjd/perl/varvarname.html

>The main reason I'm posting though is that originally I had the '$1'
>vble declared as local, i.e. if I'm looking to substitute  the value of
>$japh into the text where it says $japh, i'd coded
>
>my $japh = 'just another perl hacker';
>
>This didn't work, but you already knew that.  So I 'fixed' it if that's
>the right word by adding $japh to my 'use vars' quoted word list instead
>of having it as a 'my' vble declared in the subroutine.
>
>What am I missing here?  How can I do this better, and not have a global
>variable which could otherwise happily exist as local?

Rather than having your values to be substituted as separate variables,
say $thing, put them in a (lexically scoped) hash, say as $subst{thing}.

So your substitution would become

   $HTML =~ s/\$(\w+)/$subst{$1}/g;


Mike Guy


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

Date: Fri, 08 Jan 1999 18:52:36 GMT
From: dturley@pobox.com
Subject: Re: Sorting by 2 fields
Message-Id: <775k5i$htf$1@nnrp1.dejanews.com>

In article <3695668B.E345C4C2@webteacher.com>,
  Robert Young <rob@webteacher.com> wrote:
> Hi;
>
> I went to the FAQs, and I found a very brief example of how to do this,
> but I don't understand how to apply it.

This might help:
Joseph Hall has a generic sort function that allows you to sort by various
columns. You can pick the columns, the separtor, numeric or ascii sort.

It is at http://www.effectiveperl.com/recipes/sorting.html

at the bottom.

I keep it in my script "library" for any sorting I need to do.

____________________________________
David Turley
dturley@pobox.com
http://www.binary.net/dturley/

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 08 Jan 1999 19:50:08 GMT
From: lyle@visi.com (Lyle Merdan)
Subject: Spawning a perl script from a perl script
Message-Id: <Qjtl2.3319$TO5.82562@ptah.visi.com>

Is there a better way to call another perl script, with aruments,
from within my script than using "system" or "``" ?

I can set $ARGV[] and use "do" , but are there any tricks?

Lyle Merdan


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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