[10407] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4000 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 17 23:02:07 1998

Date: Sat, 17 Oct 98 20:00:18 -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, 17 Oct 1998     Volume: 8 Number: 4000

Today's topics:
    Re: Are there any "perl.newbie" group or forum? (Joergen W. Lang)
    Re: Are there no PERL experts out there?? Is there no o (Alastair)
    Re: ARGV and Use of uninitialized value <gellyfish@btinternet.com>
    Re: array references <gellyfish@btinternet.com>
    Re: Counting URLs <gellyfish@btinternet.com>
    Re: How to write a recursive function <gellyfish@btinternet.com>
    Re: I'm new, but know what I need (Joergen W. Lang)
    Re: matching variables out of list arrays (David Alan Black)
    Re: matching variables out of list arrays <gellyfish@btinternet.com>
    Re: Memory problems <gellyfish@btinternet.com>
    Re: Off topic: is he that Larry Wall? (Joergen W. Lang)
    Re: PERL and SQL (Linux) (Alastair)
    Re: Perl routine needed. (Michael Budash)
    Re: Perl routine needed. (Alastair)
        Perl Training in Orange County ssteves@pacbell.net
        Perl, dynamic loading, SCO OS 5 (Darrell Styner)
    Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has regi (Joergen W. Lang)
    Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has regi <eashton@bbnplanet.com>
    Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has regi <eashton@bbnplanet.com>
        Reading inary Files :: dbase headers tory1@mail.idt.net
    Re: Recover ref from string <gellyfish@btinternet.com>
    Re: Search Engine Question <gellyfish@btinternet.com>
    Re: send geroge reese (was Re: Call for Participation:  (Alastair)
    Re: Slow Sort? <gellyfish@btinternet.com>
    Re: sub and return (Tad McClellan)
    Re: sub and return (Tad McClellan)
    Re: Unzip with Perl <gellyfish@btinternet.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sat, 17 Oct 1998 21:04:57 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <1dh205q.uhvcwt7afmqfN@host052-210.seicom.net>

Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:

> > Perl is _not_ just for breakfast anymore!
> 
> Yes, and the day it makes dinner for me my life will be complete. :)
> 
> e.

Something along the line of
    use FOOD::DINNER qw(candle_light);
would be very nice. ;-)

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: Sun, 18 Oct 1998 00:41:00 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Are there no PERL experts out there?? Is there no one who can solve this??
Message-Id: <slrn72ii19.85.alastair@calliope.demon.co.uk>

Lloyd Zusman <ljz@asfast.com> wrote:
>
>If you have a pre-conceived notion that no one ever expresses
>gratitude in c.l.p.misc, then you are likely to overlook the many

No, you missed the point. Matt was not holding any 'pre-conceived notion'. I
appreciate your mastery of the statistics for your news spool though :)



-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: 18 Oct 1998 00:17:19 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: ARGV and Use of uninitialized value
Message-Id: <70b8hv$co$1@gellyfish.btinternet.com>

On Fri, 16 Oct 1998 20:52:35 GMT mike_allen@my-dejanews.com wrote:
> Hello,
> 
> Why does the following:
> 
> #!/usr/bin/perl -w
> 
> $ARGV[0] =~ s/,//;
> if( $ARGV[0] ) {           < error here
>     print "$ARGV[0]\n";
> }
> 
> produce:
> 
> $ temp.pl
> Use of uninitialized value at ./temp.pl line 4
> 
> if passed no arguments, but:
> 
<etc>

You can remedy this by using:

$ARGV[0] && $ARGV[0] =~ s/,//;

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: 18 Oct 1998 00:41:20 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: array references
Message-Id: <70b9v0$dp$1@gellyfish.btinternet.com>

On Sat, 17 Oct 1998 18:40:18 GMT Rick Delaney <rick.delaney@shaw.wave.ca> wrote:
> [posted & mailed]
> 
> nguyen.van@imvi.bls.com wrote:
>> 
>> Hi guys,
>> 
>> I want read a file with each line is assigned as an array reference 
>> and also want to print out all of them. Please give me a general 
>> format.
> 
> perldoc perllol
> 

