[16615] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4027 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 15 18:10:39 2000

Date: Tue, 15 Aug 2000 15:10:26 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966377426-v9-i4027@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 15 Aug 2000     Volume: 9 Number: 4027

Today's topics:
        Net::Dns broken, gethostbyname OK <undergronk@my-deja.com>
    Re: Net::Dns broken, gethostbyname OK (Charles DeRykus)
        NNTPClient from behind a proxy/socks server <marcelo@someplace.com>
        NT, Perl, Oracle resource erins6562@my-deja.com
    Re: Perfect Place to find Perl Jobs (David H. Adler)
        Perl 5/Red Hat 6.1 h2ph problem <jbduffy@cwcom.net>
    Re: Perl ? - How to do a count? (Abigail)
    Re: Perl Jobs Galore!  Find them here. (David H. Adler)
        Perl to Lotus Notes mail sankarmukh@my-deja.com
        Please explain the following line to me... <lesbian@party.org>
    Re: Please explain the following line to me... (Logan Shaw)
    Re: Please explain the following line to me... <care227@attglobal.net>
    Re: Please explain the following line to me... <jeff@vpservices.com>
    Re: Please explain the following line to me... <care227@attglobal.net>
    Re: Please explain the following line to me... <jeff@vpservices.com>
    Re: Please explain the following line to me... <mjcarman@home.com>
    Re: Please explain the following line to me... <jeff@vpservices.com>
        Processing text from gzipped file (Otto Wyss)
    Re: Processing text from gzipped file <tony_curtis32@yahoo.com>
    Re: Processing text from gzipped file (Decklin Foster)
    Re: push (@INC <tim@ipac.caltech.edu>
        Quiting a: while (<STDIN>) (Tony L. Svanstrom)
    Re: Quiting a: while (<STDIN>) (Mike Stok)
    Re: Quiting a: while (<STDIN>) (Brandon Metcalf)
    Re: Quiting a: while (<STDIN>) <tina@streetmail.com>
    Re: Quiting a: while (<STDIN>) <ren.maddox@tivoli.com>
    Re: Quiting a: while (<STDIN>) <tim@ipac.caltech.edu>
    Re: Quiting a: while (<STDIN>) <flavell@mail.cern.ch>
        Using a subroutine from another file!!! <igorleal@dcc.ufmg.br>
    Re: Using a subroutine from another file!!! (Mike Stok)
    Re: What's the best way to overwrite a string with '*? <lauren_smith13@hotmail.com>
    Re: Where can I find Basic Perl Definitions? (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 15 Aug 2000 19:22:48 GMT
From: Scott Kirk <undergronk@my-deja.com>
Subject: Net::Dns broken, gethostbyname OK
Message-Id: <8nc59p$etm$1@nnrp1.deja.com>

I have been developing a script to check the status of local DNS
servers.  Now the script is broken, and I can't see why.

The scripts hangs, then returns a timeout error, as if no DNS server
had responded.  But nslookup returns an answer, as does gethostbyname -
so I know my resolver configuration is correct.

Here's a sample script which showns what I mean:

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

 use Net::DNS;
 use Socket;
 $res  = new Net::DNS::Resolver;
 $name = shift || die "Usage: $0 hostname\n";

 print "Attempt 1: use gethostbyname to resolve address\n";
 if ($addr = gethostbyname $name) {
         print "$name => ", inet_ntoa($addr), "\n";     }
 else {
         die "$0: no address for '$name'\n";
 }

 print "Attempt 2: use Net::DNS \n";
 $query = $res->search($name);
 if ($query) {
         foreach $rr ($query->answer) {
                 next unless $rr->type eq "A";
                 print $rr->address, "\n";
         }
 } else {
         die "query failed: ", $res->errorstring, "\n";
 }

Here's what I get when I run it:

 $ getip.pl dingo
 defined(@array) is deprecated at  //..path../Net/DNS.pm line 137.
        (Maybe you should just omit the defined()?)

 Attempt 1: use gethostbyname to resolve address
 dingo => 10.10.111.31
 Attempt 2: use Net::DNS
 query failed: Bad file number & query timed out


I am using Perl 5.6.0 under NT, using cygwin shell - though I get the
same problem on a different PC using ActivePerl.  I have tried
different internal DNS servers, too.

I am out of ideas, so any suggestions how I can diagnose this further
would be appreciated.


--
Scott Kirk
My deja.com mailbox is full of spam. Use this instead:
perl -e '$_ = "znvygb: haqretebax\@lnubb.pbz";
tr/A-Za-z/N-ZA-Mn-za-m/; print;'


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 15 Aug 2000 20:56:42 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Net::Dns broken, gethostbyname OK
Message-Id: <FzCq6I.7n0@news.boeing.com>

In article <8nc59p$etm$1@nnrp1.deja.com>,
Scott Kirk  <undergronk@my-deja.com> wrote:
>I have been developing a script to check the status of local DNS
>servers.  Now the script is broken, and I can't see why.
>
>The scripts hangs, then returns a timeout error, as if no DNS server
>had responded.  But nslookup returns an answer, as does gethostbyname -
>so I know my resolver configuration is correct.
>
>Here's a sample script which showns what I mean:
> ...

You may have more luck with the development version
according to the author:

  > Anyone having any luck using the Net::DNS module with
    ActiveState Perl
  > (Win32).  I have installed the module and try running some
    sample
   > scripts and just get timeouts.  I have Win NT 4.0.
  
  What version of Net::DNS are you using?  Some people report
  success with the current development version on the Net::DNS
  homepage:
  
  http://www.fuhr.org/~mfuhr/perldns/
  
  The development version is, well, still under development, so it
  may have other problems.


--
Charles DeRykus


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

Date: Tue, 15 Aug 2000 18:07:24 -0300
From: Marcelo <marcelo@someplace.com>
Subject: NNTPClient from behind a proxy/socks server
Message-Id: <3999B10C.3E659BB9@someplace.com>

How could I run an NNTPClien script from behind a
proxy/socks server?

Any idea or workaround?

Thanks in advanced
--
Marcelo Narvaja
---------------
echo "mnarvaja (at) geocities (dot) com" | \
sed 's/(at)/\@/' | \
sed 's/(dot)/./' | \
sed 's/ //g'

Sorry, I'm trying to avoid spamming...





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

Date: Tue, 15 Aug 2000 21:35:37 GMT
From: erins6562@my-deja.com
Subject: NT, Perl, Oracle resource
Message-Id: <8ncd39$ob5$1@nnrp1.deja.com>

Does anyone know a good resource to find out how to make my NT systems
talk to Oracle successfully with Perl????


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 15 Aug 2000 19:55:17 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Perfect Place to find Perl Jobs
Message-Id: <slrn8pj815.52i.dha@panix2.panix.com>

On Tue, 15 Aug 2000 04:20:40 GMT, Gwyn Judd <tjla@guvfybir.qlaqaf.bet>
wrote:

>No, a post about how to create a Duke Nukem clone in Perl would be
>useful information.

Personally, I think that could only go as far as "interesting", rather
than all the way to "useful".  :-)

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
For the Forth aficionados reading this column, I offer my idea of the
ideal bumper sticker:  "YOU FORTH LOVE IF HONK THEN."
 - Chip Salzenberg, in The Perl Journal #12


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

Date: Tue, 15 Aug 2000 19:48:26 +0100
From: "John Duffy" <jbduffy@cwcom.net>
Subject: Perl 5/Red Hat 6.1 h2ph problem
Message-Id: <Nigm5.7277$pR4.147457@news6-win.server.ntlworld.com>

Hi.

Firstly, apologies if this is not to the most appropriate news group. The
problem is a Red Hat 6.1 and/or Perl 5 problem, but I don't know which.

I want to use the standard library module Sys::Syslog.

A test script I have written consists solely of:

    #!/usr/bin/perl -w

    use strict;
    use Sys::Syslog;

    my $PROG = "syslog-test.pl";

    openlog($PROG, 'pid', 'user');
    syslog('info',  'this is a test');
    closelog();

The problem is that the script fails with the message:

    undefined __need___va_list at line 9 of stdarg.ph

I have run 'h2ph', which appears to have completed without error, as per
Programming Perl and the man page:

    cd /usr/include
    h2ph -r -l .

Any help or pointers to the problem, Perl/Linux, would be greatly
appreciated.

Regards

John Duffy
jbduffy@cwcom.net






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

Date: 15 Aug 2000 20:25:56 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Perl ? - How to do a count?
Message-Id: <slrn8pj9pi.tj3.abigail@alexandra.foad.org>

Louis (louis@aol.com) wrote on MMDXLI September MCMXCIII in
<URL:news:20000815105520.00174.00003164@ng-ch1.aol.com>:
{} Hi.  I was hoping someone might be able to help me out with how to do something
{} in perl.
{} 
{} Let's say I have a text file that looks like this, with thousands of entries?
{} John     www.somewhere.com 
{} Mary     www.jodesigner.com  
{} Tom      www.tomsplace.com
{} John     www.somewhere.com
{} 
{} What I want to do is aggragate all the names and display it or write it to a
{} file.
{} 
{} Total unique users:  1234
{}     john       34
{}    Mary     10
{}    Tom        1
{}    Sarah     12
{} 
{} Total unique urls:    35
{}     www.somewhere.com   432
{}     www.yahoo.com    345
{} 
{} Can anyone show me how to do this? If you could send me email with an example
{} I would greatly appreciate it.

    perl -nawle '$users{$F[0]} ++;$urls {$F[1]} ++;
                 END {print "Unique users: ", scalar keys %users;
                      while (my ($u, $c) = each %users) {print "$u: $c"}
                      print "Unique urls: ", scalar keys %urls;
                      while (my ($u, $c) = each %urls) {print "$u: $c"}}' file


Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


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

Date: 15 Aug 2000 19:56:31 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Perl Jobs Galore!  Find them here.
Message-Id: <slrn8pj83f.52i.dha@panix2.panix.com>

On Wed, 9 Aug 2000 12:57:02 -0400, PerlPrincess <anonymous@cotse.com>
wrote:

>i found so many programming job listings here... 

You have posted a job posting or a resume in a technical group.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

There is a Perl Jobs Announce list that may be more helpful to you.  See
<http://www.pm.org/mailing_lists.shtml> for details.

Yours for a better usenet,

dha


-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
tastes filling! less great!	  - ignatz in #perl


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

Date: Tue, 15 Aug 2000 20:07:41 GMT
From: sankarmukh@my-deja.com
Subject: Perl to Lotus Notes mail
Message-Id: <8nc7tu$i05$1@nnrp1.deja.com>

Hi,

I am trying to send a test message from unix box acct (ctssmuk) to
Loyus notes acct using the following script. The script doesn't generate
any output nor any error.
******************************************************************
#!/usr/local/bin/perl -w

use Net::SMTP;

$smtp = Net::SMTP->new('pcfpdn02');

$smtp->mail('ctssmuk');
$smtp->to('sankarmukhopadhyay\@inautix.com');

$smtp->data();
$smtp->datasend("To: sankarmukhopadhyay\@inautix.com");
$smtp->datasend("\n");
$smtp->datasend("A simple test message\n");
$smtp->dataend();

$smtp->quit;

How can I test this scripting?

**********************************************************

The note server and things like that are OK because I get this when

****************************************************
#!/usr/local/bin/perl -w
use Net::SMTP;

$smtp = Net::SMTP->new('pcfpdn02');
print $smtp->domain,"\n";
$smtp->quit;
*******************************************************

inawk77:/u/ctssmuk/libnet-1.0703> ../sankar/sankar1/smtp_test1.pl
mail.inautix.com


Regards,

Sankar


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 15 Aug 2000 14:07:59 -0400
From: "zanrac" <lesbian@party.org>
Subject: Please explain the following line to me...
Message-Id: <8Gfm5.7451$Hu.113382@wagner.videotron.net>

if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {

   do things...

}

1) Is =~ for comparison or for assignation ? Is it for some kind of patern
match ?
2) Are the | for delimiters ?
3) Is the ?: used as a 'if' here ?
4) //([^/]* looks like a regular expression, am i right and what does it
mean ?


