[25130] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7380 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 8 18:10:32 2004

Date: Mon, 8 Nov 2004 15:10:10 -0800 (PST)
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, 8 Nov 2004     Volume: 10 Number: 7380

Today's topics:
    Re: references to OTHER objects <notvalid@email.com>
    Re: references to OTHER objects <spamtrap@dot-app.org>
    Re: references to OTHER objects <Joe.Smith@inwap.com>
    Re: references to OTHER objects <Joe.Smith@inwap.com>
    Re: references to OTHER objects <daveandniki@ntlworld.com>
    Re: references to OTHER objects <mritty@gmail.com>
    Re: references to OTHER objects <ioneabu@yahoo.com>
    Re: references to OTHER objects <nospam@nospam.com>
    Re: references to OTHER objects <nospam@nospam.com>
    Re: references to OTHER objects <usenet_05_08_2004@stuartmoore.org.uk>
    Re: references to OTHER objects <flavell@ph.gla.ac.uk>
    Re: references to OTHER objects <notvalid@email.com>
    Re: references to OTHER objects <spamtrap@dot-app.org>
    Re: Using $SIG{"ALRM"}  assignment inside a subroutine  torahul@gmail.com
    Re: Using libwww to retrieve a UTF-8 webpage <bogusasdfasdf@hotmail.com>
    Re: why not    print $A[0] <noreply@gunnar.cc>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 08 Nov 2004 19:21:40 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: references to OTHER objects
Message-Id: <8HPjd.6337$zx1.6315@newssvr13.news.prodigy.com>

daniel kaplan wrote:

> i think i am the last one anyone would want to do this, but i did make a
> suggestion, in a sort of round about way...i found perldoc hard to use, and
> can easily search FAQs 1-9 at faq.perl.org because questions show up at once
> and with a text search, bang, you find what you're looking for...is it
> possible to get something like that up for the perltoc ?  am sure it would
> elimnate more than half the questions from lots of people..

The Activestate Perl installation comes with all the docs in HTML 
format. That includes perltoc. It should be on your hard-disk with a 
link to it from the Start menu.

> i will start to look for a grep for pc....FIND seems to be quite lacking
> where as grep is not

You have Perl!

	perl -ne 'print if /some string/' *.html

>>Nothing personal.
> 
> the wway you word it, not in the slightest way did i take it

Thanks for understanding.

--Ala


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

Date: Mon, 08 Nov 2004 14:29:00 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: references to OTHER objects
Message-Id: <2aadnSH6lYVgVRLcRVn-3w@adelphia.com>

Ala Qumsieh wrote:

> You have Perl!
> 
>     perl -ne 'print if /some string/' *.html

That's a bit recursive, isn't it? Kind of like telling someone to drive 
to a mechanic when their car won't start...

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Mon, 08 Nov 2004 19:30:35 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: references to OTHER objects
Message-Id: <vPPjd.382045$D%.271917@attbi_s51>

daniel kaplan wrote:

>  the Perldoc does have a
>>Table of Contents readily available:
>>perldoc perltoc
> 
> 
> you may have , but surely you can't think that that is anytype of solution,
> do you?  that prints out over 217k of data...after ten minutes of holding
> down the spacebar, it still isn't done spitting out the contents?  how could
> one do a reasonable search within that?!?!?!?!

With a Unix-like command line (including cygwin for Windows), searching
is a lot easier when using 'less' as the pager.  Simply type / and the
text you're searching for.

For a plain Windows install, use this:
   Start -> Programs -> ActiveState ActivePerl-5.8 -> Documentation
The link for perltoc is at the bottom of the first screen.

	-Joe


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

Date: Mon, 08 Nov 2004 19:39:49 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: references to OTHER objects
Message-Id: <8YPjd.8415$V41.3042@attbi_s52>

Paul Lalli wrote:

