[24268] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6459 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 24 18:10:42 2004

Date: Sat, 24 Apr 2004 15:10:13 -0700 (PDT)
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, 24 Apr 2004     Volume: 10 Number: 6459

Today's topics:
        Please Recommend A Good Perl Book. <noemail@#$&&!.net>
    Re: Please Recommend A Good Perl Book. <perl@my-header.org>
    Re: Proper way to use an imported constant under 'use s <kuujinbo@hotmail.com>
    Re: Proper way to use an imported constant under 'use s <minter@lunenburg.org>
    Re: regexp quick reference card <robin @ infusedlight.net>
    Re: RFC: Text similarity ctcgag@hotmail.com
    Re: script too slow - sometimes hangs <tadmc@augustmail.com>
    Re: script too slow - sometimes hangs <jwillmore@remove.adelphia.net>
    Re: script too slow - sometimes hangs <spamtrap@dot-app.org>
    Re: slurp not working? ideas please! <kuujinbo@hotmail.com>
    Re: Text-oriented network protocols <ppagee@yahoo.com>
    Re: Text-oriented network protocols <jwillmore@remove.adelphia.net>
    Re: Text-oriented network protocols <spamtrap@dot-app.org>
    Re: Text-oriented network protocols (Walter Roberson)
    Re: Text-oriented network protocols <ppagee@yahoo.com>
    Re: What kind of RegEx should I use for <TEXTAREA>? <abigail@abigail.nl>
        Where is PL_stack_base defined??? <jkrugman@yahbitoo.com>
    Re: Where is PL_stack_base defined??? <tassilo.parseval@rwth-aachen.de>
        Which statement is "better", and why? <treborrude@SPAMBGONE.comcast.net>
    Re: Which statement is "better", and why? <perl@my-header.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 24 Apr 2004 16:15:25 +0000
From: Fred <noemail@#$&&!.net>
Subject: Please Recommend A Good Perl Book.
Message-Id: <pan.2004.04.24.16.15.25.383954@#$&&!.net>

Rating a book is very subjective, I know. I am an expereinced programmer
but have never used perl. (Got sort of hooked on a2p however... :))

At any rate, I need a good perl book to cover middle to advanced topics.
It would have prehaps only 2 pages on control structures. Cover all the
operators on another page, etc.. Then cover real life topics, date
processing, using modules, etc.

Thank you for your help!

Fred


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

Date: Sat, 24 Apr 2004 23:53:35 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: Please Recommend A Good Perl Book.
Message-Id: <icol805ssvfpgaqi55grpnh3qt455e4kk6@4ax.com>

X-Ftn-To: Fred 

Fred <noemail@#$&&!.net> wrote:
>Rating a book is very subjective, I know. I am an expereinced programmer
>but have never used perl. (Got sort of hooked on a2p however... :))
>
>At any rate, I need a good perl book to cover middle to advanced topics.
>It would have prehaps only 2 pages on control structures. Cover all the
>operators on another page, etc.. Then cover real life topics, date
>processing, using modules, etc.

"Effective Perl" is imo excellent book and "Perl Cookbook" is what you want
when you become familiar with some basics. There are also other books but
these two cover in detail pretty much everything.



-- 
Matija


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

Date: Sat, 24 Apr 2004 19:53:53 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Proper way to use an imported constant under 'use strict'?
Message-Id: <c6dh01$b3a26$1@ID-227975.news.uni-berlin.de>

H. Wade Minter wrote:

[snip]

> I have a question on one thing, though, and didn't see an answer by 
> Googling.  My code is designed on Linux but also runs on Windows via
> checks of $^O.  So, to import Windows-specific modules, I do this:
> 
> if ( "$^O" eq "MSWin32" )

[snip code]

> However, when strict subs are enabled, I get an error about barewords:
> 
> [minter@localhost mrvoice]$ ./mrvoice.pl
--^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------

That doesn't look like a M$ shell, cygwin? It wasn't specified whether 
or not the appication runs if 'use strict' is commented out.

If you *are* running under cygwin, none of the modules will have been 
included because $^O eq 'cygwin', and you'll get the error that you 
quoted below:

> Bareword "NORMAL_PRIORITY_CLASS" not allowed while "strict subs" in use 
> at ./mrvoice.pl line 3513.
> Execution of ./mrvoice.pl aborted due to compilation errors.
> 
> My question is - what's the proper way to use this constant when strictures
> are enabled?
> 
> Thanks,
> Wade

