[8743] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2360 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 18 18:17:38 1998

Date: Sat, 18 Apr 98 15:00:24 -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           Sat, 18 Apr 1998     Volume: 8 Number: 2360

Today's topics:
        a (root)
    Re: array of matches in s/// (Charles DeRykus)
        Artistic License (Derek B. Noonburg)
        ATTN: Netscape Enterprise for NetWare Admins: Is there  (BullDog)
        Child in separate window?  How? <NOSPAMkEynOn@panix.comNOSPAM>
        count number of lines in a text file <eslcafe@callisto.si.usherb.ca>
        EASY QUESTION: Replacing a line in a textfile <boliviaweb@prodigy.net>
    Re: EASY QUESTION: Replacing a line in a textfile <sowmaster@juicepigs.com>
    Re: Fastest "smallest power of 2 >= N" in Perl? <ljz@asfast.com>
    Re: Fastest "smallest power of 2 >= N" in Perl? <ljz@asfast.com>
    Re: Fastest "smallest power of 2 >= N" in Perl? <ljz@asfast.com>
        how do I install modules on win32? <"xuming "@ email.unc.edu>
    Re: how do I install modules on win32? <sowmaster@juicepigs.com>
    Re: i want to learn Perl. HELP! <doug@ccinet.com>
    Re: My macperl scripts don't shut down after 5 minutes  <eslcafe@callisto.si.usherb.ca>
    Re: Perl Oddity (Mark-Jason Dominus)
    Re: Perl Performace: CPU, and System Resource Usage. (Mark-Jason Dominus)
    Re: recursive fuctions <sneaker@earthling.net>
    Re: Server Side Include (David Jacoby)
    Re: Snobby news group (I R A Aggie)
    Re: Snobby news group (Greg Bacon)
    Re: Snobby news group (Jonathan Stowe)
    Re: Special characters (Mark Rogaski)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 18 Apr 1998 18:27:20 GMT
From: mike@ultimate.bene.baynet.de (root)
Subject: a
Message-Id: <slrn6jhs3l.6qj.mike@ultimate.bene.baynet.de>

sldcsl
>djc


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

Date: Sat, 18 Apr 1998 20:16:17 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: array of matches in s///
Message-Id: <ErMLn5.5By@news.boeing.com>

In article <353d677e.1712122@news.tornado.be>,
Bart Lateur <bart.mediamind@tornado.be> wrote:
 > Charles DeRykus wrote:
 >  [ omitted ...]
 > <GRIN> Fooled you. I purposely took this particular phrase as the
 > example, because the required order of the submatches is different in
 > French and English.
 >

I knew my lousy French would come back to haunt me one day :) 

 > But anyway, the cleanest way do to it with current Perl indeed seems to 
 > be, to do the matching twice, like you did.
 >
 >    if (my @matches = /^$key/) {
 >        s/^$key/&interpolate($translate{$key}, @matches)/e;
 >    }
 >
 > Except, of course, that now matching needs to be done twice. This isn't
 > very efficient, especially since we can't use the //o option, as we need
 > to test various phrases.


I just noticed though the substitution matching could be 
avoided since the pattern is the same, i.e., 

   if (my @matches = /^$key/) {
         s//&interpolate($translate{$key}, @matches)/e;
   }


--
Charles DeRykus


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

Date: 18 Apr 1998 14:27:21 -0700
From: derekn@aimnet.com (Derek B. Noonburg)
Subject: Artistic License
Message-Id: <m3wwcmkeh2.fsf@localhost.localdomain>

I'm not sure if this is the right place to post this -- I'll gladly
take suggestions of a better place.

I develop a free software package, which I'm considering moving to the
Artistic License.  I have a couple of questions I'd like to clear up
first, though.