Agreed, but just for fun lets just play with this little example:


#!/usr/bin/perl

open(PWD,"/etc/passwd") || die "Blah ... ";

while(<PWD>)
{
   chomp;
   push @array, [split /:/] ;
}

foreach (@array)
{
  print $_->[4],"\n";

}
__END__

Thats as easy as it comes.

But go read perlol anyhow.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: 17 Oct 1998 23:14:53 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Counting URLs
Message-Id: <70b4st$ad$1@gellyfish.btinternet.com>

On Fri, 16 Oct 1998 09:11:52 -0700 Larry Rosler <lr@hpl.hp.com> wrote:

<snip>
> 
> You might try using HTML::Parser, but I have no experience with it and 
> don't see why it should be faster than your naive approach (naive 
> because it might find all kind of false matches in HTML comments and 
> ALT= string, but I doubt that you care).
> 
Almost certainly slower but almost certainly more accurate (however one
might want to exclude certain types of url:


#!/usr/bin/perl

package CountUrls;

@ISA = qw(HTML::Parser);
require HTML::Parser;
use strict;

use vars qw($urls);

my $parser = new CountUrls;

$urls = 0;

$parser->parse_file($ARGV[0]);

print $urls,"\n";

sub start()
{
   my($self,$tag,$attr,$attrseq,$orig) = @_;
   if ( $tag eq 'a')
     {
        if ($attr->{href})
          {
           $urls++;
          }
     }
}
__END__

If only HTML::Parser was a piece of commercial software - think of all that
commission ;-}

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: 18 Oct 1998 01:57:46 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: How to write a recursive function
Message-Id: <70beea$je$1@gellyfish.btinternet.com>

On Sat, 17 Oct 1998 09:49:16 GMT Dan Lucas <dlucas@removethisgol.com> wrote:
> 
> I am trying to write a script which uses a recursive function which 
> walks through a directory tree and does something to each file. I have 
> written something gives strange results, often deciding that a file is 
> a directory and vice versa.
> 
> I have appended the script to this message; any pointers to what I have 
> done wrong would be much appreciated.

The problem is that you get all thinged up with your directory handles being
globals like all other filehandle type things.

You have several choices:

use File::Find;

stash your directories away as you go and open them later.

 .

I have used this bit of code which someone said was unnecessary but I cant
remember why:


#!/develop/bin/perl

use DirHandle;

dodir("/DOS/htdoc");

sub dodir()
{
   local $dir = shift;

   my $dirhandle = new DirHandle($dir);

   if($dirhandle)
     {
      while($file = $dirhandle->read)
        {
          next if ($file =~ /^\.{1,2}$/);
          local $fullpath = $dir . "/" . $file;
       
          if (-d $fullpath)
            {
             dodir($fullpath);
            }
          else
             { 
              print $fullpath,"\n";
             }
         }
     }
}
__END__

I must admit that this was due to my remembrance of doing similar thing in
C but there you go.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Sat, 17 Oct 1998 21:05:19 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: I'm new, but know what I need
Message-Id: <1dh225t.5vdvjhb610vtN@host052-210.seicom.net>

Dominic <forgetit@usadowntheloo.com> wrote:

> Hello
> 
> First, sorry if this kind of post has appeared many times before. I'm
> new and not sure of the "status" of this kind of post.
> 
> I'd like some help:
> 
> Sites giving an overview of the perl language instruction set.

Wouldn't 

http://www.perl.com or 
http://www.perl.org

be nice addresses for such a website ? Try them, and if you already have
perl, look for something named "perlfunc" and "perlop" on the machine
your perl is installed on.

> A site showing a "how to" of getting a script to pass the information it
> collects from the form off the Web page and to invoke a .exe
> program.(which uses it)

see above.

hth,

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: 17 Oct 1998 20:07:43 -0400
From: dblack@pilot.njin.net (David Alan Black)
Subject: Re: matching variables out of list arrays
Message-Id: <70bbgf$9tk$1@pilot.njin.net>