HTH - keith


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

Date: Sat, 24 Apr 2004 14:21:24 GMT
From: "H. Wade Minter" <minter@lunenburg.org>
Subject: Re: Proper way to use an imported constant under 'use strict'?
Message-Id: <EJuic.37562$6m4.1685429@twister.southeast.rr.com>

ko <kuujinbo@hotmail.com> wrote:
>> if ( "$^O" eq "MSWin32" )
> 
> [snip code]
> 
>> However, when strict subs are enabled, I get an error about barewords:
>> 
>> [minter@localhost mrvoice]$ ./mrvoice.pl
> --^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------
> 
> That doesn't look like a M$ shell, cygwin? It wasn't specified whether 
> or not the appication runs if 'use strict' is commented out.
> 
> If you *are* running under cygwin, none of the modules will have been 
> included because $^O eq 'cygwin', and you'll get the error that you 
> quoted below:

No, I was running that test under Linux, but the strict subs pragma was
catching the constant there, too.  The two solutions that worked were
to either disable strict subs in that block or qualify the constant
with NORMAL_PRIORITY_CLASS() parens.  It's all good now!

--Wade


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

Date: Sat, 24 Apr 2004 12:15:54 -0700
From: "Robin" <robin @ infusedlight.net>
Subject: Re: regexp quick reference card
Message-Id: <c6efqt$mm8$4@reader2.nmix.net>


"fenisol3" <olusola.o.olaode@intel.com> wrote in message
news:c6c489$huk$1@news01.intel.com...
> Hello all,
>
> Does anyone know where I can find like a cheatsheet or quick reference
card
> for Perl regular expressions online? Thanks.
>
> -fenisol3

there's tons of sites. Try http://learn.perl.org or if you have like $25 you
can get the quick perl reference. Cheers,
-Robin




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

Date: 24 Apr 2004 18:13:33 GMT
From: ctcgag@hotmail.com
Subject: Re: RFC: Text similarity
Message-Id: <20040424141333.201$1E@newsreader.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On Fri, 23 Apr 2004 14:16:53 +0200, Tore Aursand <tore@aursand.no>
> wrote:
>
> >I have a large (more than 3,000 at the moment) set of documents in
> >various formats (mostly PDF and Word).  I need to create a sort of (...)
> >index of these documents based on their similarity.  I thought it would
> >be nice to gather some suggestions from the people in this group before
> >I proceeded.
>
> I know that this may seem naive, but in a popular science magazine I
> read that a paper has been published about a technique that indeed
> identifies the (natural) language some documents are written in by
> compressing (e.g. LZW) them along with some more text from samples
> taken from a bunch of different languages and comparing the different
> compressed sizes. You may try some variation on this scheme...

I've tried this in various incarnations.  It works well for very short
files, but for longer files it takes some sort of preprocessing.  Most
compressors either operate chunk-wise, starting over again once the
code-book is full, or have some other mechanism that compresses only
locally.  So you if just append documents, and they are long, then the
compressor will have forgotten about the section of one docuemnt by the
time it gets to the corresponding part of another document.

Xho


>
> I for one would be interested in the results, BTW!
>
> Michele

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Sat, 24 Apr 2004 09:54:49 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: script too slow - sometimes hangs
Message-Id: <slrnc8kvtp.91o.tadmc@magna.augustmail.com>

The King of Pots and Pans <King@ask.for.email.invalid> wrote:

> I wrote the following perl script to wander through my hard drive
> (from current working directory) and tell me how many of which file
> types I have. It works for small directory hierarchies. It seems to
> freeze up on some arbitrary file when trundling through a large
> directory hierarchy. Not sure why.


Probably a circular symref, easily fixed by using a module that
avoids cycles instead of attempting to write it yourself.


> How can it be
> faster?


I don't know.

I expect file(1) is where the time is spent. Have you found a
module that will detect file types instead of shelling out?

(like mabye File::Type)


> #!/usr/bin/perl -w


   use warnings;  # better than -w if you have a modern perl


>        $output =~ /can\'t stat/)


Single quotes are not special in regexes/strings, no back slash needed.


> sub recurse_dir


   use File::Find;


> 	    chdir("$cwd/$_");
> 	    recurse_dir($_);
> 	    chdir($cwd);