(I don't want to quote the license here, since it's kind of long, so
I'll just refer to paragraph numbers.  The full text is at:
http://language.perl.com/misc/Artistic.html .)

What are the restrictions on using the Artistic License?  I know that
certain other freeware licenses only allow you to use them if you
don't make any modifications.  In particular, I'll need to remove
paragraphs 6 (scripts do not count as part of the package) and 7 (C
subroutines do not count as part of the package) as they're irrelevant
to my package, and replace them with something similar that exempts
the output of my package.

Paragraphs 3 and 4 are a little confusing.  It looks like 3 refers to
modifications (but not distribution), and 4 refers to distribution (of
unmodified and modified versions).  Is this the intent?

In particular, 3c says you can modify the program in any way you like,
as long as you both rename the new executable AND provide the original
executable AND provide clear documentation on the differences.  But 4c
says you only have to rename, provide clear documentation, and tell
where to get the original.  It's not a big deal, but I'm wondering
what the point is meant to be.

Thanks...

- Derek


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

Date: Sat, 18 Apr 1998 20:28:49 GMT
From: BullDog@USMC.Net (BullDog)
Subject: ATTN: Netscape Enterprise for NetWare Admins: Is there a port of Perl5 for Netware?
Message-Id: <35390b79.8051234@news.supernews.com>

Is there a port of Perl5 for Netware? If so, would you be kind enough
to tell me where I can get a copy of the NLM for the Novell Enterprise
server for NetWare?

Alternatively, how can I find out what version the existing Perl NLM
is?

I have my Perl stuff working beautifully on Enterprise for
NT/Perl5.003 and REALLY need to move it onto our Novell webserver.

HELP!

Please respond to mjs-NOSPAM-@cadvision.com (remove  -NOSPAM-  ), or
this group.

Thanks.


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

Date: 18 Apr 1998 16:13:14 GMT
From: k y n n <NOSPAMkEynOn@panix.comNOSPAM>
Subject: Child in separate window?  How?
Message-Id: <6hajeq$plj@news1.panix.com>
Keywords: fork, pipe



Does anyone know how I can fork out a child process with its own
separate X window, so that keyboard input will go to the parent or the
child depending on which window has the focus?

Thanks!

K.

-- 
To reply directly by e-mail, remove the upper-case letters from the
return address in the header.



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

Date: Sat, 18 Apr 1998 20:48:52 GMT
From: John Taylor-Johnston <eslcafe@callisto.si.usherb.ca>
Subject: count number of lines in a text file
Message-Id: <3304C798.7E7A@callisto.si.usherb.ca>

I need a simplified piece of script that will do this:

open a data file
read the number of lines of text
if number of lines of text exceed 50
delete a line

I've tore apart a few scripts that do this but seem a little confused on
the syntax. (My manuel is 50 miles away at my office.)
Please respond by e-mail

Thanks

John


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

Date: Sat, 18 Apr 1998 15:51:47 -0400
From: "Miguel Barrientos" <boliviaweb@prodigy.net>
Subject: EASY QUESTION: Replacing a line in a textfile
Message-Id: <6hb0b4$2sq0$1@newssvr04-int.news.prodigy.com>

I realize this is a very basic question, but I'm just starting.
How do I replace a line in a text file?

Miguel




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

Date: Sat, 18 Apr 1998 16:54:23 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Miguel Barrientos <boliviaweb@prodigy.net>
Subject: Re: EASY QUESTION: Replacing a line in a textfile
Message-Id: <353912FF.3525@juicepigs.com>

Miguel Barrientos wrote:
> 
> I realize this is a very basic question, but I'm just starting.
> How do I replace a line in a text file?

http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html

The best place to start is in the FAQs that you can easily find at the
URL above or of course your system if you have installed perl.

Please check the FAQs prior to posting and if you don't find your answer
there, folks in c.l.p.m will be happy to help.

HTH
-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


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

Date: 18 Apr 1998 11:31:18 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Fastest "smallest power of 2 >= N" in Perl?
Message-Id: <lt3efbuoxl.fsf@asfast.com>

abigail@fnx.com (Abigail) writes:

> [ ... ]
> 
> sub foo {
>     use integer;
>     my ($x, $y) = (shift, 2);
>     $y <<= 1 while $x >>= 1;
>     $y;
> }
> 
> sub bar {
>     use integer;
>    (my $x = unpack "B32", pack "N", shift) =~ s/^0+//;
>     1 << length $x;
> }
> 
> sub bar2 {
>     use integer;
>     1 << (32 - index unpack ("B32", pack "N", shift), 1);
> }

These are all good, but there's a slight problem with each of them:

   {foo,bar,bar2}(17) -> 32
   {foo,bar,bar2}(16) -> 32   <--- this should be 16
   {foo,bar,bar2}(15) -> 16

The following routines fix this, but I'm not sure if each of these is
how you would make the fixes, Abigail.  I will post a benchmark of
these plus all the others in a followup message in a few minutes.

sub foo_x {
    use integer;
    my ($x, $y) = (shift, 2);
    return (1) if ($x-- < 1);
    $y <<= 1 while $x >>= 1;
    $y;
}

sub bar_x {
    use integer;
    my $y = shift;
    return (1) if ($y-- < 1);
   (my $x = unpack "B32", pack "N", $y) =~ s/^0+//;
    1 << length $x;
}

sub bar2_x {
    use integer;
    my $y = shift;
    return (1) if ($y-- < 1);
    1 << (32 - index unpack ("B32", pack "N", $y), 1);
}


-- 
 Lloyd Zusman
 ljz@asfast.com


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

Date: 18 Apr 1998 11:55:30 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Fastest "smallest power of 2 >= N" in Perl?
Message-Id: <ltwwcnt98t.fsf@asfast.com>

"Igor Krivokon" <igork@pacbell.net> writes:

> Well, what about this:   
> 
>    f(N) = 1 << log(N-0.5)/log(2.0) + 1 
> 
> As far as I understand (from original post),  for N<=0 the function should
> return 1,
> (btw, why not 0?) 

Well, I realize now that I didn't state this explicitly, but I'm only
interested in powers of 2 that are integers.

I have run the benchmarks again with all of the following cases:

-- My slightly modified original.
-- Tom's original.
-- Tom's using subtraction and an 8-element array (called TOM8).
-- Tom's using a 56-element array (called TOM56).
-- Igor's
-- Carl's with the algorithm fixed (see variation_on_carls_version, below).
-- One which was emailed to me by Dean Inada.
-- Abigail's 'foo' routine with an algorithmic fix (called ABIGAIL1).
-- Abigail's 'bar' routine with an algorithmic fix (called ABIGAIL2).
-- Abigail's 'bar2' routine with an algorithmic fix (called ABIGAIL3).

Your algorithm is still the winner in speed, Igor.  Dean comes in
second, all of Tom's follow, and the rest of us bring up the rear.

I ran 8 iterations, each one passing all values from 0 through
(2^15 + 1) through each routine.

I ran this on my Pentium-Pro 200 mHz system which is running Red Hat
Linux 5.0.  I'm using Perl 5.004_04.

Here are the results, and my test program follows.

Benchmark: timing 8 iterations of ABIGAIL1, ABIGAIL2, ABIGAIL3,
                                  CARL1, DEAN, IGOR, LLOYD1,
                                  TOM56, TOM8, TOMORIG...

  ABIGAIL1: 12 secs (12.56 usr  0.00 sys = 12.56 cpu)
  ABIGAIL2: 13 secs (12.33 usr  0.00 sys = 12.33 cpu)
  ABIGAIL3: 14 secs (14.37 usr  0.00 sys = 14.37 cpu)
     CARL1: 15 secs (15.34 usr  0.00 sys = 15.34 cpu)
      DEAN:  7 secs ( 6.42 usr  0.00 sys =  6.42 cpu)
      IGOR:  5 secs ( 5.08 usr  0.00 sys =  5.08 cpu)
    LLOYD1: 12 secs (11.90 usr  0.00 sys = 11.90 cpu)
     TOM56:  7 secs ( 7.52 usr  0.00 sys =  7.52 cpu)
      TOM8:  8 secs ( 7.54 usr  0.00 sys =  7.54 cpu)
   TOMORIG:  8 secs ( 7.96 usr  0.00 sys =  7.96 cpu)

#!/usr/bin/perl -w
use strict;

sub lloyds_new_version {
    use integer;
    my $value = (shift) - 1;
    if ($value < 1) {
      return (1);
    }
    my $lastValue;
    do {
      $lastValue = $value;
    } while (($value &= ($value - 1)) != 0);
    return ($lastValue << 1);
}

sub toms_SmallestPowerOfTwoGE {
    use integer;
    my $a=sprintf("%o",(shift)-1);
    return 1<<(3*length($a)+(-3,-2,-1,-1,0,0,0,0)[ord($a)-48]) ;
}

my @longArray = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
		 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
		 3,2,1,1,0,0,0,0);