>>how could one do a reasonable search within that?!?!?!?!
> 
> 
> Does your version of `more` not support searching, or do you just not
> know how to use it?  When I run perldoc, the results are piped to
> `more`.  Within `more`, pressing / followed by a regexp to search for
> takes me directly to the first match.  Does this not work for you for
> some reason?

ActiveState's perl for win32 uses the Windows-supplied pager.
It does not support searching.
The "extended features" for
	pager='more /e'
does not include the ability to search.

	-Joe


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

Date: Mon, 08 Nov 2004 19:48:06 GMT
From: "Dave" <daveandniki@ntlworld.com>
Subject: Re: references to OTHER objects
Message-Id: <W3Qjd.123$aY2.116@newsfe5-win.ntli.net>


"daniel kaplan" <nospam@nospam.com> wrote in message 
news:1099935698.687240@nntp.acecape.com...
> "Ala Qumsieh" <notvalid@email.com> wrote in message
> news:WYNjd.6314$zx1.3866@newssvr13.news.prodigy.com...
>> daniel kaplan wrote:
>
>>    The next time you have a question, go check out
>>    the relevant docs one more time *before* posting.
>
> please don't think i don't try, but it's the searchign where i lose.
>
>
>> I understand that perldoc can be sometimes lacking (I'm sure patches are
>> welcome if you ever want to rectify the problem instead of constantly
>> complaining),
>
> i think i am the last one anyone would want to do this, but i did make a
> suggestion, in a sort of round about way...i found perldoc hard to use, 
> and
> can easily search FAQs 1-9 at faq.perl.org because questions show up at 
> once
> and with a text search, bang, you find what you're looking for...is it
> possible to get something like that up for the perltoc ?  am sure it would
> elimnate more than half the questions from lots of people..
>
>> learning Perl, I used 'grep' much more than perldoc until I was
> i will start to look for a grep for pc....FIND seems to be quite lacking
> where as grep is not
>
>> I am on the verge of killfiling you since almost all your questions so
>> far are easily answered by browsing the docs. The docs have been written
>> for a reason. Please use them, and stop wasting everyone else's time
>> unnecessarily.
>
> hey i understand, but you did say yourself, that the "that perldoc can be
> sometimes lacking", surely there is some type of solution.  as i said, 
> woudl
> much rather read than type back ad forth...besides, saving the link to 
> your
> FOUND answer in the docs is the best form of refernce i could find
>
> but it boils down to being able to find the keywords
>
>
>
>>
>> Nothing personal.
> the wway you word it, not in the slightest way did i take it
>
>

You can use the cygwin grep. If you put the cygwin /bin folder in your 
windows path then you can even use grep etc from the cmd.exe command line as 
well. Of course you can use perl to do the same task as someone else as 
suggested. The Activestate html version of the docs might be more to your 
taste too, as someone else has mentioned.

I haven't really got to grips with the docs myself. I tend to turn to the 
perl cookbook or the camel book when I don't understand or remember 
something. I think the style of the docs means the more familiar you are 
with perl and the more you get used to their layout and style the easier 
they are to use.

Dave






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

Date: Mon, 08 Nov 2004 19:52:05 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: references to OTHER objects
Message-Id: <F7Qjd.5$8N4.3@trndny09>

"Joe Smith" <Joe.Smith@inwap.com> wrote in message
news:8YPjd.8415$V41.3042@attbi_s52...
> Paul Lalli wrote:
>
> >>how could one do a reasonable search within that?!?!?!?!
> > Does your version of `more` not support searching, or do you just
not
> > know how to use it?  When I run perldoc, the results are piped to
> > `more`.  Within `more`, pressing / followed by a regexp to search
for
> > takes me directly to the first match.  Does this not work for you
for
> > some reason?
>
> ActiveState's perl for win32 uses the Windows-supplied pager.
> It does not support searching.
> The "extended features" for
> pager='more /e'
> does not include the ability to search.