I must sound like a newbie but it's ok because i am a newbie. Thanks for you
help.




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

Date: 15 Aug 2000 13:26:29 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Please explain the following line to me...
Message-Id: <8nc20l$7to$1@provolone.cs.utexas.edu>

In article <8Gfm5.7451$Hu.113382@wagner.videotron.net>,
zanrac <lesbian@party.org> wrote:
>if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
>
>   do things...
>
>}

>1) Is =~ for comparison or for assignation ? Is it for some kind of patern
>match ?

It's a binding operator.  Do a "perldoc perlop" and you'll find a
description of it there.

>2) Are the | for delimiters ?

Not exactly.  They're the boundaries of a regular expression using the
alternate syntax that doesn't involve slashes.

Again, do "perldoc perlop".  (And once you've seen the syntax for
regular expression operators, learn about Perl's regular expressions
themselves using "perldoc perlre".)

>3) Is the ?: used as a 'if' here ?

Nope, the "?" is a modifier for the previous character in the regular
expression, and the ":" is just a literal in the regular expression.

>4) //([^/]* looks like a regular expression, am i right and what does it
>mean ?

As I'm sure you've figured out by now, "//([^/]*" is just part of the
regular expression.

By the way, since you're a newbie, I'll throw in the suggestion that
you do "perldoc perldoc" and "perldoc perl" to get an idea of what
documentation comes with perl and how to use it.