my @shortArray = (3,2,1,1,0,0,0,0);

sub variation_on_toms_short_array {
    use integer;
    local $[ = 48;
    my $a=sprintf("%o",(shift)-1);
    return 1<<(3*length($a)-$shortArray[ord($a)]);
}

sub variation_on_toms_long_array {
    use integer;
    my $a=sprintf("%o",(shift)-1);
    return 1<<(3*length($a)-$longArray[ord($a)]);
}

sub igors_smallestPowerOfTwoGE {
   return ($_[0] > 0) ? (1 << log($_[0]-0.5)/log(2.0) + 1) : 1;
}

sub variation_on_carls_version {
  use integer;
  my $x = shift;
  if ($x < 1) {
    return (1);
  }
  my $nbits = 0;
  $x--;
  while(($x>>=1) != 0) {
    $nbits++;
  }
  return 1<<(++$nbits);
}

# algorithm fixed ... called ABIGAIL1
sub abigail_foo_x {
    use integer;
    my ($x, $y) = (shift, 2);
    return (1) if ($x-- < 1);
    $y <<= 1 while $x >>= 1;
    $y;
}

# algorithm fixed ... called ABIGAIL2
sub abigail_bar_x {
    use integer;
    my $y = shift;
    return (1) if ($y-- < 1);
   (my $x = unpack "B32", pack "N", $y) =~ s/^0+//;
    1 << length $x;
}

# algorithm fixed ... called ABIGAIL3
sub abigail_bar2_x {
    use integer;
    my $y = shift;
    return (1) if ($y-- < 1);
    1 << (32 - index unpack ("B32", pack "N", $y), 1);
}

# Dean Inada
sub deans_smallestPowerOfTwoGE{
	use integer;
	my $value = shift;
	--$value;
	$value|=$value>>1;
	$value|=$value>>2;
	$value|=$value>>4;
	$value|=$value>>8;
	$value|=$value>>16;
	return ++$value;
}

my $top = (1 << 15) + 2;
my $bottom = 0;
my $iterations = 8;

sub run {
  my $routineRef = shift;
  my $result;
  my $n = $top;
  while ($n-- > $bottom) {
    $result = $routineRef->($n);
  }
}

use Benchmark;

timethese ($iterations, {

LLOYD1 => q{ run(\&lloyds_new_version) },

TOMORIG => q{ run(\&toms_SmallestPowerOfTwoGE) },

TOM8 => q{ run(\&variation_on_toms_short_array) },

TOM56 => q{ run(\&variation_on_toms_long_array) },

IGOR => q{ run(\&igors_smallestPowerOfTwoGE) },

CARL1 => q{ run(\&variation_on_carls_version) },

ABIGAIL1 => q{ run(\&abigail_foo_x) },

ABIGAIL2 => q{ run(\&abigail_bar_x) },

ABIGAIL3 => q{ run(\&abigail_bar2_x) },

DEAN => q{ run(\&deans_smallestPowerOfTwoGE) },
});

__END__



> so we get the following:
> 
> #!/usr/local/bin/perl -w
> use strict;
> 
> sub igors_smallestPowerOfTwoGE {
>    return ($_[0] > 0) ? (1 << log($_[0]-0.5)/log(2.0) + 1) : 1;
> }
> 
> sub toms_SmallestPowerOfTwoGE {
>     use integer;
>     my $a=sprintf("%o",(shift)-1);
>     return 1<<(3*length($a)+(-3,-2,-1,-1,0,0,0,0)[ord($a)-48]) ;
> }
> 
> use Benchmark;
> 
> timethese (2**16, {
> TOM   => q{ my $spot = toms_SmallestPowerOfTwoGE(31) },
> IGOR  => q{ my $spot = igors_smallestPowerOfTwoGE(31) },
> TOM1   => q{ my $spot = toms_SmallestPowerOfTwoGE(1 << 30) },
> IGOR1  => q{ my $spot = igors_smallestPowerOfTwoGE(1 << 30) },
> });
> 
> __END__
> 
> Benchmarks:
> 1) PC, Win95:
> Benchmark: timing 65536 iterations of IGOR, IGOR1, TOM, TOM1...
>       IGOR:  8 secs ( 7.25 usr  0.00 sys =  7.25 cpu)
>      IGOR1:  8 secs ( 7.28 usr  0.00 sys =  7.28 cpu)
>        TOM: 11 secs (10.12 usr  0.00 sys = 10.12 cpu)
>       TOM1: 11 secs (10.10 usr  0.00 sys = 10.10 cpu)
> 
> 2)UltraSPARC, Solaris:
> Benchmark: timing 65536 iterations of IGOR, IGOR1, TOM, TOM1...
>       IGOR:  2 secs ( 1.72 usr  0.00 sys =  1.72 cpu)
>      IGOR1:  2 secs ( 1.64 usr  0.00 sys =  1.64 cpu)
>        TOM:  3 secs ( 2.88 usr  0.00 sys =  2.88 cpu)
>       TOM1:  3 secs ( 2.89 usr  0.00 sys =  2.89 cpu)

