[11761] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5362 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 12 14:07:27 1999

Date: Mon, 12 Apr 99 11:01:29 -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           Mon, 12 Apr 1999     Volume: 8 Number: 5362

Today's topics:
    Re: sorting a reference by a specific key... (Jonathan Stowe)
    Re: sorting a reference by a specific key... (Steve Linberg)
    Re: Splitting messages <john@NOSPAMpmbbs.demon.co.uk>
    Re: stripping spaces out (Matthew Bafford)
    Re: stripping spaces out (Larry Rosler)
    Re: stripping spaces out (Steve Linberg)
    Re: Suit case or backpack (Steve Linberg)
    Re: The First Parameter in Bless??? (Sys Adm 89806 Manager of programing development and Intranet Resources)
    Re: using perl to load a web page <wells@cedarnet.org>
    Re: using perl to load a web page <stevenhenderson@prodigy.net>
        Where I Can Learn About Pearl And CGI Scripting? (BarneyXter)
    Re: Where I Can Learn About Pearl And CGI Scripting? (Steve Linberg)
    Re: Where I Can Learn About Pearl And CGI Scripting? (Sys Adm 89806 Manager of programing development and Intranet Resources)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 12 Apr 1999 15:49:45 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: sorting a reference by a specific key...
Message-Id: <371214b9.28195865@news.dircon.co.uk>

On Mon, 12 Apr 1999 14:50:01 GMT, mondolumina@my-dejanews.com wrote:

>hey folks,
>
>does anyone know if there's a way to sort a reference? i'm using perLDAP to
>generate some custom reports and the search results are put into a reference
>called $entry. i'd like to sort the results of the reference by
>$entry->{cn}[0]. right now i'm just printing them out in a while loop:
>
>while ($entry)
>{
>	print $entry->{cn}[0]." ".$entry->{phone}[0]."etc... \n";
>	$entry = $conn->nextEntry(); # more reference pointer to next entry
>}
>
>obviously i could push the reference into a hash and sort it, but i'm trying
>to avoid extra cpu eating steps...
>


I would do something like this (warning untested ... I'm assuming that
you have already got something in $entry before this ):

while ($entry)
{
	
        push @unsorted,$entry;
        $entry = $conn->nextEntry(); 
}


@sorted = sort { $a->{cn}[0] cmp $b->{cn}[0] } @unsorted;



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

Date: Mon, 12 Apr 1999 12:45:59 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: sorting a reference by a specific key...
Message-Id: <linberg-1204991245590001@ltl1.literacy.upenn.edu>

In article <7et16m$oqv$1@nnrp1.dejanews.com>, mondolumina@my-dejanews.com wrote:

> hey folks,
> 
> does anyone know if there's a way to sort a reference?

A reference can't be sorted, of course.  It's a thing.  Things that a
reference points to might be sortable -- I assume that's what you mean.

> i'm using perLDAP to
> generate some custom reports and the search results are put into a reference
> called $entry. i'd like to sort the results of the reference by
> $entry->{cn}[0]. right now i'm just printing them out in a while loop:
> 
> while ($entry)
> {
>         print $entry->{cn}[0]." ".$entry->{phone}[0]."etc... \n";
>         $entry = $conn->nextEntry(); # more reference pointer to next entry
> }

I'm not familiar with perlDAP, but if you need to call a function to
iterate through a list of hash references, you might have some
difficulty.  I'd pre-build an array of hash references and write a quick
compare routine (something) like this:

@sorted_hrs = sort {$a->{cn}[0] <=> $b->{cn}[0]} @hrs;

There are many ways to do it, as always, and this may not be the best for
your need.

Hope this helps.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: Mon, 12 Apr 1999 18:58:50 +0100
From: "John P" <john@NOSPAMpmbbs.demon.co.uk>
Subject: Re: Splitting messages
Message-Id: <923939862.27139.0.nnrp-12.9e98b683@news.demon.co.uk>