Hope that helps.

  - Logan


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

Date: Tue, 15 Aug 2000 14:30:15 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Please explain the following line to me...
Message-Id: <39998C37.75888F51@attglobal.net>

zanrac wrote:
> 
> if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
> 
>    do things...
> 
> }
> 
> 1) Is =~ for comparison or for assignation ? Is it for some kind of patern
> match ?

=~ is a match operator.  

> 2) Are the | for delimiters ?

in this case, yes.  They can also specify alternation within the 
regex body.

> 3) Is the ?: used as a 'if' here ?

no.  The ? after the https makes the 's' optional.  the : is a 
literal :.  Meaning, it could match http: or https:

> 4) //([^/]* looks like a regular expression, am i right and what does it
> mean ?

everything between the |s in this case is a regular expression.  
This bit matches two forward slashes, followed by anything that 
is not a forward slash, with anything that is not a forward slash
being optional. (the * quantifier specifies 0 or more)


read up on regular expression syntax in the perlre manpage.

$ perldoc perlre


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

Date: Tue, 15 Aug 2000 11:40:28 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Please explain the following line to me...
Message-Id: <39998E9C.DAAAC6EC@vpservices.com>

"zanrac" <lesbian@party.org> wrote:
> 
> if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
> 
>    do things...
> 
> }
> 
> 1) Is =~ for comparison or for assignation ? Is it for some kind of patern
> match ?