-- 
 Lloyd Zusman
 ljz@asfast.com


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

Date: 18 Apr 1998 12:09:16 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Fastest "smallest power of 2 >= N" in Perl?
Message-Id: <ltra2vt8lv.fsf@asfast.com>

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

>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, 
>     Lloyd Zusman <ljz@asfast.com> writes:
> :The following algorithm (see below) returns the smallest power of 2
> :which is greater than or equal to a given integer.  For example:
> :
> :  smallestPowerOfTwoGE(15) -> 16
> :  smallestPowerOfTwoGE(16) -> 16
> :  smallestPowerOfTwoGE(17) -> 32
> 
> Look at the number in binary.  Find the first bit set.  If there are no
> other bits set, that's the number you want.  Otherwise, the number you
> want is the one with only the previous (one place left) bit set.

This looks a lot like the algorithm in the 'bar' or perhaps 'bar2'
routine posted by Abigail.  If so, it's not all that fast compared to
some of the other algorithms that have been suggested.

> You might see Programming Perl version 1 (magenta), page 211.

I don't have this book.  Can anyone post the algorithm on page 211 so
I can test it along with the others?

Thanks in advance.

-- 
 Lloyd Zusman
 ljz@asfast.com


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

Date: Sat, 18 Apr 1998 12:52:33 -0400
From: Xuming <"xuming "@ email.unc.edu>
Subject: how do I install modules on win32?
Message-Id: <6ham0e$i3p$1@fddinewz.oit.unc.edu>

I am new to perl, but I checked the FAQ and the readme file with a module
bundle, and I also searched Dejanews.  the most helpful info I got is:

====== CPAN FAQ ==========
The easiest way is to have the CPAN module do it for you. This module comes with
perl version 5.004 and
later. To manually install the CPAN module, or any well-behaved CPAN module for
that matter, follow these
steps: 

   1.Unpack the source into a temporary area. 
   2.    perl Makefile.PL
   3.    make
   4.    make test
   5.    make install

If your version of perl is compiled without dynamic loading, then you just need
to replace step 3 (make) with
make perl and you will get a new perl binary with your extension linked in. 

See MakeMaker for more details on building extensions. 
====================