>Err yes i think it probably is - but here is what I would do :
>
>split -b120 - mps
>for file in mps*
>do
>  mail jonathan.stowe@dircon.net <$file
>done
>rm mps*
>
>Of course all of that could be done in Perl but why bother eh ;-?


Hold on, that means it will send all the messages to you! Why would I do
that eh?
*ONLY KIDDING* (wouldn't want to offend the people in this newsgroup any
more...)

I'd forgotten you could use do and for in a shell script. That certainly
seems the easiest way from an implementation point of view.

Thanks for your help Jonathan..

John.





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

Date: Mon, 12 Apr 1999 16:05:48 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: stripping spaces out
Message-Id: <slrn7h453k.f8.dragons@dragons.duesouth.net>

On Mon, 12 Apr 1999 08:15:55 -0500, quinn coldiron <qcoldiro@unlinfo.unl.edu>
lucked upon a computer, and thus typed in the following:
) I read the perl FAQ, and found a reg exp to strip spaces, but it only
) strips spaces off the beginning and end of a string.  I want to strip
) ALL the spaces out of a string.  Does anybody have a reg exp that will
) do this?

Everyone else did regexs, so:

$string =~ tr/ //d;

) Quinn

--Matthew


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

Date: Mon, 12 Apr 1999 08:59:09 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: stripping spaces out
Message-Id: <MPG.117bb826173a92ec989898@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <371208be.25127984@news.dircon.co.uk> on Mon, 12 Apr 1999 
15:00:29 GMT, Jonathan Stowe <gellyfish@gellyfish.com >says...
+ On Mon, 12 Apr 1999 08:15:55 -0500, quinn coldiron
+ <qcoldiro@unlinfo.unl.edu> wrote:
+ 
+ >I read the perl FAQ, and found a reg exp to strip spaces, but it only
+ >strips spaces off the beginning and end of a string.  I want to strip
+ >ALL the spaces out of a string.  Does anybody have a reg exp that
+ >will do this?
+ 
+ Errr
+ 
+ perlfaq4 has this to remove space from the ends of a string:
+ 
+     $string =~ s/^\s+//;
+     $string =~ s/\s+$//;
+ 
+ And the perlre manpage says:
+ 
+ In particular the following metacharacters have their standard
+ egrep-ish meanings: 
+ 
+     \   Quote the next metacharacter
+     ^   Match the beginning of the line
+     .   Match any character (except newline)
+     $   Match the end of the line (or before newline at the end)
+     |   Alternation
+     ()  Grouping
+     []  Character class
+ 
+ So now you know what is causing those regex to do what they do and
+ thus you know what to remove in order to remove all spaces from a
+ string.

Errr

With the information you just gave, he could remove the first space from 
a string, not 'all spaces'.  Something more is needed (besides just 
using the 'tr' operator, that is).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 12 Apr 1999 12:14:17 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: stripping spaces out
Message-Id: <linberg-1204991214170001@ltl1.literacy.upenn.edu>

In article <MPG.117bb525edece804989897@nntp.hpl.hp.com>, lr@hpl.hp.com
(Larry Rosler) wrote:

> Yes, but I won't show it to you (though others already have), because 
> then you might use it instead of the proper (much more efficient) 
> solution, which does not use a regular expression at all:
> 
>     tr/ //d

This is why I'm so careful to say "here's one way to do it" when
suggesting solutions these days.  :)  tr is indeed much, much faster and
better when dealing with replacing single characters, the regex is
overkill for something that simple.

An interesting hack that could be useful would be a Perl interpreter that
would decelerate your machine as punishment when it runs into small,
inefficient constructs or operations like <s/ //g>, so you'd feel the pain
more.  :)  With 450 mhz machines now cheaper than original Apple IIs, who
notices anymore?

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: Mon, 12 Apr 1999 12:17:32 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Suit case or backpack
Message-Id: <linberg-1204991217320001@ltl1.literacy.upenn.edu>