It depends what follows it.  foo =~ s/... is different from foo =~
m/...  In this case it is for comparison, basically asking if the $ENV
variable contains a certain pattern.

> 2) Are the | for delimiters ?

In this case, yes.  The m// operator (pattern matching) can use almost
any delimiter so those could have been exclamation marks or quote marks
just as well.  In this case it is useful because the default delimiter
'/' is contained in the pattern to be matched and that would get awfully
confusing.

> 3) Is the ?: used as a 'if' here ?

No.  But, frankly, I can't see exactly what it is doing there in this
case.  My guess would be that the person meant to put https*://  which
would match either http:// or https://. Or else they were trying some
variation on pattern clustering which escapes me at the moment.

> 4) //([^/]* looks like a regular expression, am i right and what does it
> mean ?

It is *part* of the regular expression.  

    //    are the two slashes in a URL (e.g. https://foo.bar.edu/).
    ()    means capture whatever is between them for use later
    [^/]* means everything that is not a slash (i.e. the host part of
the URL)

One thing I should point out, is that your snippet makes use of the
environment variable 'HTTP_REFERER' which *sometimes* shows what URL a
user is arriving at your cgi from.  But it is easily faked and is not a
reliable method for doing things like security checks so I hope that is
not what it is being used for.

> I must sound like a newbie but it's ok because i am a newbie.