If the chdir's fail you will never know it because you are
not checking the return values:

   chdir($cwd) or die "could not cd to '$cwd'  $!";

(but that whole issue will go away when you change to File::Find)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 24 Apr 2004 11:10:02 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: script too slow - sometimes hangs
Message-Id: <pan.2004.04.24.15.10.01.564950@remove.adelphia.net>

On Sat, 24 Apr 2004 08:12:16 +0000, The King of Pots and Pans wrote:

> I wrote the following perl script to wander through my hard drive
> (from current working directory) and tell me how many of which file
> types I have. It works for small directory hierarchies. It seems to
> freeze up on some arbitrary file when trundling through a large
> directory hierarchy. Not sure why.

[ ... ]
 
> #!/usr/bin/perl -w
> 
> use strict;
> use Cwd;
> 
> my %ftype;
> my $total_files = 0;
> 
> sub classify_file
> {
>     my $output = `file $_`;
>     
>     # ignore these ones
>     if($output =~ /broken symbolic link/ or
>        $output =~ /symbolic link to/ or
>        $output =~ /can\'t stat/)
>     {
>         return;
>     }
>        
>     # remove filename
>     $output =~ s/.+: //;
>     
>     # increment value for this key
>     ++$ftype{$output};
>     ++$total_files;
> }
> 
> sub recurse_dir
> {    
>     # only get cwd, faster that way
>     my $cwd = getcwd();
>     
>     # read all files in current dir
>     foreach(<*>)
>     {
> 	# recurse into directories
> 	if(-d $_)
> 	{
> 	    chdir("$cwd/$_");
> 	    recurse_dir($_);
> 	    chdir($cwd);
> 	}
> 	
>         # perform the 'file' shell command
>         classify_file("$cwd/$_");
>     }
> }
> 
> print "\nClassifying all files recursively...";
> recurse_dir(getcwd());
> print "\nFound $total_files files.";
> print "\n";
> 
> # print in descending order by value
> foreach my $key (sort { $ftype{$b} <=> $ftype{$a} } (keys %ftype))
> {
>     print "$ftype{$key} - $key";
> }

`perldoc File::Find`
It's easier to use File::Find to recurse directories than using Cwd.

Just a suggestion :-)
HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
 Computer programmers do it byte by byte 
 
 


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

Date: Sat, 24 Apr 2004 11:19:41 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: script too slow - sometimes hangs
Message-Id: <opSdnXzw4N8NGBfdRVn_iw@adelphia.com>

The King of Pots and Pans wrote:

> It uses the 'file' shell command, and is extremely slow!

Have a look at File::MMagic.

sherm--

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


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

Date: Sun, 25 Apr 2004 00:03:12 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: slurp not working? ideas please!
Message-Id: <c6dvjj$b78fr$1@ID-227975.news.uni-berlin.de>

Geoff Cox wrote:
> On 24 Apr 2004 04:54:16 GMT, "Tassilo v. Parseval"
> <tassilo.parseval@rwth-aachen.de> wrote:
> 
> 
> 
>>For one, it would help to remove the File::Find dependecy and post code
>>that only works on one input file. That way, someone could put the input
>>file and the two other files opened by your program into one directory.
> 
> 
> Tassilo,
> 
> OK - have tried to follow your suggestions in cutting down the code
> etc.
> 
> The code and the 3 files test.htm, db.txt and allphp2.php can be in
> the same folder. The results will appear in results.htm. Hope this can
> allow you to see why the oder in results.htm is not the same as that
> in test.htm ...
> 
> Cheers
> 
> Geoff
> 

[snip code/test files]

Before starting, note that this is just a suggestion/alternate solution. 
I also thought the examples given by Tassilo in one of your other 
threads were excellent and learned a lot, but being a newbie to 
OO/subclassing/callbacks it seems like you may be focusing too much on 
those parts of your code. I say that because I ran the code you supplied 
and the output file *was* in the same order as your test.htm. Maybe the 
problem is elsewhere?

I haven't followed this thread in its entirety, but if you're only 
interested in a small set of events and doing relatively straightforward 
parsing as in your example, you can also use regular subroutines to 
parse the HTML. Something like this:

use strict;
use warnings;
use HTML::Parser;

my $data;
{ local $/; $data = <DATA> }

my @to_print = qw[h2 p];
my @get_attr = qw[option];
my $current_tag = '';