But, but.... ActiveState's has something better!  Activestate
automatically installs the perldocs in a nice convenient HTML format
with links in your Start Menu.  Why would one be using the command-line
perldoc utility if one has the HTML versions so readily available?

Paul Lalli




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

Date: Mon, 08 Nov 2004 13:49:05 -0500
From: wana <ioneabu@yahoo.com>
Subject: Re: references to OTHER objects
Message-Id: <10ovkatra0chofd@news.supernews.com>

Ryan Thompson wrote:

> daniel kaplan wrote to :
> 
>> Hi all,
>>
>> I hope I have my terminology down right.  I've finally gotten down how
>> use reference for scalar's, arrays, and arrays of arrays.
>>
>> Of course now I would like to pass into a subroutine a reference for an
>> object, Mail::Header.   Now I couldn't find anythign in perldoc related
>> to references and objcts,
> 
> The first subheading in the "perlobj" page reads:
> 
>      An Object is Simply a Reference
> 
> So, why pass a reference to a reference? Just pass $obj.
> 
>> So if anybody knows of the proper perldoc keywords, or links, would
>> appreciate it.
> 
> I recommend reading perlref, perlboot, perlobj, and perltoot, in about
> that order. I'd consider those to be the "required reading" for doing
> anything half serious with objects in Perl.
> 
> - Ryan
> 

Thanks for the recommendation from me too.  I am becoming a perldoc junkie. 
I find it takes me an average of 1/2 hour for a small one to 1 hour for a
large one doing a decent but quick read, skipping some of the harder
material.  That works out to about 1-2 minutes per page printed out with a
10 pt font.  Like I said, I read them on the stairmachine at the gym so I
can learn perl and get in shape at the same time.  I will likely make the
above four my reading for the next 2-4 days.  Thanks!

wana


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

Date: Mon, 8 Nov 2004 15:08:50 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: references to OTHER objects
Message-Id: <1099944596.436765@nntp.acecape.com>

"Paul Lalli" <mritty@gmail.com> wrote in message
news:F7Qjd.5$8N4.3@trndny09...

youa re right, the TOC is all one easy to read html, not at the top/top mind
you, where i looked for them, but it is there...thank you...

although will still write my own search routine, just because shoudl be able
to search for "object" and "reference" occuring on same line, even if not
together....in an easy to search of manner...

thanks




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

Date: Mon, 8 Nov 2004 15:10:18 -0500
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: references to OTHER objects
Message-Id: <1099944684.485411@nntp.acecape.com>

"Dave" <daveandniki@ntlworld.com> wrote in message
news:W3Qjd.123$aY2.116@newsfe5-win.ntli.net...

> I haven't really got to grips with the docs myself. I tend to turn to the
> perl cookbook or the camel book when I don't understand or remember
> something. I think the style of the docs means the more familiar you are
> with perl and the more you get used to their layout and style the easier
> they are to use.

i will say this, when not as tight as i am right noe ($$$ wise) i prefer to
buy the books...sure they can get outdated, but i never found reading easy
on the screen, compared to a book

thanks




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

Date: Mon, 08 Nov 2004 20:13:39 +0000
From: Stuart Moore <usenet_05_08_2004@stuartmoore.org.uk>
Subject: Re: references to OTHER objects
Message-Id: <cmok1d$18i$1@gemini.csx.cam.ac.uk>

daniel kaplan wrote:
> 
> 
> i try wiht a -q, without, quotes, then i go to faq.perl.org, text search
> there, browse my books, then come here....
> 

What books do you have? Most people seem to think the best ones for Perl 
are the O'Reilly ones (their authors generally know the language well 
because they wrote it...)

If you don't have them already, then Learning Perl and Programming Perl 
are definitely worth buying if you're going to do much programming in 
Perl. The other books might also be worth a look, depending on what you 
actually intend to do with Perl in the end.


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

Date: Mon, 8 Nov 2004 20:11:40 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: references to OTHER objects
Message-Id: <Pine.LNX.4.61.0411082005280.17728@ppepc56.ph.gla.ac.uk>