No crime in that.  Newbies and newbie questions are welcomed in this
group although it is always best to do a little research first.  In your
case, the answers to all of your questions can be found in the part of
the perl FAQ called "perlre" (perl regular expressions) which is part of
the perl distribution.  You can read it by typing "perldoc perlre" at a
command prompt, or by various other means which you can learn about by
searching the archives of this newsgroup (found at www.deja.com) for the
regular posting on "Where to find the Perl FAQ".  If you read the FAQ
and it makes no sense (happens to me all the time), tell us what you're
stuck on and we'll try to help.

Good luck, welcome to perl.

-- 
Jeff


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

Date: Tue, 15 Aug 2000 14:52:58 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Please explain the following line to me...
Message-Id: <3999918A.6339330A@attglobal.net>

Jeff Zucker wrote:
> 
> > 3) Is the ?: used as a 'if' here ?
> 
> No.  But, frankly, I can't see exactly what it is doing there in this
> case.  My guess would be that the person meant to put https*://  which
> would match either http:// or https://. Or else they were trying some
> variation on pattern clustering which escapes me at the moment.
> 

Why would they have used a * quantifier here?  The ? will match
1 charachter, with that match being optional.  The * will match 
0 or more, so https* matches http, https fine, but it also matches
httpsssssssss.  While I wouldn't expect to see a referer start 
with httpsssss, I certainly wouldn't want to match one that did
sneak in.


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

Date: Tue, 15 Aug 2000 12:04:04 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Please explain the following line to me...
Message-Id: <39999424.228FA6E1@vpservices.com>

Drew Simonis wrote:
> 
> Jeff Zucker wrote:
> >
> > > 3) Is the ?: used as a 'if' here ?
> >
> > No.  But, frankly, I can't see exactly what it is doing there in this
> > case.  My guess would be that the person meant to put https*://  which
> > would match either http:// or https://. Or else they were trying some
> > variation on pattern clustering which escapes me at the moment.
> >
> 
> Why would they have used a * quantifier here?  The ? will match
> 1 charachter, with that match being optional.  The * will match
> 0 or more, so https* matches http, https fine, but it also matches
> httpsssssssss.  While I wouldn't expect to see a referer start
> with httpsssss, I certainly wouldn't want to match one that did
> sneak in.

You're right.  I'm sleepy.  Ignore me.

-- 
Jeff


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

Date: Tue, 15 Aug 2000 14:10:24 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Please explain the following line to me...
Message-Id: <399995A0.7CAA7145@home.com>

Jeff Zucker wrote:
> 
> "zanrac" <lesbian@party.org> wrote:
> >
> > if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
>
> > 3) Is the ?: used as a 'if' here ?
> 
> No.  But, frankly, I can't see exactly what it is doing there in this
> case.  My guess would be that the person meant to put https*://  which
> would match either http:// or https://.

And would also match httpssssss://

You got the intent right, but forgot that '?' is used for more than
clustering. In this case, it means '0 or 1 of the preceding.'

-mjc


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

Date: Tue, 15 Aug 2000 12:26:15 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Please explain the following line to me...
Message-Id: <39999957.A09D8A8@vpservices.com>


Michael Carman wrote:
> 
> Jeff Zucker wrote:
> >
> > "zanrac" <lesbian@party.org> wrote:
> > >
> > > if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
> >
> > > 3) Is the ?: used as a 'if' here ?
> >
> > No.  But, frankly, I can't see exactly what it is doing there in this
> > case.  My guess would be that the person meant to put https*://  which
> > would match either http:// or https://.
> 
> And would also match httpssssss://
> 
> You got the intent right, but forgot that '?' is used for more than
> clustering. In this case, it means '0 or 1 of the preceding.'


I've just had a lot of snakes trying to sneak into my sites lately :-). 
I was composing a self-correction note, but you and Drew beat me to it.

-- 
Jeff


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

Date: Tue, 15 Aug 2000 22:52:37 +0200
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: Processing text from gzipped file
Message-Id: <1effglw.aw3ypq1m71d14N%otto.wyss@bluewin.ch>

I'd like to open a gzipped file an process its contents. Is there any
easy way, i.e. is there a function (or module) to unzip it on the fly?

O. Wyss


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

Date: 15 Aug 2000 16:05:34 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Processing text from gzipped file
Message-Id: <87n1iegrq9.fsf@limey.hpcc.uh.edu>