my $parser = HTML::Parser->new
   (
     report_tags => [ @to_print,   @get_attr             ],
     default_h   => [ \&default,   'text'                ],
     start_h     => [ \&start_tag, 'tagname, attr, text' ],
   )->parse( $data ) or die $!;

sub start_tag {
   my ($tag, $attr, $text) = @_;
   $current_tag = $tag;
   ( grep { $current_tag eq $_ } @to_print )
     ? print $text
     : print $attr->{value};
}

sub default {
   print shift if grep { $current_tag eq $_ } @to_print;
}
__DATA__
<html>
<head><title>test</title>
</head>
<body>

<h2>Finance </h2>

<p> description re Finance document</p>

<option
value="docs/gcse/student-activities/finance">Marketing</option>

<h2>Marketing</h2>

<p> description re marketing document </p>

<option
value="docs/gcse/student-activities/marketing">Marketing</option>

</body>
</html>
__END__

Worth noting:

1. You're only looking for three tags in your example, so its a good 
idea to use the 'report_tags' key (method) in the new() constructor. 
Basically it allows the parser to skip all tags not specified and makes 
it more efficient. You get both start and end events, and text events in 
between. The default handler above picks up the end/text events.

2. Just skimmed through your code, but if I understood correctly you 
only want to (a) print 'p' and 'h2' tags and *text* inside of the tags, 
or (b) get the 'value' attribute of 'option' tags. You should probably 
add a test in the start_tag sub to make sure there is a 'value' attribute.

3. As in your existing code you need to reset $current_tag for each file 
parsed.

4. Guilty of using grep in void context - this is a FAQ, but this is 
just a short example.

HTH -keith


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

Date: Sat, 24 Apr 2004 12:41:52 +0200
From: Mike Mimic <ppagee@yahoo.com>
Subject: Re: Text-oriented network protocols
Message-Id: <zxric.1529$37.218415@news.siol.net>

Hi!

Joe Smith wrote:
> Summary: network protocols are more flexible and easier to debug when
> the commands and responses are plain text, and only the payload (raw
> data) is transfered as a binary stream of single bytes.

This is not a Perl question anymore but anyway:

How than you know when data stream (binary stream) has ended?
You specify length in advance? But what if length is not known
than yet? How does FTP solve this? Is there some good page about
this?


Mike


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

Date: Sat, 24 Apr 2004 11:01:13 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Text-oriented network protocols
Message-Id: <pan.2004.04.24.15.01.07.661473@remove.adelphia.net>

On Sat, 24 Apr 2004 12:41:52 +0200, Mike Mimic wrote:

> Joe Smith wrote:
>> Summary: network protocols are more flexible and easier to debug when
>> the commands and responses are plain text, and only the payload (raw
>> data) is transfered as a binary stream of single bytes.
> 
> This is not a Perl question anymore but anyway:

In a way, it is :-)
 
> How than you know when data stream (binary stream) has ended? You
> specify length in advance? But what if length is not known than yet? How
> does FTP solve this? Is there some good page about this?

  In *most* cases, there is a module out there to accomplish whatever
  networking issue you have (for example, there is
Net::FTP to interact with an FTP server in Perl :-) ).  In short - someone
has already solved to problem for you and made code available ... so you
too can solve your problems ... in Perl :-)

Licoln Stein wrote a book entitled "Network Programming with Perl".  The
source code for the examples is available at
http://modperl.com:9000/perl_networking/.  You could download the examples
and look them over.

I'd also suggest, at least, looking over some of the RFC's on the aspects
of networking that pertain to what you're trying to accomplish
(http://www.rfc.net).

And .... you could use Google to search this newsgroup to find code
examples and discussions.

All of this in pursuit of knowing how to do network programming in Perl
:-)

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
 "Why is it that we rejoice at a birth and grieve at a funeral?  
 It is because we are not the person involved"   -- Mark Twain 
 


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

Date: Sat, 24 Apr 2004 11:12:20 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Text-oriented network protocols
Message-Id: <jd6dnVaM1ZJIHhfdRVn-vw@adelphia.com>

Mike Mimic wrote:

> How than you know when data stream (binary stream) has ended?
> You specify length in advance? But what if length is not known
> than yet? How does FTP solve this?

I haven't done raw FTP in years - there are modules for that now. If memory
from writing a 16-bit VBX for Windows 3.1 serves, however...