On Mon, 8 Nov 2004, Paul Lalli wrote:

> Why would one be using the command-line perldoc utility if one has 
> the HTML versions so readily available?

In a word, "grep".  Across all of the docs, if I want to.

The ActiveState HTML-ified documents are nice for browsing in comfort, 
I've no argument about that.  But when you're not quite sure where you 
should be looking for a specific answer, they're not my first choice.

Mind you, Google is also a remarkable resource.  More than once I have 
typed - or, if possible, copy/pasted - my exact problem symptoms into 
Google, and got the answer as the #1 match.  Saved me from asking lots 
of naive questions on usenet.  (Over and above the naive questions 
that I -did- ask, I mean ;-)


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

Date: Mon, 08 Nov 2004 21:36:14 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: references to OTHER objects
Message-Id: <iFRjd.19219$6q2.1344@newssvr14.news.prodigy.com>

Sherm Pendley wrote:

> Ala Qumsieh wrote:
> 
>> You have Perl!
>>
>>     perl -ne 'print if /some string/' *.html
> 
> 
> That's a bit recursive, isn't it? Kind of like telling someone to drive 
> to a mechanic when their car won't start...

How so? My comment was in response to daniel saying that he wants to 
find a 'grep' for pc (and I assumed he meant Win32 there) to search the 
perldocs. I showed him how to use Perl to do the same job.

I don't see your point.

--Ala


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

Date: Mon, 08 Nov 2004 17:23:04 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: references to OTHER objects
Message-Id: <PpydnQWxQKtUbBLcRVn-3Q@adelphia.com>

Ala Qumsieh wrote:

> How so? My comment was in response to daniel saying that he wants to 
> find a 'grep' for pc (and I assumed he meant Win32 there) to search the 
> perldocs. I showed him how to use Perl to do the same job.

Think about someone who doesn't know about -e or Perl one-liners. A 
one-liner is a useful tool for searching the docs. But to learn about 
one-liners, he needs to search the docs... That's the recursiveness I 
was commenting on.

Having said that, I do see that I missed the point of your comment. I 
thought you were criticizing him for not having broken that recursive 
loop for himself. Looking back at your comment again, I see that's not 
the case. Sorry for the misunderstanding.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 8 Nov 2004 14:20:11 -0800
From: torahul@gmail.com
Subject: Re: Using $SIG{"ALRM"}  assignment inside a subroutine ...
Message-Id: <e713d286.0411081420.24436fb5@posting.google.com>

Thanks Ryan & Tad! Prefixing subroutine handler with \& worked for me.

As you already have imagined, I have just started with Perl! Hence
regarding calling subroutine withour '&' prefix, I wasn't aware of
'this' way of calling subroutine (and hence difference between both!).
The book which I am reading might be either older edition or has not
make these things clear about subroutine -- at least till the point I
have finished reading :-).

Usage of 'my' instead of 'local', 'use strict' are also new to me --
and after browsing little thru online perl documentation, is making
things clearer now.

One thing sure for me -- still long way to go to learn perl :-)

Regards,
Rahul.