(MakeMaker in the last line is a link but destination can't be found.)

there is a CPAN.pm file under my perl/lib dir, but how do I use it to install a
module bundle?  I don't have gzip or tar on my win95 for sure.  so if I run
'perl cpan.pm' it would just fail (error messages at the end of this post).  I
don't have a C compiler either.  so make won't run.  (I'm going to install VC5,
will that help?)

well, you see, I did my homework ...

any help would be highly appreciated.

Xuming Wang

============  error messages from 'perl cpan.pm' ==========
Fetching http://www.perl.com/CPAN/authors/01mailrc.txt.gz with LWP
Going to read C:\perl\lib\cpancache\sources\01mailrc.gz
Bad command or file name
Fetching http://www.perl.com/CPAN/modules/02packages.details.txt.gz with LWP
Going to read C:\perl\lib\cpancache\sources\02packag.gz
Bad command or file name
Fetching http://www.perl.com/CPAN/modules/03modlist.data.gz with LWP
Going to read C:\perl\lib\cpancache\sources\03mlist.gz
Bad command or file name
Can't locate object method "data" via package "CPAN::Modulelist" at (eval 7) lin
e 1.
        CPAN::Index::rd_modlist('CPAN::Index', 'C:\perl\lib\cpancache\sources\03
mlist.gz') called at C:\PERL\lib/CPAN.pm line 1975
        CPAN::Index::reload('CPAN::Index') called at C:\PERL\lib/CPAN.pm line 43
0
        CPAN::exists('CPAN=HASH(0x89f290)', 'CPAN::Module', 'LWP') called at C:\
PERL\lib/CPAN.pm line 1318
        CPAN::Shell::expand('CPAN::Shell', 'Module', 'LWP') called at C:\PERL\li
b/CPAN.pm line 454
        CPAN::has_inst('CPAN=HASH(0x89f290)', 'LWP') called at C:\PERL\lib/CPAN.
pm line 1469
        CPAN::FTP::localize('CPAN::FTP', 'MIRRORED.BY', 'C:\perl\lib\cpancache\s
ources\MIRRORED.BY', 'force') called at C:\PERL\lib/CPAN/FirstTime.pm line 235
        CPAN::FirstTime::init('C:\PERL\lib/CPAN/Config.pm') called at C:\PERL\li
b/CPAN.pm line 868
        CPAN::Config::load('CPAN::Config') called at C:\PERL\lib/CPAN.pm line 30
8
        require CPAN.pm called at C:\PERL\lib/CPAN/Nox.pm line 3
        CPAN::FirstTime::BEGIN() called at C:\PERL\lib/CPAN.pm line 0
        eval {...} called at C:\PERL\lib/CPAN.pm line 0
        require CPAN/Nox.pm called at C:\PERL\lib/CPAN/FirstTime.pm line 39
        CPAN::FirstTime::init('C:\PERL\lib/CPAN/Config.pm') called at cpan.pm li
ne 868
        CPAN::Config::load('CPAN::Config') called at cpan.pm line 308
BEGIN failed--compilation aborted at C:\PERL\lib/CPAN/Nox.pm line 3.


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

Date: Sat, 18 Apr 1998 14:06:41 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Xuming <"xuming "@ email.unc.edu>
Subject: Re: how do I install modules on win32?
Message-Id: <3538EBB1.BA4@juicepigs.com>

Xuming wrote:
> 
> I am new to perl, but I checked the FAQ and the readme file with a module
> bundle, and I also searched Dejanews.  the most helpful info I got is:

It really depends on which module you are looking for and what version
of perl you are running. The standard win32 version 5.004_02 ported by
Gurusamy Sarathy comes with many of the modules already installed.

Otherwise it is usually as simple as copying the modules components to
the right directories.

HTH
-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


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

Date: Sat, 18 Apr 1998 21:27:37 GMT
From: "Doug Evans" <doug@ccinet.com>
Subject: Re: i want to learn Perl. HELP!
Message-Id: <dV8_.288$3K.1131319@katana>

The quoted passage below, is exactly why I have installed The Perl Study
Forum...
http://www.icparts.com/perlforum

If you don't know what these terms mean, or you don't understand a statement
in one of the books, come to the Forum, go to the BBS, and ask. If enough do
that, and if enough "old timers", or slightly more advanced students answer
our questions, I will archive those answers, for future "newbies".

Doug Evans
A Newbie helping Newbies.

PS. I must say, I was somewhat amazed, yesterday, when I received a note
from Randall Schwartz, even if all he wanted to know, is *why*. If enough of
you use this tool, we can show him *why*.

D

>>Neither the Camel nor even the Llama makes any real concessions to the
needs
>>of beginning programmers.  In fact, both books appear to assume that the
>>reader already knows at least one programming language.  Many references
and
>>comparisons are made to C, a few less to awk, sed, and sh.  Here is a
quote
>>from the beginning of the Llama book (2nd Ed., p. 35):





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

Date: Sat, 18 Apr 1998 21:01:50 GMT
From: John Taylor-Johnston <eslcafe@callisto.si.usherb.ca>
Subject: Re: My macperl scripts don't shut down after 5 minutes as they are supposed to!
Message-Id: <3304CA9F.6CE3@callisto.si.usherb.ca>

Thanks for those who mailed me suggesting my posting a piece of script!

This is a twilight zone thing!

It doesn't seem to matter which type of script I use. - A simple text
screen-response or a more complicated script where I use a smpt server
to send a message.

All these scripts work fine, no glitches on a UNIX server.
I have thought of hosting to my UNIX server account, but will have to
give up the unix when I change jobs in July. This is why I am working on
getting a Mac server to work.

Could it be a memory thing on the server or is it the version or is it
the version I installed on the server?
I've enough experience with perl and a unix server ... but conversion
doesn't seem to be that easy.

Strange but true.

John


> OK - we know we are doing something wrong! My macperl apps don't shut
> down automatically after 5 minutes! And my server admin is in a tizzy.
> 
>         Most scripts are still running the next morning - sometimes it is the
> same ones over and over. (They are saved as cgi-scripts!?) What I don't
> understand is why can't I shut them down even when I double click on
> them, receive the menu to shut them down, and click on shut down from my
> station, in my directory! The sys admin has to do it himself. ... The
> next morning he arrives, looks in teh finder menu and sees 5 or 10
> macperl apps still running!  There must be a way to limit their time.
> 
>         (Don't they shut down automatically? Can I programme perl to shut tehm
> down immedaitely after use? This is what pisses off my sys admin!)
> 
> MORE INTERESTING
> From time to time, I get response from netscape that says that "The
> document contains no data". It seems to be these that cause the trouble.
> I rename them, (try to) erase them or otherwise and resave the app with
> my back up file - this seems to overcome the problem - sometimes.  (I
> have run the check syntax and ran the perl app before I try testing it
> from the net.)
> 
> I'm wondering if I should save my apps as perl droplets, but they don't
> seem to work.
> For the moment my sys admin :-( has banished macperl from the main
> server to another IP where I am to test and solve the problem with
> macperl before he lets Macperl back in!
> 
> (I'm using Webstar 1.0 on a power mac. System 7, soon to be udated to
> sys 8 and web star 3)
> 
> Thanks!


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

Date: 18 Apr 1998 14:19:04 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Perl Oddity
Message-Id: <6haqqo$5na$1@monet.op.net>
Keywords: Appleton debutante fifteen Galt

In article <6h7trm$s7u@fridge.shore.net>, Grinch <grinch@whoville.com> wrote:
>No need to keep posting over and over... We get the idea.

This article superseded an earlier article with the wrong URL.


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

Date: 18 Apr 1998 13:29:14 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Perl Performace: CPU, and System Resource Usage.
Message-Id: <6hanta$5gr$1@monet.op.net>
Keywords: congestion fragrant roadbed stargaze

In article <9SEO1IIelgmP092yn@netins.net>,  <phdss@netins.net> wrote:
>Any faqs or articles discussing perl system performance?  Speed tips
>and other related matters?

You might want to look at Mike Lee's document about optimization.
It's ostensibly about C, but most of the techniques and strategioes it
discusses are language-neutral.

In particular, anyone interested in optimization should have the
introduction and `gotchas' sections memorized by heart.


	<URL:http://www.ontek.com/mikey/current.html>



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

Date: Sat, 18 Apr 1998 18:36:41 GMT
From: Bill 'Sneex' Jones <sneaker@earthling.net>
Subject: Re: recursive fuctions
Message-Id: <3538F120.CC1E9C7C@earthling.net>

Kevin B Cohen wrote:

> >On Wed, 15 Apr 1998, Byron Jones wrote:
> >
> >> i want to write a perl script that renames files to 8.3, creating unique
> >> names as needed.  the function needs to process subdirectories recusively.
>
> one thing i was surprised (though i guess i shouldn't have been) to
> discover recently is that if you use strict (as you do in the script
> you posted), my'd variables in main are not accessible by subroutines
> called by main, and must be passed to them if you want the subs to
> have their data.  makes sense, i guess-- i just expected main to be
> different from a subroutine.  guess i was wrong.
>
> i don't have nigel chapman's book "perl: the programmer's companion"
> handy, but i believe it talks about recursive functions.
>
> kevin

 I believe you have 'extern' C-like functionailty mixed up with Perl's scoping.
To help, I took the liberty of resurrecting an old Tom Christiansen post which
helped someone else who was thinking along similar lines:

##### Begin tchrist post:  Note that the THEN Subject line was
'Externing a vaiable in perl':

Here's a sample template. Call it Frobniz.pm and make it mode 0644.

    package Frobniz;
    use strict;

    require Exporter;
    use vars qw(@ISA @EXPORT @EXPORT_OK);
    @ISA        = qw(Exporter);
    @EXPORT     = qw(&func);
    @EXPORT_OK  = qw($avar %hishash);

    use vars qw($avar %hishash @mybits)
    $avar    = "stuff";
    %hishash = ();

    @mybits = 1 .. 10;

    my $start       = time();

    sub func        { return $start }
    sub sphunk      { return (&func - 300) }

    1;

The following are package globals in Frobniz

    Exporter-related stuff: @ISA @EXPORT @EXPORT_OK
    Always exported: &func
    Exported if requested: $avar %hishash
    Not exported, but available with Frobniz notation: @mybits &sphunk

The following variable is not reachable from outside this file,
because it is not a package global in the symbol table: $start

######## End of tchrist post ################

HTH,
Sneex :-)



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

Date: 18 Apr 1998 17:45:13 GMT
From: jacoby@harbor.ecn.purdue.edu (David Jacoby)
Subject: Re: Server Side Include
Message-Id: <6haor9$n0n@mozo.cc.purdue.edu>

In article <3537A2BA.9D6FB05B@acc.umu.se>,
N i c l a s O l o f s s o n  <gurun@acc.umu.se> wrote:
>Jerry wrote:
>> Is there any way to write one line in HTML that will run a PERL script
>> that just prints part of a web page?  I'm not interested in having the
>> entire page CGI..
>> 
>> E-Mail me if you have any insite.
>> 
>> Thanx in advance.

>If your server is capabel of doing SSI (Apache for eq) just put in the
>following (one:) line...
>
><!--#include file="abigailcouldnotanswerit.html" -->

That would put in an existing HTML file. If you want to generate the
page via CGI, you use

<!==#exec cmd="/path/to/the/cgi/script/you/are/using.cgi" -->

>If you want to read more about SSI go to this article at "Apache
>Week"...
>http://www.apacheweek.com/features/ssi.html

Yeah, that looks like a good site to read.

>Cheers,
>/Niclas


-- 
 David Jacoby                              mailto:jacoby@ecn.purdue.edu
 Web Technician and Librarian     http://harbor.ecn.purdue.edu/~jacoby/
 Engineering Computer Network   Writing software is more fun than work!
------------------------------------------------------------------------


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

Date: Sat, 18 Apr 1998 15:41:56 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Snobby news group
Message-Id: <fl_aggie-1804981541560001@aggie.coaps.fsu.edu>

In article <6h8qin$3qr@acme.sb.west.net>, jbc@west.net (John Callender) wrote:

+ "Screw 'em if they can't understand it," is the attitude of some longtime 
+ participants here. Personally, I find that attitude kind of sad.

You're mistaken. Badly.

The attitude is more accurately stated as "you won't use the index
in a book, you won't search the on-line documentation, you won't
use 'perldoc perlfaq' but instead depend upon some kind-natured
soul on Usenet to answer your question that is answered in the
afore mentioned resources? then you get what you deserve."

If they're not willing to put in some effort to figure out their
problems, then why should anyone else be expected to put in
any more effort than what the questioner has already expended?

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>


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

Date: 18 Apr 1998 20:16:45 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Snobby news group
Message-Id: <6hb1nd$i30$1@info.uah.edu>

In article <6h8qin$3qr@acme.sb.west.net>,
	jbc@west.net (John Callender) writes:
: Sure, there 
: would still be the current crop of lazy bastards who would bug the gurus 
: with their rude intrusions, but there might very well be a critical mass 
: of polite, earnest newcomers who would use the newbie group to good effect.

I see two problems with a ``newbie'' group:

    1) The potential for spread of misinformation is great.
    2) It's unlikely that many expert level users will be willing to
       participate in the group.

: A *lot* of people with no programming background are learning Perl for 
: Web (and other) purposes.

Everyone must learn somewhere.  However, you must consider that the
expert participants in a newsgroup for the discussion of brain surgery
would be similarly hostile to ``accidental neurosurgeons'' who lack the
necessary training to practice their craft.  This would be the case
whether or not there were some Whiz-Bang Scalpel [tm] that made brain
surgery a snap.

: Like it or not, Larry has made the perfect 
: "gateway drug" for programming addiction: making the easy things easy not 
: only means you veterans can whip up awesome applications in no time, but 
: also that Biff can figure out how to print "hello world!\n" without even 
: buying an O'Reilly book (or learning what a man page is).

I suspect that this is a byproduct of the influx of non-programmers,
unaccustomed to the art of manual reading--an art learned and perfected
through years of study and training.

: As one of those accidental programmers, I would really appreciate a forum 
: where I could discuss questions along the lines of "how do I do X with 
: Perl?" without having to worry if X is something Perl-specific, or is 
: merely something that any beginning programmer has to learn about, 
: regardless of the language he or she is learning with.

Such a broad topic is impractical for a forum like Usenet.  One reason
for having so many different discussion groups is to increase the
density of people interested and well versed in specific topics around
common reference points.  However, there is nothing stopping anyone
from asking the group how to implement a particular algorithm in Perl.
Contrast this with the much less researched question of ``How do I
express task X in Perl?''.

: Yes, the FAQs and man pages are a great resource. Yes, any beginning 
: programmers trying to cut their teeth on Perl should contribute to the 
: Larry Wall/Randal Schwartz/Tom Christiansen Retirement Fund by buying the 
: Llama and the Camel. But the reality is that all those resources are 
: pitched over the heads of many beginners.

Both of these resources were written with a certain audience in mind,
namely programmers.  Would you be upset if you read a book on auto
repair targeted at auto mechanics?

: "Screw 'em if they can't understand it," is the attitude of some longtime 
: participants here. Personally, I find that attitude kind of sad.

I find it hard to believe that this is the attitude of clpm's longtime
participants.  I've exchanged email and met in person with many of them,
and the common thread among most (if not all) is a strong desire to help
people (for maybe only a warm fuzzy or two in return).  I think a more
accurate way to phrase the frustrated attitudes of many regulars is
``screw 'em if they won't help themselves or are just looking for a
handout''.

: I have no illusions that a newbies group would fly even if someone could 
: be found to champion it; the political climate of this group has become 
: so anti-newbie that I'm sure it would never be voted in. Which is a 
: shame, given the many neat things about Perl from the standpoint of a 
: beginning programmer.

Again, I think it's unfair to say that clpm is anti-newbie.  The
perception (if not the reality) is that 99% of newbies are asking FAQs
and subjects covered in the docs that so many have worked so hard to
create or are just looking to freeload.  I feel safe in saying that
yes, clpm is very anti-freeloader.  It's just that the set of freeloaders
and the set of newbies aren't very mutually exclusive. :-/

This really isn't a clpm-specific problem, though.  Usenet is growing at
an enormous rate, and these symptoms are likely to be growing pains.
The solution to the problem might lie back at the local level.  If you
quizzed new posters to any newsgroup, how many do you think would know
what news.announce.newusers is?  Go back, say, five years.  What do you
think the numbers would have been then?  When Usenet (and the whole
Internet) was much smaller and more intimate, it was much easier for
admins and ISPs to keep an eye on their users and to provide a gentle
nudge when netiquette was violated.  This is certainly not the case now.

The solution to many of our problems is accountability.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Fri, 17 Apr 1998 02:35:30 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Snobby news group
Message-Id: <3536815e.18870911@news.btinternet.com>

On Fri, 17 Apr 1998 10:09:11 -0700, "Database Coder"
<dbcoder@juno.com> wrote in comp.lang.perl.misc:

>Why is this such a snobby unhelpful news group. I have posted in many other
>news groups and always recieved polite and helpful responses. This news
>group is the exception. The amount of time you people spend asking people if
>they read the FAQ or bought a good book on PERL could have been spent
>helping the person.
>
OK Lets set the record straight here for the viewers:

This your record of postings from Deja News:

216 unique articles posted. 
     Number of articles posted to individual newsgroups (slightly
skewed by  cross-postings): 
                                                           
          53 rec.boats 
          38 comp.soft-sys.powerbuilder 
          26 rec.woodworking 
          19 rec.outdoors.fishing.saltwater 
          16 comp.sys.ibm.pc.games.strategic 
          8 comp.publish.cdrom.hardware 
          6 rec.boats.electronics 
          5 ba.market.computers 
          4 alt.forsale 
          4 sci.engr.joining.welding 
          3 alt.games.redalert 
          3 ca.driving 
          3 comp.lang.perl.misc 
          2 alt.computer.consultants 
          2 alt.games.command-n-conq 
          2 rec.models.railroad 
          1 5col.forsale 
          1 alt.cars.ford-probe 
          1 alt.comp.periphs.cdr 
          1 ba.market.computer 
          1 ba.market.vehicles 
          1 comp.dcom.isdn 
          1 comp.infosystems.www.browsers.ms-windows 
          1 comp.lang.java.programmer 
          1 comp.sys.ibm.pc.games.marketplace 
          1 misc.forsale.computers.monitors 
          1 rec.autos.4x4 
          1 rec.autos.misc 
          1 rec.outdoors.fishing.bass 
          1 rec.outdoors.rv-travel 
          1 sci.bio.fisheries 
          1 tx.jobs

Now  if this is (as I suspect ) a true record of your interests then
Perl comes slightly behind "welding": a practice I have never engaged
in despite being forced to metalwork at school for three years all
these years ago.  When the garden gate comes off its hinges and Mrs
Gellyfish starts giving me a hard time to fix it I'm going to post to
sci.engr.joining.welding right?

Snobby?  Lets take at random and completely out of context of course
something from rec.boats:

>In <6h0i9c$8fu@jake.bga.com>, ref@bga.com (ref) writes:
<snip>
> >Yes, and it just reinforces the image of Bayliner owners as being
> >the boating equivalent of K-Mart shoppers.

(Of course i may have got the attribution totally wrong as someone
seems to have made a virtue out of over quoting in the thread)
 
c.l.p.m Snobby ?  

Now lets say I want to take a trip to France.  I wonder what the
response would be if I posted to rec.boats asking for the times of the
Ferries (I did actually, just for fun and in total defiance of
netiquette - but got no response after two hours so I guess they're
just too ... <blah blah invective deleted>). 

You see its a matter of culture really isnt it.

As to the precursor to your tirade:

Database Coder wrote in message <6h382h$49p$1@news.scruz.net>...

>I wrote a small perl script that uses mailx to send email. The body of the
>message is read from a text file. When the message is received the first
>line of the body contains "Content-Length:  805" even thought the string
>that contains the body text at the time it is sent to mailx does not contain
>that line. Is there a way to get rid of it?

I believe that the response you got from [Gg]rinch was in fact quite
useful and appropriate in response to a question that was obviously
unrelated to the topic of this newsgroup,  that from Abigail was
perhaps terse and sarcastic (and not a lttle humorous), but hey if you
had read the group a little more and tried to understand the culture
you might have expected that response  .

Of course we all are a bunch of Bay-Liner bashing er sorry Newbie
bashing elitists, but then who can refuse a turkey shoot ?  

Apologies to those in rec.boats who might have got upset at the joke.

Oh before any tit for tat starts here is my author profile from Deja
News

     224 unique articles posted. 
     Number of articles posted to individual newsgroups (slightly
skewed by  cross-postings): 


          155 comp.lang.perl.misc 
          14 comp.os.linux.networking 
          11 comp.lang.javascript 
          8 comp.infosystems.www.servers.ms-windows 
          8 comp.lang.c++ 
          7 comp.lang.c 
          4 comp.infosystems.www.servers.unix 
          2 alt.comp.virus 
          2 comp.infosystems.www.authoring.cgi 
          2 comp.infosystems.www.authoring.html 
          2 comp.mail.sendmail 
          2 comp.unix.amiga 
          1 alt.california 
          1 alt.fan.tank-girl 
          1 comp.infosystems.www.servers.misc 
          1 comp.os.linux.misc 
          1 comp.os.linux.setup 
          1 comp.text.pdf 
          1 comp.unix.programmer 


Just to set the record straight..

<Follow-Ups set>

/J\  
 
Jonathan Stowe
See the MetaFaq at http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm


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

Date: 18 Apr 1998 20:55:23 GMT
From: wendigo@deathstar.jabberwock.org (Mark Rogaski)
Subject: Re: Special characters
Message-Id: <slrn6ji4pt.rkh.wendigo@deathstar.jabberwock.org>

Brian Katz <bdkatz@collins.rockwell.com> wrote:
: Greetings everyone.  I have to convert some old files which were
: written on a vax and have these line-feed characters which translate
: on UNIX into ^M.  I would like to be able to s/^M/ / or s/\^M/ /  for
: these annoying things, but it appears no go.  (Like \n, \t, etc., ^M is
: acting like a single character...for instance vi treats it as a single
: char.
: 

Try "\r".

Mark


-- 
[] Mark Rogaski                   "That which does not kill me
[] wendigoNO@SPAMpobox.com              only makes me stranger."
[] finger wendigoNO@SPAMdeathstar.jabberwock.org for PGP key
[] remove NO & SPAM to reply or finger
[] anti spambot: postmaster@localhost abuse@localhost uce@ftc.gov


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 2360
**************************************

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