>> On Tue, 15 Aug 2000 22:52:37 +0200,
>> otto.wyss@bluewin.ch (Otto Wyss) said:

> I'd like to open a gzipped file an process its
> contents. Is there any easy way, i.e. is there a
> function (or module) to unzip it on the fly?

    perldoc Compress::Zlib

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Tue, 15 Aug 2000 21:58:20 GMT
From: decklin+usenet@red-bean.com (Decklin Foster)
Subject: Re: Processing text from gzipped file
Message-Id: <02jm5.371$CW2.1075@news1.rdc1.ct.home.com>

Otto Wyss <otto.wyss@bluewin.ch> writes:

> I'd like to open a gzipped file an process its contents. Is there any
> easy way, i.e. is there a function (or module) to unzip it on the fly?

open FH, "gunzip -c $file|" or die "can't gunzip: $!";

-- 
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)


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

Date: Tue, 15 Aug 2000 13:31:46 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: push (@INC
Message-Id: <3999A8B2.8C3B0D6F@ipac.caltech.edu>

dschl@my-deja.com wrote:
> 
> Why doesn't push(@INC,...) work?
> 
> My source file contains these lines:
> 
>   BEGIN{
>   push(@INC, '/var/ns-home/cgi-bin');
>   use qqemail;
>   }
> 
> When run, I get the error:

As Matthew said, 'use lib qw(...)' is the way for you. But as to what went
wrong, here's what 'perldoc -f use' says:

"Imports some semantics into the current package from the named module,
generally by aliasing certain subroutine or variable names into your
package.  It is exactly equivalent to

    BEGIN { require Module; import Module LIST; }

except that Module I<must> be a bareword."

If we take that literally, you're trying to nest BEGIN blocks. Here's what
happens when you do that:

% perl -wle 'BEGIN { print "Hi 1"; BEGIN { print "Hi 2"}}'
Hi 2
Hi 1

So the interior-most one gets executed first. In your case, that means the 'use'
is executed before the 'push'. But since (non-nested) BEGIN blocks are executed
in the order they're defined

% perl -wle 'BEGIN { print "Hi 1" } BEGIN { print "Hi 2" }'
Hi 1
Hi 2

 ... then this should work:

>   BEGIN{
>   push(@INC, '/var/ns-home/cgi-bin');
>   }
>   use qqemail;

But 'use lib' is the correct direction in any case.

--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Tue, 15 Aug 2000 20:37:39 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Quiting a: while (<STDIN>)
Message-Id: <1efepzi.fn6a581vao1bgN%tony@svanstrom.com>

I've never come across this one before, and I hope that I can get some
help...

I've got a while (<STDIN>) where I do something with each line I get,
but in some cases I might want only the first few lines, of what could
be several meg. The question is: What is the most correct way of leaving
it while there's still data to accept?

Maybe a simple last to get out of it is enough, maybe I have to accept
it all, to avoid an error message otherwise... Anyone that knows for
sure?


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
 DSS: 0x9363F1DB, Fp: 6EA2 618F 6D21 91D3 2D82  78A6 647F F247 9363 F1DB
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©1999  <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Tue, 15 Aug 2000 19:48:12 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Quiting a: while (<STDIN>)
Message-Id: <08hm5.4352$K5.90873@typhoon.austin.rr.com>

In article <1efepzi.fn6a581vao1bgN%tony@svanstrom.com>,
Tony L. Svanstrom <tony@svanstrom.com> wrote:
>I've never come across this one before, and I hope that I can get some
>help...
>
>I've got a while (<STDIN>) where I do something with each line I get,
>but in some cases I might want only the first few lines, of what could
>be several meg. The question is: What is the most correct way of leaving
>it while there's still data to accept?
>
>Maybe a simple last to get out of it is enough, maybe I have to accept
>it all, to avoid an error message otherwise... Anyone that knows for
>sure?

Have you looked at the first few lines generated by

  perldoc -tf last

    last LABEL
    last    The `last' command is like the `break' statement in C (as used
            in loops); it immediately exits the loop in question. If the
            LABEL is omitted, the command refers to the innermost enclosing
            loop. The `continue' block, if any, is not executed:

                LINE: while (<STDIN>) {
                    last LINE if /^$/;      # exit when done with header
                    #...
                }


Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |
GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work)      |                  75D2 9EC4 C1C0 0599 13DA


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

Date: 15 Aug 2000 19:30:18 GMT
From: bmetcalf@nortelnetworks.com (Brandon Metcalf)
Subject: Re: Quiting a: while (<STDIN>)
Message-Id: <8nc5oa$iqp$1@bcrkh13.ca.nortel.com>

tony@svanstrom.com writes:

 > I've got a while (<STDIN>) where I do something with each line I get,
 > but in some cases I might want only the first few lines, of what could
 > be several meg. The question is: What is the most correct way of leaving
 > it while there's still data to accept?
 > 
 > Maybe a simple last to get out of it is enough, maybe I have to accept
 > it all, to avoid an error message otherwise... Anyone that knows for
 > sure?

last will work.

Brandon


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

Date: 15 Aug 2000 19:52:30 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Quiting a: while (<STDIN>)
Message-Id: <8nc71u$86cdm$8@ID-24002.news.cis.dfn.de>

hi,
Tony L. Svanstrom <tony@svanstrom.com> wrote:

> I've got a while (<STDIN>) where I do something with each line I get,
> but in some cases I might want only the first few lines, of what could
> be several meg. The question is: What is the most correct way of leaving
> it while there's still data to accept?

uhm, if i understand you right, you have a
condition, and if this is true, you want to
end the while loop?

well, then try:
last if $condition;

tina


-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \ _,_\ __/\ __/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: 15 Aug 2000 13:46:44 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Quiting a: while (<STDIN>)
Message-Id: <m3vgx29xbf.fsf@dhcp11-177.support.tivoli.com>

tony@svanstrom.com (Tony L. Svanstrom) writes:

> I've got a while (<STDIN>) where I do something with each line I get,
> but in some cases I might want only the first few lines, of what could
> be several meg. The question is: What is the most correct way of leaving
> it while there's still data to accept?
> 
> Maybe a simple last to get out of it is enough, maybe I have to accept
> it all, to avoid an error message otherwise... Anyone that knows for
> sure?

Using "last" should be fine.  You may want to close STDIN after you
are finished, which may free up any buffer space if this is on a
pipeline (and may even allow a previous process in the pipeline to
complete early).

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 15 Aug 2000 13:38:21 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Quiting a: while (<STDIN>)
Message-Id: <3999AA3D.DCB05780@ipac.caltech.edu>

"Tony L. Svanstrom" wrote:
> I've got a while (<STDIN>) where I do something with each line I get,
> but in some cases I might want only the first few lines, of what could
> be several meg. The question is: What is the most correct way of leaving
> it while there's still data to accept?
> 
> Maybe a simple last to get out of it is enough, maybe I have to accept
> it all, to avoid an error message otherwise... Anyone that knows for
> sure?

I don't mean to be snarky, but what's wrong with running an experiment and
finding out? You'll know for sure alot faster than by posting to Usenet.

perl -we 'my $n=0; while(<STDIN>) { last if ++$n > 3; print; }'

What happens when you type 3 lines of input at your terminal after executing
this one-liner? 

--

-- Tim Conrow         tim@ipac.caltech.edu       626-395-8435


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

Date: Tue, 15 Aug 2000 23:04:54 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Quiting a: while (<STDIN>)
Message-Id: <Pine.GHP.4.21.0008152256040.7700-100000@hpplus03.cern.ch>

On 15 Aug 2000, Ren Maddox wrote:

> Using "last" should be fine.  You may want to close STDIN after you
> are finished, 

Looks good to me.  

However, situations arise where, outside of the loop, you will want to
test whether the loop was exited prematurely or ran to completion.

In that kind of situation, I rather like the idea of having the loop
as a logical function, which returns with a true value when it runs to
completion, or false when exited prematurely.  Then you exit
prematurely by issuing a return (with a value of false), rather than
with last.

Back when I was using BCPL (a language which I grew remarkably fond
of, when you consider that physicists write FORTRAN in any language
;-) I would do that with a VALOF , putting the code of the function
in-line.  And hey, Perl has a way to do that too.  But there's always
more than one way....

cheers



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

Date: Fri, 11 Aug 2000 10:21:25 -0300
From: Igor Campos Leal <igorleal@dcc.ufmg.br>
Subject: Using a subroutine from another file!!!
Message-Id: <Pine.GSO.4.21.0008111018270.26370-100000@turmalina.dcc.ufmg.br>

Please, help me!
I wanna know how I can use a function from another program in my program
in use. May I use something like:

use "my_another_program.pl";

inside my program in use???

Thanks,

                    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
                    \                                      /
                    /           Igor Campos Leal           \
                    \        Ciencia da Computacao         /
                    /              DCC - UFMG              \
                    \     e-mail:   igorleal@dcc.ufmg.br   /
                    /               igor@acesso.com.br     \
                    \             ICQ# 37936364            /
                    /                                      \
                    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



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

Date: Tue, 15 Aug 2000 19:58:35 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Using a subroutine from another file!!!
Message-Id: <Lhhm5.4353$K5.90873@typhoon.austin.rr.com>

In article <Pine.GSO.4.21.0008111018270.26370-100000@turmalina.dcc.ufmg.br>,
Igor Campos Leal  <igorleal@dcc.ufmg.br> wrote:
>Please, help me!
>I wanna know how I can use a function from another program in my program
>in use. May I use something like:
>
>use "my_another_program.pl";
>
>inside my program in use???

You might want to visit http://www.plover.com/~mjd/perl/Hello/ whose
"introduction" includes:

 The very very short tutorial about modules in Perl

 There are two styles you can use for Perl modules. Both are useful under
 different circumstances. 

 In the `exporting' style, the `module file' defines some functions which you
 can load into your program and use as if you had defined them
 yourself. 