Ryan Thompson <a@ry.ca> wrote in message news:<20041107171347.M20279@coyote>...
> torahul@gmail.com wrote to :
> 
> > Hi,
> 
> Hi!
> 
> > Wondering what's happening here -- is it a bug or an expected behavior
> > from perl ? I am trying to set SIGALRM handle from within a
> > subroutine; surprisingly it executes the handler rotine soon I assign
> > to SIG{"ALRM"}, even I haven't set any alarm!
>  
> > Following perl code :
> > ----------------- Start of Script -----------------
> > #!/usr/local/bin/perl
> 
> Please use warnings and strict. This problem almost solved itself!
> 
> Among other problems:
> 
> >       kill ("KILL", $pid);
> > }
> >
> > sub s_sub1 {
> >   local (@args) = @_;
> >
> >   print ("Setting alarm routine to s_alarm_handler\n");
> >   $SIG{"ALRM"} = s_alarm_handler;
> 
> The above line is the problem. You're setting the value of $SIG{"ALRM"}
> to the *return of* s_alarm_handler. It has nothing to do with signal
> processing. You need to pass in a *reference* to the subroutine you want
> called, like so:
> 
>      $SIG{"ALRM"} = \&s_alarm_handler;
> 
> The actual warning generated is:
> You need to quote "s_alarm_handler" at ./sig.pl line 12.
> where line 12 is the $SIG{"ALRM"} = s_alarm_handler call.
> 
> > If I move SIG{"ALRM"} assignment outside the subroutine, it's working
> > as I would expect.
> 
> I doubt that, unless you assigned it differently.
> 
> See the first page of "perldoc perlipc".
> 
> Here's the complete fixed script which runs under -w and strict:
> 
>      #!/usr/local/bin/perl -w
>      use strict;
> 
>      my $pid = 0;
> 
>      sub s_alarm_handler {
>  	print ("$$ : *** KILLING process(pid=$pid) after timeout\n");
>  	kill ("KILL", $pid);
>      }
> 
>      sub s_sub1 {
>  	my (@args) = @_; # You had "local". Anyway, why copy @_?
> 
>  	print ("Setting alarm routine to s_alarm_handler\n");
>  	$SIG{"ALRM"} = \&s_alarm_handler;  # sub reference
>  	print ("Alarm routine set to s_alarm_handler\n");
>      }
> 
>      s_sub1 ("something");	# No need for & here
> 
> It produces the following output:
>      Setting alarm routine to s_alarm_handler
>      Alarm routine set to s_alarm_handler
> 
> Hope this helps,
> - Ryan


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

Date: 8 Nov 2004 12:24:26 -0800
From: "EH" <bogusasdfasdf@hotmail.com>
Subject: Re: Using libwww to retrieve a UTF-8 webpage
Message-Id: <1099945466.106742.20360@s69g2000cwa.googlegroups.com>

Thanks Ben.

I've got it working.  You were right; I needed to decode manually.  For
the benefit of others, the functional script follows below.

Eddie

#######################

use LWP::UserAgent;
use Encode::Guess;

$ua = LWP::UserAgent->new;

my @ns_headers = (
'User-Agent' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
 .NET CLR 1.1.4322)',
'Accept' => 'text/html, image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, image/png, */*',
'Accept-Charset' => 'UTF-8',
'Accept-Language' => 'en-US',
);


$url = "http://news.google.com/news?ned=cn&hl=zh-CN";

my $content = $ua->get($url, @ns_headers);

open TEST, ">:encoding(utf8)", "wwwutftest.html" || die "failed to open
$!\n";

my $decoder = Encode::Guess->guess($content->content());
die $decoder unless ref($decoder);
my $utf8 = $decoder->decode($content->content());


if ($content->is_success) {
print TEST $utf8;
} else {
	print "failed to get: $!";
}

close(TEST);



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

Date: Mon, 08 Nov 2004 20:38:54 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: why not    print $A[0]
Message-Id: <2va06hF2k1l6bU1@uni-berlin.de>

Mark Galecki wrote:
> So what I can understand from the responses, is that I have to do
> 
> print {$A[0]} "foo\n";
> 
> or 
> $a = $A[0];  print $a "foo\n";
> 
> but not 
> print $A[0] "foo\n";  
> 
> because of the way the Perl parser works.  OK I can accept that.  
> 
> But please, can someone point me to where this is written down in the
> Camel book?  (I really tried to find it there ).

Why are you so anxious to find it in the Camel, considering that it's 
very clearly explained in the latter versions of

     perldoc -f print

> Or is it?

I didn't find it in my copy. But, again, the Camel isn't the first place 
to look for the syntax of a specific built-in function.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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.

#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 V10 Issue 7380
***************************************


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