ok1ago@aol.com (Ok1aGo) writes:

>I would like to know how to match
>if ($blabla eq $whatever) this is ok 

>BUT: how to exclude whenever a PART variable matches
>I would like to know the code, similar to 
>if ('blabla" eq " /^blabla/") but for variables out of a list array


Huh?

David Black
dblack@pilot.njin.net


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

Date: 18 Oct 1998 01:32:55 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: matching variables out of list arrays
Message-Id: <70bcvn$gj$1@gellyfish.btinternet.com>

On 17 Oct 1998 06:36:57 GMT Ok1aGo <ok1ago@aol.com> wrote:
> I would like to know how to match
> if ($blabla eq $whatever) this is ok 
> 
> BUT: how to exclude whenever a PART variable matches
> I would like to know the code, similar to 
> if ('blabla" eq " /^blabla/") but for variables out of a list array

I would say that that is what grep is for:

if (grep /$whatever/, @array )
{
  # etc
}

Of course this is discussed in the FAQ so dont believe me

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: 18 Oct 1998 00:07:29 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Memory problems
Message-Id: <70b7vh$bb$1@gellyfish.btinternet.com>

On Sat, 17 Oct 1998 12:12:18 -0700 Adam Morgan <amorgan@vsol.com> wrote:
> Does anyone know how to monitor memory use in Perl? I keep running out.
> 

Whaddya mean ?

You can use top or sar or your taskmgr or whatever.

Alternatively you could show us the code that you find problems with
'cause there's almost certainly a more memory efficient way to achieve
what you want to do.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Sat, 17 Oct 1998 21:05:22 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: Off topic: is he that Larry Wall?
Message-Id: <1dh23vp.pbafm15iyg2xN@host052-210.seicom.net>

I R A Aggie <fl_aggie@thepentagon.com> wrote:

> In article <708mph$836@kiev.wall.org>, larry@kiev.wall.org (Larry Wall) wrote:
> 
> + In article <3627846E.DDE5D443@hotmail.com>, feng  <j9feng@hotmail.com>
> + wrote: > Is he the Larry Wall who fathered Perl?
> + 
> + That's the polite way to put it.  :-)
> 
> Well, its not like you disowned the little bambino at v1.0...
> 
> James

Who might be the mother ? 
Or did Perl come into this world by something like "sprouting" ?

Or was it the virgin Lary ?
 ;-))

Who knows....

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: Sun, 18 Oct 1998 01:06:25 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: PERL and SQL (Linux)
Message-Id: <slrn72ijgu.85.alastair@calliope.demon.co.uk>

Nico <info@edoc.co.za> wrote:
>Hi,
>
>I must expand my PERL horizon to SQL.
>
>I'm Running Linux, and would like to know if there is somewhere a
>FAQ/HowTo or similar?
>
>Or could somebody give me a good start?

Look for things like - PostgresSQL, MySQL, mSQL, DBI etc.

PostgresSQL : http://postgresql.axon.legnica.pl/

(don't know how I ended up with a Polish mirror!)

MySQL : http://www.tcx.se/
mSQL  : http://www.Hughes.com.au/

DBI   : http://www.hermetica.com/technologia/perl/DBI/
CPAN  : http://www.cpan.org

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Sat, 17 Oct 1998 17:31:38 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Perl routine needed.
Message-Id: <mbudash-1710981731380001@d23.nas1.napa.sonic.net>

In article <70bab7$tp6$1@node17.cwnet.frontiernet.net>, "Waylen"
<waylen@ntx.com> wrote:

>> Any perl gurus out there who can help me with a sub routine
>> for a script. I need a sub routine for customshipping.pl
>> which can be seen at
>> http://www.securecommerce.com/ss6d7/cgi-bin/shoppro/customshipping.pl
>> What is needed is a minimum shipping charge of $5.00
>> and a cap of $20.00 in addition to the percentage that is
>> generated by the cgi program....
>> http://www.securecommerce.com/ss6d7/cgi-bin/shoppro/shoppro.cgi
>> The config file is at
>> http://www.securecommerce.com/ss6d7/cgi-bin/shoppro/shoppro.cfg
>> As is obvious I am no programmer.
>> Any takers?
>> Thanks!

if i understand what you're asking for (and i'm not sure i do!), this
should do it:

  if ($customShippingCost < 5.00) {
   $customShippingCost = 5.00;
   }
  elsif ($customShippingCost > 20.00) {
   $customShippingCost = 20.00;
   }

