[9911] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3504 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 21 20:07:15 1998

Date: Fri, 21 Aug 98 17:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 21 Aug 1998     Volume: 8 Number: 3504

Today's topics:
        $ftp->put stores empty file (Net::FTP) <Robert.Lopez@abq.sc.philips.com>
        5.005 Under HPUX 11.0 - help! <derek_sherlock@hp.com>
        beginners substring question <saunder@kben.co.uk>
    Re: beginners substring question (Kelly Hirano)
    Re: beginners substring question <r28629@email.sps.mot.com>
    Re: COBOL and Perl cadams@acucorp.com
    Re: comp.lang.perl.announce redux <tchrist@mox.perl.com>
    Re: comp.lang.perl.announce redux <tchrist@mox.perl.com>
    Re: comp.lang.perl.announce redux <tchrist@mox.perl.com>
    Re: comp.lang.perl.announce redux (John Moreno)
    Re: Date Manipulation (Josh Kortbein)
    Re: Date Manipulation (Abigail)
    Re: help, @INC doesn't contain /usr/lib/perl5 nana@my-dejanews.com
    Re: How do I read a file backwards. <jdw@dev.tivoli.com>
    Re: Index.pl <jdw@dev.tivoli.com>
        ioctl.pm  <dlambert@sangacorp.com>
    Re: NEWBIE Question: Perl Script in Unix vs. NT (John Moreno)
        No index script <bpn@get2net.dk>
    Re: Perl Bots! [Chatterbots, FAQbots, InfoBots] (Abigail)
    Re: Prime numbers [was Re: here's an implementation of  (Matt Knecht)
    Re: Problem using CGI.pm for the first time <jdw@alder.dev.tivoli.com>
    Re: Problem using CGI.pm for the first time <jdw@dev.tivoli.com>
    Re: Problem using CGI.pm for the first time <murrayb@vansel.alcatel.com>
    Re: Send cmd and Receive result from command? (Charles DeRykus)
    Re: system commands <r28629@email.sps.mot.com>
    Re: Test Post 1 - please ignore <r28629@email.sps.mot.com>
    Re: Turn Perl program into binary <terjekv@ifi.uio.no>
    Re: Turn Perl program into binary <r28629@email.sps.mot.com>
    Re: Turn Perl program into binary (Maurice Aubrey)
    Re: Utility for news article fetching selected by keywo (John Stanley)
    Re: what is 'sub f () {555};' (Josh Kortbein)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 21 Aug 1998 15:55:24 -0600
From: Robert Lopez <Robert.Lopez@abq.sc.philips.com>
Subject: $ftp->put stores empty file (Net::FTP)
Message-Id: <jc6ww82knjn.fsf@abqn07.ato.sca.philips.com>


I have a program which runs with no errors and puts
only empty files at the destination.

I have used Net::FTP for a while and never encountered
this problem. I have checked and in all previous cases
I used get() with no problem. Apparently I never used put(). 

This is a reduction of what I am doing:

my $ftp = Net::FTP->new($dns_host, Timeout => 60) or
  die "Host unreachable : $dns_host : $!";
$ftp->login() or
  die "Can not login to $dns_host : " . $ftp->message;
$ftp->cwd($dns_drop_point) or
  die "Can not change directory on $dns_host : " . $ftp->message;
$ftp->ascii() or
  die "Unable to confirm ascii mode: " . $ftp->message;
$ftp->put($subnet_5) or
  die "Unable to put $subnet_5 file on $dns_host : " . $ftp->message;
$ftp->quit() or
  die "Could not close connection to $dns_host : $!";
print "DNS file created and put in place on $dns_host.\n";
exit;

and it runs to the exit without errors.

I stuck a ->get() in there above and below the ->put() and they work
fine. So the connection is being made correctly. The problem is
independent of destination systems.

I was convinced that any such bug in the Net::FTP module would have
been discussed I searched dejanews but did not find any reference
to a known bug. So I decided it was the way I was using the put
method. I tried put($subnet_5), put("$subnet_5"), put('subnet.5')
which is the file name directly put in there but none of that helped.
I also tried stor() and stou() but I confess I do not understand
why they exist.

I put a $ftp->debug(1); line just before the my $ftp = Net::FTP...
line and the output does not suggest any problem to me:

Net::FTP: Net::FTP(2.33)
Net::FTP:   Exporter
Net::FTP:   Net::Cmd(2.11)
Net::FTP:   IO::Socket::INET
Net::FTP:     IO::Socket(1.1603)
Net::FTP:       IO::Handle(1.1504)

Net::FTP=GLOB(0xb3344)>>> PORT 130,140,5,4,220,179
Net::FTP=GLOB(0xb3344)<<< 200 PORT command successful.
Net::FTP=GLOB(0xb3344)>>> STOR subnet.5
Net::FTP=GLOB(0xb3344)<<< 150 ASCII data connection for subnet.5 (130.140.5.4,56499).
Net::FTP=GLOB(0xb3344)<<< 226 Transfer complete.
Net::FTP=GLOB(0xb3344)>>> QUIT
Net::FTP=GLOB(0xb3344)<<< 221 Goodbye.
DNS file created and put in place on abqato.

But I do note that the 150 ASCII data line does not have a file size
at the end the way the gets did when I put gets in for more debug
info. 

I ran the program with the debugger and put a break point at the 
start of the above code. Stepping through it showed me no problems
but there was so much code I stepped through, which I did not 
understand, that I might have missed some error.

Using a protocol analyzer on the net I can see the file is opened
and then closed without any transfer of file content.

-- 
Robert.Lopez@abq.sc.philips.com


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

Date: Fri, 21 Aug 1998 17:55:41 -0600
From: Derek Sherlock <derek_sherlock@hp.com>
Subject: 5.005 Under HPUX 11.0 - help!
Message-Id: <35DE08FC.95C1C080@hp.com>

Hi Folks,

I'm trying to compile perl 5.005 under HPUX 11.0.

It builds & works just great, unthreaded.

When I turn on threads.  Then it still compiles, but at link time I get
an undefined symbol "PL_defstash".

Here's how I'm compiling:

  ./Configure -Dusethreads
   (default answers for everything, except under the list of libraries,
I add -lpthread just before -lc)
  make depend
  make

Can anybody throw any light on this mystery?

Many thanks,
Derek.




--
 ___ __ /___ ___    Derek Sherlock
|   /  /_ _ \   |   Fort Collins Systems Lab (FSL)
|  /  / // / \  |   3404 E. Harmony
|  \ / //_/  /  |   Fort Collins CO 80525
|___\_ /____/___|
      /             Direct: 970-898-7582
  H E W L E T T     Fax:    970-898-7388
  P A C K A R D     Email:  dereks@fc.hp.com





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

Date: Wed, 19 Aug 1998 18:11:06 +0100
From: Robert Saunders <saunder@kben.co.uk>
Subject: beginners substring question
Message-Id: <35DB072A.66B0F07E@kben.co.uk>

Hi

Here's the situation: I have files in which there are lines begining
with a time stamp
the format of which is a little variable and I want to extract the
year.  Some examples
are:

00:98/08/18 17:57:36.22 blah blah blah
01:98/08/18 12:57:36.34 blah blah blah
0023:01:98/08/18 10:45:23.25 blah blah blah
000001:0023:0001:1998/08/18 10:45:23.56 blah blah blah
03:1998/08/18 17:45:23.45 blah blah blah

well you get the idea.  I can see how a simple use of
index($line,"/") would get where the date ended. Help would be
appreciated

thanks

Robert



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

Date: 21 Aug 1998 16:29:25 -0700
From: hirano@Xenon.Stanford.EDU (Kelly Hirano)
Subject: Re: beginners substring question
Message-Id: <6rkvsl$moq@Xenon.Stanford.EDU>

In article <35DB072A.66B0F07E@kben.co.uk>,
Robert Saunders  <saunder@kben.co.uk> wrote:
>Hi
>
>Here's the situation: I have files in which there are lines begining
>with a time stamp
>the format of which is a little variable and I want to extract the
>year.  Some examples
>are:
>
>00:98/08/18 17:57:36.22 blah blah blah
>01:98/08/18 12:57:36.34 blah blah blah
>0023:01:98/08/18 10:45:23.25 blah blah blah
>000001:0023:0001:1998/08/18 10:45:23.56 blah blah blah
>03:1998/08/18 17:45:23.45 blah blah blah

how about something like:

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

my @years;
while (<>) {
	## provided that the year is always the first
	## part of the date and there is always some
	## number followed by a colon before it
	m!:(\d+)/!;
	push (@years, $1);
}

## all of your years are in the array @years
-- 
Kelly William Hirano	                    Stanford Athletics:
hirano@cs.stanford.edu	                 http://www.gostanford.com/
hirano@alumni.stanford.org      (WE) BEAT CAL (AGAIN)! 100th BIG GAME: 21-20


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

Date: Fri, 21 Aug 1998 18:19:13 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: beginners substring question
Message-Id: <35DE0071.2F4C3546@email.sps.mot.com>

> Here's the situation: I have files in which there are lines begining
> with a time stamp
> the format of which is a little variable and I want to extract the
> year.  Some examples
> are:
> 
> 00:98/08/18 17:57:36.22 blah blah blah
> 01:98/08/18 12:57:36.34 blah blah blah
> 0023:01:98/08/18 10:45:23.25 blah blah blah
> 000001:0023:0001:1998/08/18 10:45:23.56 blah blah blah
> 03:1998/08/18 17:45:23.45 blah blah blah
> 

if your line formats are as consistant as your example shows, then try
this

foreach (@lines) {
	if (/:([0-9]+)\//) {
		print "\nYear is $1";
	}
}	

# -TK


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

Date: Fri, 21 Aug 1998 22:19:29 GMT
From: cadams@acucorp.com
Subject: Re: COBOL and Perl
Message-Id: <6rkrph$j64$1@nnrp1.dejanews.com>

In article <6rkfeb$kqc@sjx-ixn6.ix.netcom.com>,
  "William M. Klein" <wmklein@ix.netcom.com> wrote:

> Is there anyone in either NG who actually makes their living today with both
> COBOL (the current variation, not some pre-ANS'85 archaic version) and also

Disclaimer: I work for a COBOL vendor (Acucorp) but I've also written a fair
amount of Perl

> Perl who can give a *brief* comment on when they use which and what types of
> constructs or applications are better in one than the other?  My guess is

I'd give Perl the nod on string handling, particularly since it has excellent
regular expression support. I'd give COBOL the nod for record/indexed file
handling, screen-based I/O, and business math. However, I'll note that both
languages are sufficiently rich that you can solve any problem with either
one.

I'd also note that COBOL has been around longer and business has invested
billions in it, so the smart money says that it'll be with us for quite some
time. Perl probably will too but it just doesn't have the longevity track
record.

COBOL is probably easier to audit for correctness as Perl allows a programmer
to be *very* clever if they wish. Of course, this really gets into
shop-standards - programmers can certainly produce horrible code in either
language.

<PLUG MODE="SHAMELESS">
While I give COBOL the nod for screen I/O, it's worth noting that the COBOL
standard only deals with character-mode screens. I'll note, however, that the
extensions in Acucobol-GT make it the easiest GUI creation language I've seen.
Perl doesn't have much in the language itself but there are quite a few
available modules in CPAN's User Interface category.
</PLUG>

----
# The views expressed in this message are my
# own and may not match those of my employer.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 21 Aug 1998 22:41:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: comp.lang.perl.announce redux
Message-Id: <6rkt25$nar$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, "Daniel Adams" <dan@fearsome.net> writes:
:Actually, Paddy was entirely correct in what he said. The language known as
:English is documented in dictionaries such as the Oxford English Dictionary.
:American English, whilst stemming from the same origins as British English,
:is sufficiently different to be classified as a different language. 

No, sir.  Please pick up a basic college textbook on linguistics
and study the differences between "language" and "dialect".

--tom
-- 
     "... an initial underscore already conveys strong feelings of
      magicalness to a C programmer."
	--Larry Wall in <1992Nov9.195250.23584@netlabs.com>


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

Date: 21 Aug 1998 22:42:21 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: comp.lang.perl.announce redux
Message-Id: <6rkt4d$nar$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, phenix@interpath.com (John Moreno) writes:
:This is of course ridiculous - please, a hundred words that are British
:English and not American English (no slang or food please).

That's not going to prove anything.

--tom
-- 
Unix never says `please.'  -- Rob Pike


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

Date: 21 Aug 1998 22:46:47 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: comp.lang.perl.announce redux
Message-Id: <6rktcn$nar$3@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, "Daniel Adams" <dan@fearsome.net> writes:
:However, the divisions between American English and British English are too
:great to fall under any lesser category of divission (such as "dialect") and
:have reached a stage where they are two seperate languages in their own
:right. 

Pardon me, but what language is it that has words such as "divission"
and "seperate"?  Certainly not English.  Whatever your native language
actually happens to be, I don't think you're in much a position to be
dictating to scholars what constitutes a language and what a dialect,
particularly with regard to a language that you do not appear to write.

--tom :-)
-- 
    X-Windows: It was hard to write; it should be hard to use.
	--Jamie Zawinski


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

Date: Fri, 21 Aug 1998 19:30:24 -0400
From: phenix@interpath.com (John Moreno)
Subject: Re: comp.lang.perl.announce redux
Message-Id: <1de4k88.1co7p5msanbs0N@roxboro0-031.dyn.interpath.net>

Tom Christiansen <tchrist@mox.perl.com> wrote:

>  [courtesy cc of this posting sent to cited author via email]

All responses to my post are automatically brought o my attention.

> In comp.lang.perl.misc, phenix@interpath.com (John Moreno) writes:
> :This is of course ridiculous - please, a hundred words that are British
> :English and not American English (no slang or food please).
> 
> That's not going to prove anything.

Not of itself no, but it'd be a start.  Perl and C are a different
languages that have a lot of points in common, but picking out major
differences is extremely easy.  Doing so with American and Britsh
english, isn't anywhere near as simple.

-- 
John Moreno


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

Date: 21 Aug 1998 22:39:53 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: Date Manipulation
Message-Id: <6rksvp$73c$1@news.iastate.edu>

shawn_campbell@my-dejanews.com wrote:
: I am looking for a way to manipulate dates in Perl: ie. add/subtract various
: date parts.  Most ide's (VB, Access, Powerbuilder) and databases (Oracle
: PL/SQL, Sybase Transact SQL) have functions for this purpose.  However, I
: have not found anything similar in Perl.

See Date::Manip at your nearest CPAN mirror.



Josh

-- 
I am the author of all tucks & damask piping
I am the Chrome Dinette
I am the Chrome Dinette
I am the eggs of all persuasion



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

Date: 21 Aug 1998 23:36:38 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Date Manipulation
Message-Id: <6rl0a6$kce$1@client3.news.psi.net>

shawn_campbell@my-dejanews.com (shawn_campbell@my-dejanews.com) wrote on
MDCCCXVI September MCMXCIII in <URL: news:6rko96$eud$1@nnrp1.dejanews.com>:
++ I am looking for a way to manipulate dates in Perl: ie. add/subtract various
++ date parts.  Most ide's (VB, Access, Powerbuilder) and databases (Oracle
++ PL/SQL, Sybase Transact SQL) have functions for this purpose.  However, I
++ have not found anything similar in Perl.

Take your subject, delete everything after the 'p', and replace the
white space with perl5's equivalent of perl4's '. Now goto CPAN.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: Fri, 21 Aug 1998 18:43:30 -0400
From: nana@my-dejanews.com
Subject: Re: help, @INC doesn't contain /usr/lib/perl5
Message-Id: <nana-2108981843300001@jvs.gdn.org>


thanks for respond.

no luck again. it is so frustrating. I tryed to recompile. I tryed to
mannually add /usr/lib/perl5. In script itself I put #!/usr/bin/perl
-I/usr/lib/perl5 and then it again gave me error on strict.pm -
complaining that can't locate it in /usr/lib/perl5 as well. So there must
be some other thing, I just don't have any idea. Strange thing is that it
doesn't complain about other modules: CGI.pm or Mysql... 


> In article <6rh9be$8s7$1@nnrp1.dejanews.com>,
>   nana@my-dejanews.com wrote:
> > I've just installed latest perl on my linux on intell. actually it was
> > installed with linux, but then I needed some additional modules. I tryed to
> > use CPAN shell to install them and finally ended up installing the latest
> > perl5.00502.
> >
> > Now my problem is that it can't find any module which is in /usr/lib/perl5
> > (strict.pm for example) and reason is that @INC contains
> > /usr/lib/perl5.00502, /usr/lib/perl5/site_perl, etc, except /usr/lib/perl5.
> > Is this a way it sould be, or do I need somehow to include /usr/lib/perl5 in
> > @INC and how to do that?
> >
> > thanks
> >
> 
>         There are many ways to do this.  One is using the environment
variabble
>         PERL5LIB pointing to your /usr/lib/perl5 (for global effect or local).
>         Another way is push it in the @INC array in your script (local
to script
>         only).  And if you're brave enough, re-config and re-compile.
> 
>         Dzuy
> 
> > -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> > http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum
> >
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 21 Aug 1998 17:59:32 -0500
From: "Jim Woodgate" <jdw@dev.tivoli.com>
Subject: Re: How do I read a file backwards.
Message-Id: <obk942hrfv.fsf@alder.dev.tivoli.com>


Robert Saunders <saunder@kben.co.uk> writes:
> I want to look through some very large files for particular lines.
> Since I want the last occurence of these lines,  working from the end
> of the file towards the start would be preferable. other than repeatedly
> 
> invoking `tail -n` with n increasing can anybody suggest a better way.

perldoc -f seek

you could seek to the end of the file, read backwards (saving
characters as you went along, when you hit the end of a line, simply
return  reverse $line.

I don't know if that would actually be faster than just going through
the entire file (where you have perl and os optimizations working in
your favor) even if the file is really long, but under certain
conditions it might...

-- 
Jim Woodgate 
Tivoli Systems
E-Mail: jdw@dev.tivoli.com


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

Date: 21 Aug 1998 16:13:09 -0500
From: "Jim Woodgate" <jdw@dev.tivoli.com>
Subject: Re: Index.pl
Message-Id: <obn28yhwd6.fsf@alder.dev.tivoli.com>


james.a.ray2@boeing.com (Jim Ray) writes:
> I need a  perl script that will create a linkable list 
> 
> Example
> 
> Top
>   SubDir
>      Files
>      Files
>         SubDir
>            Files
>            Files
>   SubDir
>      Files
>      Files
>         SubDir
>            Files
>            Files
> 
> Each one of these need to have a link attached to them.  Does anyone have 
> any suggestions?

Not exactly what you want, but might get you started in the right
direction:

use CGI qw/:standard/;
require "find.pl";

# Traverse desired filesystems

&find('.');

exit;

sub wanted {
  my $link = make_link($name);
  my $text = make_text($name);
  print a({-href => $link}, $text), "\n";
}


-- 
Jim Woodgate 
Tivoli Systems
E-Mail: jdw@dev.tivoli.com


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

Date: Fri, 21 Aug 1998 23:07:51 GMT
From: Donald WHIZZARD Lambert <dlambert@sangacorp.com>
Subject: ioctl.pm 
Message-Id: <35DDFDDA.A9E4C5E3@sangacorp.com>

Hello I am looking for the perl module ioctl.pm, I was told I could find
it from CPAN,
however I have not been able to locate it.

    Any help would be greatful.

            -- Donnie
                dlambert@sangacorp.com



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

Date: Fri, 21 Aug 1998 19:30:30 -0400
From: phenix@interpath.com (John Moreno)
Subject: Re: NEWBIE Question: Perl Script in Unix vs. NT
Message-Id: <1de4lhq.1nuise26jtxfkN@roxboro0-031.dyn.interpath.net>

In comp.lang.perl.misc Mr. Mirthful wrote:

> TextPad is MAC, no? Anyone know a format to save in from Windows that
> will avoid the ^M problem?

No, as he said, TexPad is windows.

As for a windows format - don't bother, use a decent ftp client and it
should all happen automatically.

-- 
John Morene


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

Date: Sat, 22 Aug 1998 00:26:38 +0200
From: "Brian Nielsen" <bpn@get2net.dk>
Subject: No index script
Message-Id: <6rks6j$37m$1@dalen.get2net.dk>

Hi there,

I am looking for a cgi-script that can take all my files in a dir without an
index.html
and create a nice site on the fly.
Do you know where I can find sutch a script?

Brian




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

Date: 21 Aug 1998 23:38:08 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl Bots! [Chatterbots, FAQbots, InfoBots]
Message-Id: <6rl0d0$kce$2@client3.news.psi.net>

Jonathan Feinberg (jdf@pobox.com) wrote on MDCCCXVI September MCMXCIII in
<URL: news:n28ycafc.fsf@mailhost.panix.com>:
++ harry@dublin.net (Harry McGreggor) writes:
++ 
++ > Has anyone used the Eliza module to create anything useful?
++ 
++ [*boggle*]


Well, Eliza created emacs, didn't she?



Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


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

Date: Fri, 21 Aug 1998 22:55:47 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Prime numbers [was Re: here's an implementation of diff in perl]
Message-Id: <TVmD1.246$pY1.2098284@news2.voicenet.com>

Sean McAfee <mcafee@pacman.rs.itd.umich.edu> wrote:
>It has nothing to do with the number base used.
>
>Let $x and $y be strings such that $x = $c x $n and $y = $c x $m, for any
>one-character string $c ('1' in our case) and some integers $n and $m.
>Then
>
>$x =~ /^($y)\1+$/
>
>will be a true expression iff $x consists of an integral number >= 2 of
>repetitions of $y (that is, if $n is evenly divisible by $m, $n/$m being at
>least 2).  Clear?

Crystal.

>If $y is replaced with 11+, the + quantifier will first gobble up all of
>$x, thereby testing if $n is divisible by $n, $n/$n being at least 2.
>After this initial failure, the + quantifier will put back '1's one at a
>time until either the patten is matched or it cannot put back any more

The regex wasn't hard to understand.  What was eluding me was the logic
behind it. :)

>'1's.  In other words, the RE engine successively tests whether $n is
>divisible by $n-1, $n-2, ..., 2.  If this test ever succeeds, $n is
>composite and is not printed.  If the match ultimately fails, then $n is
>not divisble by any number from 2 to $n-1, so it is prime and is printed.

And length $1 returns the value of what it was divisible by.  For
example: 

$nine = '111111111';
$nine =~ /^(11+)\1+$/;
print length $nine, ' is divisible by ', length $1, "\n" if $1;

Nifty!

>Neat, isn't it?  I think this has to be one of the niftiest pieces of Perl
>code I've ever seen.

I'll have to agree here.  And add a much less obfuscated translation.

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

OUTER: for $number (1 .. 10) {
    INNER: for ($divisor = $number - 1; $divisor > 1; $divisor--) {
        next OUTER unless $number % $divisor;
    }
    print "prime: $number\n";
}

Hard to beleive that accomplishes the same thing!

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: 21 Aug 1998 16:02:11 -0500
From: Jim Woodgate <jdw@alder.dev.tivoli.com>
Subject: Re: Problem using CGI.pm for the first time
Message-Id: <obogtehwvg.fsf@alder.dev.tivoli.com>


ffan@itsa.ucsf.edu (Francis Fan) writes:
> I was trying to use CGI.pm for the first time but it is not working.
> My script is,
> #!/usr/bin/perl -w
> 
> use CGI qw/:standard/;
> 
> print   start_html('Vegetables');
> print   h1('Eat your vegetables');
> print   hr;
> print   end_html;
> 
> But when I run, it gave me this -
> torrey:~/public_html>t.cgi
> (offline mode: enter name=value pairs on standard input)
> 
> And I have to usr Ctrl-C to escape it.

this is normal, CGI noticed you were running from the command line,
and not a httpd/browser environment, and is asking if there are any
variables you'd like to set before the script runs (so you can
simulate input to a form, for example).  Simply hit Ctrl-D at the
prompt to let CGI.pm know you have no more data to enter, and it will
print the start_html code as well...

perldoc CGI would be big help as well....

-- 
Jim Woodgate 
Tivoli Systems
E-Mail: jdw@dev.tivoli.com


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

Date: 21 Aug 1998 17:50:57 -0500
From: "Jim Woodgate" <jdw@dev.tivoli.com>
Subject: Re: Problem using CGI.pm for the first time
Message-Id: <oblnoihru6.fsf@alder.dev.tivoli.com>


Francis Fan <ffan@mail.arc.nasa.gov> writes:
> ~/public_html>t.cgi
> (offline mode: enter name=value pairs on standard input)
> Can't call method "rearrange" without a package or object reference at
> (eval 6) line 5.
> CGI=HASH(0x100b9250)Vegetables

don't know where that came from, did you pass anything before hitting Ctrl-D

> And I will use CGI.pm in my cgi scripts, so I couldn't wait for user to
> enter Ctrl-d.

like I said in my previous post, you're only getting this because you
are running from the command line.  When running as a *real* cgi
script, it will get these types of variables from the httpd daemon...

a man CGI would help quite a bit...

-- 
Jim Woodgate 
Tivoli Systems
E-Mail: jdw@dev.tivoli.com


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

Date: 21 Aug 1998 15:07:59 -0700
From: Brad Murray <murrayb@vansel.alcatel.com>
Subject: Re: Problem using CGI.pm for the first time
Message-Id: <uvhnmrnsw.fsf@vansel.alcatel.com>

Francis Fan <ffan@mail.arc.nasa.gov> writes:

>   I tried Ctrl-D, it gave me this -
> 
> ~/public_html>t.cgi
> (offline mode: enter name=value pairs on standard input)
> Can't call method "rearrange" without a package or object reference at
> (eval 6) line 5.
> CGI=HASH(0x100b9250)Vegetables
> 
> And I will use CGI.pm in my cgi scripts, so I couldn't wait for user to
> enter Ctrl-d.

CGI.pm only behaves this way from the command line.  It is used to debug
your work.  It does not behave this way when executed by a web server.
You desperately need to read more about CGI.pm and, by the sounds of
things, CGI in general.


-- 
Brad Murray       "A great many people think they are thinking when
Software Analyst   they are merely rearranging their prejudices."
Alcatel Canada	                                  -- William James


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

Date: Fri, 21 Aug 1998 22:29:59 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Send cmd and Receive result from command?
Message-Id: <Ey2960.298@news.boeing.com>

In article <35DD54A9.35A2@gianni.com>, 8\(F&@  <versace@gianni.com> wrote:
>Hi all,
>
>
>open (CMD, "|$CMD|");
>
>but received nothing using
> ...

perldoc IPC::Open2


HTH,
--
Charles DeRykus


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

Date: Fri, 21 Aug 1998 17:24:18 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: system commands
Message-Id: <35DDF391.A79EF20F@email.sps.mot.com>

I have the same problem awhile ago. Actually, as long as you have
'setup' search path located in the PATH variable (again, assuming it's
in UNIX) , system() will find it. Chances are that 'setup' is in fact an
alias with a fully qualified pathname, then you will have to either,

1) add the path for 'setup' onto PATH, or
2) use full pathname for 'setup' in system()

-TK

huntersean@hotmail.com wrote:
> >
> > #!/usr/local/bin/perl -w
> >
> > system "setup openingres2.0";
> >
> > exit;
> >
> Assuming unix, have you tried
> 
> #!/usr/local/bin/perl -w
> 
> system "csh", "-e, "which setup";
> 
> exit;
> 
> Basically,  you probably need an absolute pathname to "setup" to call it from
> perl.  Find it and put the whole path into your script.
> 
> Sean H
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Fri, 21 Aug 1998 18:25:19 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Test Post 1 - please ignore
Message-Id: <35DE01DF.94EBE06@email.sps.mot.com>

Ben Pavon wrote:
> 
> Doing a test. Had problems posting a reply.

Why not try post a valid 'question', I am sure you have some. Not trying
to be mean, but I just hate to see this ng turning into a posting
'test-site' - you are not the first one who did this.


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

Date: 22 Aug 1998 00:42:18 +0200
From: Terje Kvernes <terjekv@ifi.uio.no>
Subject: Re: Turn Perl program into binary
Message-Id: <wxx67fmneid.fsf@hel.ifi.uio.no>

"Lily Y. Fu" <lily@tigr.org> writes:

> Hi,
> 
> I have a perl program having password information in clear text.
> I want people to run the program but don't want them to
> know the password. If I make the program not readable by
> the user, it won't run.
> 
> Is there a way to "compile" the program into binary
> so that the password is not in clear text at least?

Uhm. Yes, there is a perl compiler. But:
 1) It's a beta still.
 2) I dont think it wouldn't help much.
    Programs like "strings" fetch strings from files. A compiled file
    still contains the literal strings you have enterd in he file.
    This is at least the case for C and Java, and I doubt it'll change
    with perl.

Hint:
Since your not running Windows, use crypt. Makes things so much safer.
And it isn't easy to get around...
 
> Thanks,

Anytime... =)
 
> -- 
> Lily Fu
> The Institute for Genomic Research
> Voice Mail: (301) 838-3557
> Email: lily@tigr.org

-- 
Terje Kvernes
http://www.stud.ifi.uio.no/~terjekv/


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

Date: Fri, 21 Aug 1998 18:07:57 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Turn Perl program into binary
Message-Id: <35DDFDCD.46FDFCEE@email.sps.mot.com>

> I have a perl program having password information in clear text.
> I want people to run the program but don't want them to
> know the password. If I make the program not readable by
> the user, it won't run.
> 
> Is there a way to "compile" the program into binary
> so that the password is not in clear text at least?
> 
> Thanks,

If you are in UNIX, just turn OFF everything but the x (executable)
permission. Then your user will be allow to run your script but not
reading or writing it.

That is, if you are in UNIX.

-TK


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

Date: Fri, 21 Aug 1998 23:29:08 GMT
From: maurice@hevanet.com (Maurice Aubrey)
Subject: Re: Turn Perl program into binary
Message-Id: <slrn6ts0m6.bp5.maurice@localhost.localdomain>

On Fri, 21 Aug 1998 18:07:57 -0500, Tk Soh <r28629@email.sps.mot.com> wrote:

>If you are in UNIX, just turn OFF everything but the x (executable)
>permission. Then your user will be allow to run your script but not
>reading or writing it.
>
>That is, if you are in UNIX.

Uh, no.  Scripts must be read.  Even in Unix.

-- 
Maurice Aubrey <maurice@hevanet.com>

 ... one of the main causes of the fall of the Roman Empire was that,
lacking zero, they had no way to indicate successful termination 
of their C programs.
  - Robert Firth


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

Date: 21 Aug 1998 23:09:09 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Utility for news article fetching selected by keywords ?
Message-Id: <6rkuml$p07$1@news.NERO.NET>

In article <m3d89ux454.fsf@windlord.Stanford.EDU>,
Russ Allbery  <rra@stanford.edu> wrote:
>Gildas Perrot <perrot@francenet.fr> writes:
>> Is there any tool to fetch in certain newsgroups, articles selected by
>> keywords ?
>
>No, I'm afraid that there is no tool that I know of, although as other
>people have pointed out you can probably construct your own tool using

Actually, there is a tool called "newsclip" that was written by Brad
Templeton, although I don't believe it was in perl. It isn't too hard
to write one of your own, even easier since the modules have come
along. 



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

Date: 21 Aug 1998 22:46:21 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: what is 'sub f () {555};'
Message-Id: <6rktbt$73c$2@news.iastate.edu>

Kevin Reid (kpreid@ibm.net) wrote:
: Josh Kortbein <kortbein@iastate.edu> wrote:

: > Abigail (abigail@fnx.com) wrote:
: > : Josh Kortbein (kortbein@iastate.edu) wrote on MDCCCXV September MCMXCIII
: > : in <URL: news:6rhvkr$bvv$6@news.iastate.edu>:
: > : ++ Steven Smith (steves@wco.com) wrote:
: > : ++ : I'm trying to understand a lib we pulled off of the net.  I've never
: > : ++ : seen this before.
: > : ++ : what would a sub declaration like this do??
: > : ++ 
: > : ++ : sub f () {555};
: > : ++ 
: > : ++ Have you tried it?
: > : ++ 
: > : ++ It looks to me like it returns 555, regardless of the argument
: > : ++ provided - which leads me to believe that it's either (a) useless,
: > : ++ or (b) capable of doing something else that I don't see. AFAIK,
: > : ++ though, it just returns 555.
: > : I guess you find
: > : # define f 555
: > : in C code useless as well?
: > 
: > No, but since I don't need to use C I prefer
: > 
: > const int f = 555;
: > 
: > in C++.
: > 
: > Despite the fact that constant subs have a use, I still don't
: > find them very useful - it's better IMO for code to just use
: > plain old scalars, as opposed to something that borders on
: > obfuscation.

: If the constant is defined before it is used, then it is optimized so
: that 

: if ($x == f) {

: is identical to

: if ($x == 555) {

: , and therefore is faster than a scalar variable.

In an environment like mine, where I have to write code that will
be read weeks or months later by someone with far less perl knowledge,
the tiny speed hit it worth it if the code is more readable.

Of course, the use constant pragma gives me the best of both
worlds. Why use constant subs myself, then? :)


Josh

-- 
I am the author of all tucks & damask piping
I am the Chrome Dinette
I am the Chrome Dinette
I am the eggs of all persuasion



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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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