FTP uses two sockets, a command socket and a data socket. The client sends
the transfer request over the command socket. The data socket is then
created (how that happens depends on whether passive mode is used), and the
data sent.

After it finishes sending data, the server sends the "transfer complete" and
"x bytes sent" responses on the command socket. The client can then take
the appropriate action, depending on whether it has received that many
bytes on the data socket.

I don't know if there are any FTP servers that are capable of serving
dynamic content. If so, I would assume they'd handle it differently than an
HTTP server would. HTTP sends the Content-length header before the content,
so it needs to buffer a dynamic response until its final length can be
determined. A dynamic FTP server wouldn't need to do that; it could simply
count the bytes sent and report the total when it's done sending.

As I said though - if memory serves. It's been ten years, so take it with a
whole shaker of salt. ;-)

> Is there some good page about this?

Dunno. You could always download the source for the Net::FTP module and have
a look if you're curious about how it might be done in Perl.

sherm--

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


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

Date: 24 Apr 2004 17:12:01 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Text-oriented network protocols
Message-Id: <c6e751$887$1@canopus.cc.umanitoba.ca>

In article <jd6dnVaM1ZJIHhfdRVn-vw@adelphia.com>,
Sherm Pendley  <spamtrap@dot-app.org> wrote:
:I don't know if there are any FTP servers that are capable of serving
:dynamic content. If so, I would assume they'd handle it differently than an
:HTTP server would. HTTP sends the Content-length header before the content,
:so it needs to buffer a dynamic response until its final length can be
:determined.

HTTP servers have other options. They can send a Multipart/related header,
and send a text/html header (with Content-length) for the part that they 
already know. The second "part" can then be another text/html or
image/jpeg or whatever header if it is the last part, but it can
be another Multipart header if there are more parts yet to come.

You can do "animation" of an indefinite length using this technique:
just keep sending Multipart headers as prefixes as long as you think
there might be more to send later, and then send the next fixed-length
content as soon as it is available.
-- 
Take care in opening this message: My grasp on reality may have shaken
loose during transmission!


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

Date: Sun, 25 Apr 2004 00:02:09 +0200
From: Mike Mimic <ppagee@yahoo.com>
Subject: Re: Text-oriented network protocols
Message-Id: <mvBic.1544$37.221753@news.siol.net>

Hi!

Walter Roberson wrote:
> In article <jd6dnVaM1ZJIHhfdRVn-vw@adelphia.com>,
> Sherm Pendley  <spamtrap@dot-app.org> wrote:
> :I don't know if there are any FTP servers that are capable of serving
> :dynamic content. If so, I would assume they'd handle it differently than an
> :HTTP server would. HTTP sends the Content-length header before the content,
> :so it needs to buffer a dynamic response until its final length can be
> :determined.
> 
> HTTP servers have other options. They can send a Multipart/related header,
> and send a text/html header (with Content-length) for the part that they 
> already know. The second "part" can then be another text/html or
> image/jpeg or whatever header if it is the last part, but it can
> be another Multipart header if there are more parts yet to come.
> 
> You can do "animation" of an indefinite length using this technique:
> just keep sending Multipart headers as prefixes as long as you think
> there might be more to send later, and then send the next fixed-length
> content as soon as it is available.

Thanks to all of you.


Mike


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

Date: 24 Apr 2004 11:53:03 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: What kind of RegEx should I use for <TEXTAREA>?
Message-Id: <slrnc8kl8v.egl.abigail@alexandra.abigail.nl>

W. D. (NewsGroups@US-Webmasters.com) wrote on MMMDCCCLXXXVIII September
MCMXCIII in <URL:news:4088C3EB.2A40@US-Webmasters.com>:
[]  Hi Folks,
[]  
[]  If a form has a <TEXTAREA> box to input all sorts of free-form
[]  text, is it necessary to do a regular expressions validation?
[]  That is, are there any dangerous characters that shouldn't be
[]  allowed?

You tell us. Characters are only "dangerous" depending on how you
use them. Since you don't tell us how you use them, it's impossible
to determine from your question.


Abigail
-- 
#!/opt/perl/bin/perl -w
$\ = $"; $SIG {TERM} = sub {print and exit};
kill 15 => fork for qw /Just another Perl Hacker/;


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

Date: Sat, 24 Apr 2004 18:52:24 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: Where is PL_stack_base defined???
Message-Id: <c6ed18$9a2$1@reader2.panix.com>