put these lines immediately before the line:

  return $customShippingCost;

hth-

-- 
Michael Budash ~ Michael Budash Consulting
707-255-5371 ~ 707-258-7800 x7736
mbudash@sonic.net


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

Date: Sun, 18 Oct 1998 00:49:23 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Perl routine needed.
Message-Id: <slrn72iih0.85.alastair@calliope.demon.co.uk>

Waylen <waylen@ntx.com> wrote:
>Any perl gurus out there who can help me with a sub routine
>for a script. I need a sub routine for customshipping.pl

A lot of people won't bother looking at your code (from your links) because
they're too busy (perhaps). You might want to look at hiring a contract
programmer or, even better, teach yourself how to program Perl. It's almost
certainly not as hard as you think.

Good luck.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Sat, 17 Oct 1998 18:17:47 -0800
From: ssteves@pacbell.net
Subject: Perl Training in Orange County
Message-Id: <36294F92.20271729@pacbell.net>

Howdy..

Is there anyone who is doing Perl training in Orange County California. If so
I have a couple of students for you. Please comment, with particulars,
directly to steve@viking.ez.net.

Many thanks.


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

Date: Sat, 17 Oct 1998 18:57:42 -0500
From: dstyner@telalink.net (Darrell Styner)
Subject: Perl, dynamic loading, SCO OS 5
Message-Id: <dstyner-1710981857420001@dial1-dyn5-59.bna.telalink.net>

I can't get Perl (latest version: 5.005_02) to compile in such a way as to
support autoloading of modules. I'm using the SCO OpenServer Development
System (ver 5.1.0Ac) under OpenServer 5.0.4p with release supplement
504.0.1.a. Perl builds and runs just fine, but when I try to run a script
that uses DB_File.pm I get:

"Can't load module DB_File, dynamic loading not available in this perl.
(You may need to build a new perl executable which either supports dynamic
loading or has the DB_File module statically linked into it.)"

I've tried to do both, but haven't had any luck (I get failed links and
core dumps). Does anyone have a clue as to how to get this to work? It
seems like there must be other people using SCO systems as web servers who
need this functionality.

-- 
Darrell Styner
dstyner@telalink.net


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

Date: Sat, 17 Oct 1998 21:05:07 +0100
From: jwl@_munged_worldmusic.de (Joergen W. Lang)
Subject: Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <1dh214n.3egl5810ei4j1N@host052-210.seicom.net>

Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com> wrote:

> Adam Turoff wrote:
> 
> >         Then the llama was ported to windows.  What do we get?
> >         A cold blooded lizard called a gecko.
> > 
> > Roast gecko stays on the menu.  I wouldn't mind armadillos crawling
> > around the room or barbequed moose, grilled squid, marinated horseshoe
> > crabs, etc.  (I draw the line at any of the Oracle bugs, or the
> > canine/feline Windows animals.)
> 
> Hmmm. I can see it now, I'll hire a friend of mine who is a gourmet chef
> in vail, have a menu where each entree' is an O'Reilly animal, save for
> the few not quite so appetizing ones. Hmmmm. I'm going to have to pitch
> this to a biz friend this weekend and see if it would fly. I've always
> wanted my own pub. :)
> 
> e.

And the menu is written in Perl, of course.

Joergen
-- 
  To reply by email please remove _munged_ from address Thanks !
-------------------------------------------------------------------
   "Everything is possible - even sometimes the impossible"
             HOELDERLIN EXPRESS - "Touch the void"


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