In article <3712107d.27111065@news.dircon.co.uk>, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:

> On 12 Apr 1999 14:42:04 GMT, stan@tempest.temple.edu (Stanley Horwitz)
> wrote:
> 
> >Does anyone have any thoughts on this matter? How is train traveling with 
> >a suit case? I still plan to pack light. 
> 
> I would consult the documentation for the Luggage::Pack module
> available from CPAN.

Yes, and be sure to use Compress::LZO to compress your stuff and zip
things up nice and tight.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: 12 Apr 1999 16:33:02 GMT
From: ruben@llinderman.dental.nyu.edu (Sys Adm 89806 Manager of programing development and Intranet Resources)
Subject: Re: The First Parameter in Bless???
Message-Id: <7et77u$7in$3@news.nyu.edu>

In article <7et70j$7in$1@news.nyu.edu,
	ruben@llinderman.dental.nyu.edu (Sys Adm 89806 Manager of programing development and Intranet Resources) writes:
 Does anyone know in more detail what Sriram Srinivasan  means in "Advanced
 Perl Programing" when he says on page 106 in Chapter 7,
 
 When Perl sees $empl1-promote(), it determines the class to which
 $empl1 belongs.  In this case, it is the Regular-Employee (which I think is a
 typo in the book since the type is RegularEmployee without the dash).  Perl then calls this function as follows:  RegularEmployee::promote($empl1). In other
  words, the object on the left side of the arrow is simply given as a parameter
  of the appropriate subroutine.
 
 This last line is loosing me because a parameter is in the list given to the
 subroutine.  In C++ - indeed we do use this syntax in the constructor in that
 it is self referencing.
 
 Here, I don't see any such thing.  The suboutine new doesn't seem to
 have a parameter for the package name.  Only in the bless clause is
 this given as
 
 bless $r_employee, 'RegularEmployee';
 
 With static class methods, it seems that he's changing his mind on this
 and is adding a scalar $pkg to the parameter list.  Why would it be needed
 for a static Method and not an instance?
 
 I'm very confused about what is happening here.
 
 
 Ruben
 
 


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

Date: Mon, 12 Apr 1999 16:01:24 +0000
From: Steve Wells <wells@cedarnet.org>
Subject: Re: using perl to load a web page
Message-Id: <371218D4.9C69904E@cedarnet.org>

