[10313] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3906 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 6 15:07:41 1998

Date: Tue, 6 Oct 98 12:01:37 -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           Tue, 6 Oct 1998     Volume: 8 Number: 3906

Today's topics:
    Re: Problems Using a Compare Subroutine with Sort <jdporter@min.net>
    Re: Q: How do I force perl to deallocate hash tables? <sugalskd@netserve.ous.edu>
    Re: send geroge reese (was Re: Call for Participation:  (Abigail)
    Re: send geroge reese (was Re: Call for Participation:  <tchrist@mox.perl.com>
    Re: Shuffling of array content (Tad McClellan)
    Re: sort question? <jdporter@min.net>
    Re: Split question - retain the pattern? <jdporter@min.net>
        What does $INPUT{'name'} =~ s/\s+$//; do?? (I'm a newbi (Nancy)
    Re: What does $INPUT{'name'} =~ s/\s+$//; do?? (I'm a n <eashton@bbnplanet.com>
    Re: What does $INPUT{'name'} =~ s/\s+$//; do?? (I'm a n <ajohnson@gatewest.net>
    Re: What does $INPUT{'name'} =~ s/\s+$//; do?? (I'm a n <minich@globalnet.co.uk>
    Re: What does $INPUT{'name'} =~ s/\s+$//; do?? (I'm a n <commitman@digitalnet.com.br>
        What is a .pag file? <BOwen@PrioritySearch.Com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 06 Oct 1998 14:21:43 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Problems Using a Compare Subroutine with Sort
Message-Id: <361A5FB7.A9E33475@min.net>

Garry T. Williams wrote:
> 
> I don't believe that interpreting 0xffffffff as a minus one is a bug.
> That *is* minus one (assuming a 32-bit word size). 

No, it entirely depends on whether the word is being treated as
signed or unsigned.  I think it's clear we are only interested in
treating these numbers as unsigned.  If Perl lacks a way to force
the interpretation of words as unsigned, then that's a problem
with Perl.  I have not encountered that problem, however.


> The real problem is using a numeric compare to sort IP addresses.
> They are strings and a string compare is the only way to order them.

I'm sorry, Garry, but that is utterly false.
IP addresses are unsigned 32-bit numbers.
The dotted-decimal notations are for human convenience only.

How I wish the IETF (or whatever) had chosen to specify
dotted-hex with zero padding, instead of decimal; everyone's
life would be so much easier.

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: 6 Oct 1998 17:03:31 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: Q: How do I force perl to deallocate hash tables?
Message-Id: <6vdih3$bts$1@news.NERO.NET>

Craig De Groot <cdegroot@hdc.net> wrote:
: I am trying to force perl to deallocate some hashes because I am running
: low on memory.  I tried using undef, but this merely removes the
: reference to the hash and does not allow me to reclaim the memory.  Is
: there any way for me to actually remove the hash from memory?

Depends on what you mean by 'remove the hash from memory'. If you're
trying to give memory back to the OS, you're out of luck everywhere but on
the Mac. If you just want to make the memory the hash used available for
reallocation by perl, an undef(%hash) should do it. 

Of course, undef(%hash) only frees up the space used by scalars not
otherwise referenced. If all the scalars in your hash are referenced by
other things, then undefing the hash isn't going to get you any more
space.

					Dan


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

Date: 6 Oct 1998 16:34:54 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: send geroge reese (was Re: Call for Participation: Python Conference)
Message-Id: <6vdgre$ojq$1@client3.news.psi.net>

Zenin (zenin@bawdycaste.org) wrote on MDCCCLXII September MCMXCIII in
<URL:news:907659738.616445@thrush.omix.com>:
++ Abigail <abigail@fnx.com> wrote:
++ 	>snip<
++ : @{$self -> {_array}}  vs   @array;
++ :
++ : The fact your implementation depends on the implementation of your
++ : parent class. OO is implementation *hiding*, not being depended on it.
++ 
++ 	Yes, but this is "old" Perl (ok, by a few months, but still:-).
++ 
++ : Yes, fields.pm makes it a little better.
++ 
++ 	Personally, I think it makes it a *lot* better.
++ 
++ : It took only 5 years of OO Perl to come with it.
++ : Which means that 5 years worth of writing modules
++ : does *NOT* use fields.pm and suffers from name collision and not having
++ : data encapsulation.
++ 
++ 	True, but it is here now.  As such, this should no longer be
++ 	considered an issue for new, large scale projects that need
++ 	inheritance.

Large scale projects don't tend to start after the release of
perl5.005. Some large scale project have started a year or longer ago.

++ 	I'm not worried about CPAN.  Most of the CPAN modules are built
++ 	on a "uses" vs an "is-a" (inheritance) relationship.

Who said CPAN? Not everything that's written appears on CPAN. I've written
many modules that aren't on CPAN, that use inheritance, and where I need
to be careful about name clashes. That isn't even a matter of someone
else using my modules.

++ 	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?



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: 6 Oct 1998 18:02:53 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: send geroge reese (was Re: Call for Participation: Python Conference)
Message-Id: <6vdm0d$7oo$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, abigail@fnx.com writes:
:If you don't use inheritance, why bother with OO?

That's a great question, and I bet you can think of good answers.  State,
behaviour, and identity are nice -- but abstraction is the important
issue here.  You want to be able to separate the implementation from
the interface.  Of course, a traditional module with a purely --
and strictly -- procedural interface can also satisfy these criteria.
Think of stdio FILE* operations, for example.

But I agree that inheritance is overused.   Containership is
underappreciated, and much clearer.

--tom
-- 
:The only reason [not to use] perl is that some sysadmins don't allow software that they didn't pay for.
By all means, let them send me money if it makes them feel better.  :-)
	--Larry Wall in <1993Dec13.213032.26623@netlabs.com>


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

Date: Tue, 6 Oct 1998 06:48:15 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Shuffling of array content
Message-Id: <v10dv6.hp.ln@flash.net>

Hauk Langlo (hauk@forumnett.no) wrote:

: Hi there. I'm about to write a script that will have to shuffle the
: content in an array so that the elements are placed in random order. 

[snip]

: PS: No flaming please. 


   If you post a FAQ, you will likely get flamed.

   You are expected to check for your question in the FAQ *before* posting.


: I'm a newbie allright, 

   Welcome!

   But that isn't an excuse for asking a FAQ yet again...


: but I have learned (the
: hard way) not to post lazyquestions etc.


   Perl FAQ, part 4:

      "How do I shuffle an array randomly?"


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


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

Date: Tue, 06 Oct 1998 13:34:19 -0400
From: John Porter <jdporter@min.net>
Subject: Re: sort question?
Message-Id: <361A549B.4B1B0420@min.net>

Brand Hilton wrote:
> 
> In article <361A2776.57C1F48C@min.net>, John Porter  <jdporter@min.net> wrote:
> >Brand Hilton wrote:
> >>
> >>   print sort {substr($a,-2,1) cmp substr($b,-2,1) || $a cmp $b} <>;
> >
> >That's wrong, those should be substr($a,-1) and substr($b,-1).
> 
> BZZZT!  Look again.  I didn't chomp the input.

Wups!  [sound of head smacking]

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: Tue, 06 Oct 1998 13:59:22 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Split question - retain the pattern?
Message-Id: <361A5A7A.AA8A2CE9@min.net>

Bart Lateur wrote:
> 
> John Porter wrote:
> 
> >This one works.
> >It doesn't attempt to remove the line-ending whitespaces;
> >and it loses any text after the last dot/bang/hook.
> >
> >@sentences = /(.*?[.!?](?:\s+|$))/gs;
> 
> It doesn't work if, unintentional of course ;-), the final sentence
> doesn't end with either of [.!?]. It'll gladly drop it. 

Quite intentional, I assure you, and well-documented.  (:-)
Sorry if you missed that.


> BTW shouldn't your closing paren for the first submatch, be put in front
> of the second opening paren? Otherwise, it STILL keeps the spaces
> following the dot/bang/hook.

If the original request was to NOT keep the whitespaces, then Yes,
you're right.  I don't remember that requirement, and I assumed 
that the whitespaces should be kept.

BTW my other post in this thread gives a more complete (i.e. "verbose")
solution which doesn't lose the part of the line after the last 
dot/bang/hook.  If there is any such text, I'm not sure I'd call
that a "sentence" anyway.

-- 
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer


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

Date: Tue, 06 Oct 1998 18:21:21 GMT
From: Nancy56@bigfoot.com (Nancy)
Subject: What does $INPUT{'name'} =~ s/\s+$//; do?? (I'm a newbie)
Message-Id: <361a5e1c.4189942@news.iaehv.nl>

Hello,

I'm making some changes to a script. In the script a came across the
following line:

$INPUT{'name'} =~ s/\s+$//;

The only problem is that I don't know what this line do! I don't want
to delete it without knowing what it does!!


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

Date: Tue, 06 Oct 1998 17:50:39 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: What does $INPUT{'name'} =~ s/\s+$//; do?? (I'm a newbie)
Message-Id: <361A55F5.170AB3E7@bbnplanet.com>

Nancy wrote:

> $INPUT{'name'} =~ s/\s+$//;
> The only problem is that I don't know what this line do! I don't want
> to delete it without knowing what it does!!

This will do a match on more than one whitespace '\s+' to the end of the
line '$' and substitute it with null '//'. See 'perldoc perlre' for more
info on this.
 
e.

Que fiz tantos planos de me entregar 
  Como fiz enganos de me encontrar 
    Como fiz estradas de me perder 
      Fiz de tudo e nada de te esquecer. - Jobim -


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

Date: Tue, 06 Oct 1998 13:13:05 -0500
From: Andrew Johnson <ajohnson@gatewest.net>
Subject: Re: What does $INPUT{'name'} =~ s/\s+$//; do?? (I'm a newbie)
Message-Id: <361A5DB1.6246F4A1@gatewest.net>

Nancy wrote:
> 
> Hello,
> 
> I'm making some changes to a script. In the script a came across the
> following line:
> 
> $INPUT{'name'} =~ s/\s+$//;
> 
> The only problem is that I don't know what this line do! I don't want
> to delete it without knowing what it does!!

Do you often make changes to programs written in languages
you are not familiar with?  I'd suggest learning some
basic Perl before going further ... the s/// operator is
fundamental, you will encounter it often in Perl scripts.

I'd suggest obtaining 'Learning Perl" 2nd ed and taking
a look at the following manpages:
perldoc perlop
perldoc perlre

for a start at understanding s/\s+$//.

regards
andrew


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

Date: Tue, 6 Oct 1998 19:41:39 +0100
From: "Martin" <minich@globalnet.co.uk>
Subject: Re: What does $INPUT{'name'} =~ s/\s+$//; do?? (I'm a newbie)
Message-Id: <6vdo9f$541$1@newnews.global.net.uk>

>$INPUT{'name'} =~ s/\s+$//;
>
>The only problem is that I don't know what this line do! I don't want
>to delete it without knowing what it does!!

It's obviously there for a reason. What it does is removes any whitespace
characters (spaces/tabs/newlines/carriage returns/form-feeds) from the
end of the data that are held in $INPUT{'name'}.

Martin




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

Date: Tue, 6 Oct 1998 14:57:27 -0300
From: "Commitman" <commitman@digitalnet.com.br>
Subject: Re: What does $INPUT{'name'} =~ s/\s+$//; do?? (I'm a newbie)
Message-Id: <6vdlpe$10a$1@srv4-poa.nutecnet.com.br>

It will erase the all the ocurrence of \s+$ ( +$) of the $INPUT{ 'name'}

If u speak portuguese u may access www.digitalnet.com.br/clientes/lammertech
and look at "Tutoriais"

Nancy wrote in message <361a5e1c.4189942@news.iaehv.nl>...
>Hello,
>
>I'm making some changes to a script. In the script a came across the
>following line:
>
>$INPUT{'name'} =~ s/\s+$//;
>
>The only problem is that I don't know what this line do! I don't want
>to delete it without knowing what it does!!




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

Date: Tue, 6 Oct 1998 14:52:14 -0400
From: "Brian Owen" <BOwen@PrioritySearch.Com>
Subject: What is a .pag file?
Message-Id: <6vdosj$5ac$1@news0-alterdial.uu.net>

Hey,

    I've come into the ownership of a Web-Site that needs updating and CGI
scripts are used in one section.  I need to modify this .pag file to
add/remove some changes that have been made.  My question is how do I take
the .dat file also in the same directory and convert it into a .pag file?
It may seem simple to most, but I am just starting to use this and I can't
any reference to this type of file other than for security reasons.  Any
help is appreciated.

Thanks,

Brian




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

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

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