Date: Sun, 18 Oct 1998 00:53:24 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <3629397F.26450F6F@bbnplanet.com>

Matt Pryor wrote:

> > That'd be *father*-of-perl, no? Unless there's something Larry hasn't
> > told us...
> 
> Hmmm... I always did think that big handlebar moustache was a bit
> suspicious.

Well, giving birth is usually considered in the feminine sense of
'motherhood'. Unless there has been a miracle and men can now share the
experience. ;) Larry is the mother of this Perl. 

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: Sun, 18 Oct 1998 00:54:21 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <362939B9.D7C79AF3@bbnplanet.com>

Joergen W. Lang wrote:

> And the menu is written in Perl, of course.

Of course, with a translated version for the non-geeks. :)

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: Sat, 17 Oct 1998 22:03:52 -0400
From: tory1@mail.idt.net
Subject: Reading inary Files :: dbase headers
Message-Id: <36294C88.B86@mail.idt.net>

Hi,
Can anyone help with reading a binary file?
I am on Solaris 2.5.1 (Sun) and have a file
in dbase Version 3 format.  

I have opend the file successfully and I can read 
in the buffer read(INFILE, $buff32,32) and if
I do something like
print "Found Version 3.0" if (substr($buff32,0,1) == "x\03");
then I get the correct print -- but I cannot do
$Version = sprintf("%x",substr($buff32,0,1));
successfully.

Can anyone help

Thanks

Jim


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

Date: 18 Oct 1998 01:26:54 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Recover ref from string
Message-Id: <70bcke$gf$1@gellyfish.btinternet.com>

On Fri, 16 Oct 1998 20:39:29 -0700 Larry Rosler <lr@hpl.hp.com> wrote:
> [Posted to comp.lang.perl.misc and copy mailed.]
> 
> In article <MPG.109197601a59e43f989696@news.anet-chi.com> on Fri, 16 Oct 
> 1998 18:48:56 -0500, Thomas Rock <thomas@x-tekcorp.com> says...
>> my $a = [10, 11, 12];
>> my $b = sprintf("%s", $a);
>> 
>> Is there any way to recover the reference to the
>> array from the string contained in $b?
> 
> No.
> 
;-P

Or to put it a little less succinctly why dont you just try it :

print $b->[0];

nope that dont work.

By using the sprintf on the scalar value of the reference you are turning it
into a pure string that no longer has any meaning as a reference.  It
might be nice if we can think of this as a hash key like $::{$b} but that
isnt the case I'm afraid.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: 17 Oct 1998 23:53:05 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Search Engine Question
Message-Id: <70b74h$av$1@gellyfish.btinternet.com>

On Fri, 16 Oct 1998 18:29:46 GMT Danny Groppo <gosdpads@yahoo.com> wrote:

<snip> 

> The second part is giving be difficulty.  I would like to store their
> information in a way that will make it easy to search for them via
> their city, state, zip, country or name - a basic search engine.  What
> kind of data structure and algorithm is used to do this? I would like
> to be able to store 1_000_000 records and still have an efficient
> search.  Can I do this with pure Perl, or do I need to implement some
> SQL database?  
> 

I think you'll find that you will want to use some sort of database system
unless you are keen on developing your own. There are free databases
available - check out yahoo for MySQL for instance. There are Perl modules
that interface with most Database servers.
 
/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Sun, 18 Oct 1998 00:46:15 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: send geroge reese (was Re: Call for Participation: Python Conference)
Message-Id: <slrn72iib4.85.alastair@calliope.demon.co.uk>

Abigail <abigail@fnx.com> wrote:
>Zenin (zenin@bawdycaste.org) wrote on MDCCCLXII September MCMXCIII in
><URL:news:907659738.616445@thrush.omix.com>:
>
>++ 	IMHO, inheritance is highly overrated.  A uses relationship is
>++ 	much more useful and reusable in most cases.  There never was field
>++ 	name collision in a uses relationship.
>
>If you don't use inheritance, why bother with OO?