"Randal L. Schwartz" wrote:
> 
> >>>>> "Steven" == Steven T Henderson <stevenhenderson@prodigy.net> writes:
> 
> Steven> or even better, just change the URL:
> Steven> print <<RELOAD;
> Steven> Content-type: text/html\n\n
> Steven> <HTML><HEAD></HEAD><BODY><META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;
> Steven> URL=$HTML_HOME/$HTML_DEFAULT\"></BODY></HTML>
> Steven> RELOAD
> 
> No.  Don't.  Don't.  Don't use meta-refresh.  It destroys your "back"
> button's usefulness.
> 
> If you're doing this from a CGI program, just print the proper
> "Location:" header to force a browser redirect.
> 
> Please *stop* passing along solutions that use the word "refresh"
> in them. :(
> 
> (I think I'll write a script that sends anyone that uses the word
> "meta" near "refresh" or "limit" near "GET" a nastygram when they
> post. :-)

Personally I wouldn't go quite this far as there are times when it's 
useful.

Take for instance your web techniques entry col20:
  search in progress page (Dec 97)
http://www.stonehenge.com/merlyn/WebTechniques/col20.html

You could use meta refresh to simulate an interactive process to the user.

If the parent redirects to a simple CGI that outputs another tick until the 
child has created it's page it could use a meta refresh to reload itself.

ie /results.cgi?count=3&page=myresults.html

Each time it reloads it looks for myresults.html and ticks one up on count
if it doesn't exist.

(It would also help with cleanup because once the CGI has spit out what the
 child created it's time to clean up.)

As long as the page reloads itself it doesn't have any effect on the back
button.

Now a meta refresh of 0 is another story.

STEVE 
-- 
-----------
Stephen D. Wells
http://expert.cc.purdue.edu/~bgannon/booksearch/


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

Date: Mon, 12 Apr 1999 10:48:40 -0500
From: "Steven T. Henderson" <stevenhenderson@prodigy.net>
Subject: Re: using perl to load a web page
Message-Id: <XnqQ2.23687$oa3.271961@news.san.rr.com>

 i was wrong! i recieved a nasty-gram suggesting there is a better way. try
this:

# Simply load the home page
print <<RELOAD;
Location: $HTML_HOME/$HTML_DEFAULT\n\n
RELOAD

thanks to the person who corrected me.

Steven T. Henderson wrote in message ...
>or even better, just change the URL:
>
>
>print <<RELOAD;
>Content-type: text/html\n\n
><HTML><HEAD></HEAD><BODY><META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;
>URL=$HTML_HOME/$HTML_DEFAULT\"></BODY></HTML>
>RELOAD
>
>
>
>Jonathan Feinberg wrote in message ...
>>psalzman@landau.ucdavis.edu (Pete) writes:
>>
>>> i'd like to load up a page, say,
>>>    http://landau.ucdavis.edu/psalzman/version.html
>>> read the entire content into a variable, say,
>>>    $output
>>
>>   use LWP::Simple;
>>   $output = get('http://landau.ucdavis.edu/psalzman/version.html');
>>
>>--
>>Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
>>http://pobox.com/~jdf
>
>




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

Date: 12 Apr 1999 16:34:24 GMT
From: barneyxter@aol.com (BarneyXter)
Subject: Where I Can Learn About Pearl And CGI Scripting?
Message-Id: <19990412123424.21220.00003207@ngol01.aol.com>

The Title Says It All.  I Want To Learn How To Make A Chat Room And Have Pages
That I Can Input Text From...


=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
For E-Mail Reply:  <A HREF="mailto:BarneyXter@aol.com?Subject=Helping People
In Newsgroups">Click Here... Barney Exterminator@Aol.Sux</a>
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=

=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
For E-Mail Reply:  <A HREF="mailto:BarneyXter@AOL.COM?Subject=Helping People In
Newsgroups">Click Here... Barney Exterminator@Aol.Sux</A>
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


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

Date: Mon, 12 Apr 1999 13:05:15 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Where I Can Learn About Pearl And CGI Scripting?
Message-Id: <linberg-1204991305150001@ltl1.literacy.upenn.edu>

In article <19990412123424.21220.00003207@ngol01.aol.com>,
barneyxter@aol.com (BarneyXter) wrote:

> The Title Says It All.  I Want To Learn How To Make A Chat Room And Have Pages
> That I Can Input Text From...

You Can Learn About Perl, If That Is What You Mean By "Pearl", And CGI
Scripting, From Lots Of Places On The Net, And A Good Place To Start Is
Http://Www.Perl.Com.  Or Your Local Bookstore.

Good Luck.

-- 
Steve Linberg, Systems Programmer &c.
National Center on Adult Literacy, University of Pennsylvania
email: <linberg@literacy.upenn.edu>
WWW: <http://www.literacyonline.org>


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

Date: 12 Apr 1999 17:06:47 GMT
From: ruben@llinderman.dental.nyu.edu (Sys Adm 89806 Manager of programing development and Intranet Resources)
Subject: Re: Where I Can Learn About Pearl And CGI Scripting?
Message-Id: <7et977$9b1$1@news.nyu.edu>

In article <19990412123424.21220.00003207@ngol01.aol.com>,

If you are in NYC - I teach a course on this at the New school.

Our end goal is to design a bullitin board system.

Ruben
http://www.brooklynonline.com

	barneyxter@aol.com (BarneyXter) writes:
> The Title Says It All.  I Want To Learn How To Make A Chat Room And Have Pages
> That I Can Input Text From...


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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