I'm going blind reading the Perl source!  It's chaos!!!

Where is PL_stack_base defined???

I know about perlguts, but it is of no help with questions like
this.  Is there any other guide to the Perl source code?

Thanks!

jill

-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



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

Date: 24 Apr 2004 21:28:02 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Where is PL_stack_base defined???
Message-Id: <c6em52$avdtc$1@ID-231055.news.uni-berlin.de>

Also sprach J Krugman:

> I'm going blind reading the Perl source!  It's chaos!!!

There are rumours that perl has initially really just been an
experiment to prove that a program can be written only by using the
preprocessor. It eventually failed and that's the reason why you'll
occasionally find a few lines of C code sprinkled in between the
preprocessor directives.

> Where is PL_stack_base defined???

Most of that stuff is defined in intrpvar.h and thrdvar.h. These two
headers list all the fields of 'struct interpreter'. A few hundred
macros eventually transform PL_stack_base into Tstack_base which is then
inserted into 'struct interpreter' via thrdvar.h (see perl.h). The
actual definition is done with

    PERLVAR(Tstack_base, SV **);

which translates into

    SV ** Tstack_base;

That means that PL_stack_base is just a pointer to a pointer of scalars
which makes sense for a stack.

> I know about perlguts, but it is of no help with questions like
> this.  Is there any other guide to the Perl source code?

Maybe

    <http://gisle.aas.no/perl/illguts/>

can help a bit.

Other than that, there is no real guide to the source that I know of.
Everyone has acquired his own set of secret source reading and
understanding skills. They are not secret by malice but because they are
hard to formalize and be put into words.

My trick is to skip those parts I don't understand and conclude that I
probably don't need to understand them. This works well 90% of the time.
To resolve the remaining 10%, a few consoles, grep and patience usually
help.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Sat, 24 Apr 2004 18:35:00 GMT
From: "Trebor A. Rude" <treborrude@SPAMBGONE.comcast.net>
Subject: Which statement is "better", and why?
Message-Id: <nryic.26817$GR.3443912@attbi_s01>

I'm new to Perl (although I have about 7 years of C++ experience), and I was
just wondering which of these two equivalent statements the group thinks is
"better", and why:

push @command, map {exists $options{$_} ? ($options{$_}, $comments{$_}) :
()} keys %comments;

push @command, map {($options{$_}, $comments{$_})} grep exists $options{$_},
keys %comments;

What I'm doing: I have a hash (%comments) of comments from an ogg file and I
want to construct a command to pass to system() that will set the same tags
in an mp3 file (using the "id3v2" command-line program). The ogg will
typically have more tags in it than id3v2 can handle, so I need to select
just those comments that have equivalents in id3v2 tags (I've set them up
in the %options hash, with the ogg tag as the key and command-line switch
for the id3v2 program as the value). Both statements above do just that,
but I was wondering what the advantages and disadvantages of each are.

Trebor



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

Date: Sat, 24 Apr 2004 23:13:34 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: Which statement is "better", and why?
Message-Id: <gvll80h82fmdsc0f4a0ubqjf3rr55do2m6@4ax.com>

X-Ftn-To: Trebor A. Rude 

"Trebor A. Rude" <treborrude@SPAMBGONE.comcast.net> wrote:
>push @command, map {exists $options{$_} ? ($options{$_}, $comments{$_}) :
>()} keys %comments;
>
>push @command, map {($options{$_}, $comments{$_})} grep exists $options{$_},
>keys %comments;
>
>What I'm doing: I have a hash (%comments) of comments from an ogg file and I
>want to construct a command to pass to system() that will set the same tags
>in an mp3 file (using the "id3v2" command-line program). The ogg will
>typically have more tags in it than id3v2 can handle, so I need to select
>just those comments that have equivalents in id3v2 tags (I've set them up
>in the %options hash, with the ogg tag as the key and command-line switch
>for the id3v2 program as the value). Both statements above do just that,
>but I was wondering what the advantages and disadvantages of each are.

There is no particular advantage for any of examples so you may consider
their speed (check perldoc Benchmark) or readability. I would pick second
one and write it like this,

push @command, 
  map { $options{$_}, $comments{$_} } 
  grep exists $options{$_},
  keys %comments;


ps. it seems that your followup is to ng which doesn't exists (at least not
on my server)


-- 
Matija


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

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


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