Why not? Inheritance is only one aspect of OO after all. Other reasons might
include data encapsulation only.


-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: 17 Oct 1998 23:31:46 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Slow Sort?
Message-Id: <70b5si$as$1@gellyfish.btinternet.com>

On Fri, 16 Oct 1998 18:48:13 +0100 Matt Pryor <matt@whiterabbit.co.uk> wrote:
> 

<snip>

> Took just 9 seconds under Win95 with a Cyrix 200mhz processor with 32
> meg ram...
> 
 6 Seconds on similar hardware with Linux 2.034 ;-}

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Sat, 17 Oct 1998 14:42:30 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: sub and return
Message-Id: <6vra07.um7.ln@flash.net>

Matt Pryor (matt@whiterabbit.co.uk) wrote:

: Here you go:

: #!/usr/bin/perl -w
                  ^^

   Putting a -w on your script is a very good idea...

: while ($repeat ne "no") {
         ^^^^^^^

   ... but ignoring the warnings that it generates in not such a good idea...


[ snip code that works fine but is not -w clean ]


   That can easily be fixed by using the 

      do {

      } while () 

   form instead.


   The chomp()ing is not needed in these particular cases either,
   so I would have done it like:

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

use strict;
my($radius, $repeat);

do {
        print "Enter the radius of the circle: ";
        $radius = <STDIN>;
        print 2 * 3.1415 * $radius, "\n";

        print "Do you want to try again? (y/n): ";
        $repeat=<STDIN>;
} until ($repeat eq "n\n");
------------------------


: Note that brackets surrounding quotes isn't necessary with print
                                                        ^^^^^^^^^^
: statements.
  ^^^^^^^^^^

   Note that parenthesis are optional on all of Perl's functions,
   not just print()    ;-)


   From 'perlfunc':  

      "Any function in the list below may be used either with or without
       parentheses around its arguments."



   ( I assume that "brackets" means "parenthesis" over there?

     I know you talk funny (now I know who was first, and who
     it really is that talks funny, but I don't want to
     acknowledge that in a public forum such as this ;-)
   )


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 17 Oct 1998 20:17:36 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: sub and return
Message-Id: <gjfb07.rq8.ln@flash.net>

Todd R Koning (army.tennis@lineone.net) wrote:
: I have been reading a book on learning perl that has exercises at the end of
: chapters.  The exercise was to write a program that prompts for an input for
: a radius and then outputs the circumference of the cirlce.  I managed this,
: but then thought that I would try to add an option to end the program or
: input a new radius.  I have tried to use a subroutine for this but got into
: a bit of a mess!

: 1    -    Is the subroutine idea a good way of doing  it?


   A subroutine is _a_ way of doing it.

   "good" is kinda ambiguous. Means different things to different people.

   The first test of "goodness" is that the program work correctly.

   Everything beyond that is of secondary importance   ;-)


: 2    -    How do I make the subroutine work?
: 3    -    How do I take the return value from the sub and say whether to
: re-run the prompt for input or quit the program?


Reworking code from my other followup in this thread, you could
do it like this:


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

use strict;
my $radius;

do {
        print "Enter the radius of the circle: ";
        $radius = <STDIN>;
        print 2 * 3.1415 * $radius, "\n";

} while do_it_again_please();


sub do_it_again_please {
   print "Do you want to try again? (y/n): ";

   if (<STDIN> eq "n\n")  # read a line and check it
      { return 0 }        # false
   else
      { return 1 }        # true
}
----------------------------------------------------


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 18 Oct 1998 00:58:48 +0100
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Unzip with Perl
Message-Id: <70bavo$e9$1@gellyfish.btinternet.com>

On Fri, 16 Oct 1998 16:03:25 -0700 Alex Guberman <alex@digi-q.com> wrote:
> Hi,
> 
> Does anybody know how I can unzip a file and put the unziped files in a
> directory using Perl script, but NOT using system call.  Please help.
> 

If there isnt a module on CPAN that doesnt afford this capability then
you will have to use an external program or alternatively write your
own solution.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

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

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