You sound like you're interested in the exporting style...

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |
GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work)      |                  75D2 9EC4 C1C0 0599 13DA


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

Date: Tue, 15 Aug 2000 12:00:55 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: What's the best way to overwrite a string with '*?
Message-Id: <8nc3ud$imk$1@brokaw.wa.com>


> Alex Buell (alex.buell@tahallah.clara.co.uk):comp.lang.perl.misc:Tue, 15
Aug 2000 11:44:20 +0100:quote:
> : For example, I have a string 'Hello world, I am 29!' that I want to
> : overwrite with '*' (asterisks) such that it becomes the following:
> : '*********************'.
> :
> : What's the best way to do this?

I've been receiving replies before original posts lately, sorry for the
misplaced followup.

$str = 'abc';
$str = '*' x length $str;

But is that *really* the question?  Could this be an AB question and you are
really wondering how to get a password from a user?

See perlfaq8: How do I ask the user for a password?

Lauren
--
print grep ord $_,map{y/a-z//d;$x.="+ $_";chr(eval $x)}
'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
c40k25er2wx8-y6z13-81'=~m#([^!\n]{3})#g#tr/-0-9//d;print





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

Date: 15 Aug 2000 21:17:18 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Where can I find Basic Perl Definitions?
Message-Id: <slrn8pjcpr.tj3.abigail@alexandra.foad.org>

Lincoln [HOOF:4713:EXCH] (lincolnmarr@europem01.nt.com) wrote on
MMDXXXVII September MCMXCIII in <URL:news:39941458.364CCEA8@europem01.nt.com>:
^^ I'm getting reasonable at programming perl/CGI stuff by now but I am
^^ still fairly new to Perl. I am enjoying the perl community and their
^^ willingness to help each other, but I haven't yet managed to find a
^^ website or any other documentation which defines clearly how to use the
^^ perldoc command, or which defines basic programming things such as
^^ classes, packages, modules etc and what ActivePerl is etc.
^^ 
^^ I don't expect everyone here to tell me about these things I was
^^ wondering whether you could tell us newbies where to find some
^^ documentation like this, I'm sure a lot of people would find it
^^ useful... don't you remember what your first few weeks of programming
^^ Perl were like?? (well for me I've been thrown in the deep end ... my
^^ boss says to learn perl and make a huge database driven website within 3
^^ months...)


man perl


Abigail
-- 
perl -we'$;=$";$;{Just=>another=>Perl=>Hacker=>}=$/;print%;'


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4027
**************************************


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