[26273] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8455 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 25 21:05:25 2005

Date: Sun, 25 Sep 2005 18:05:04 -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           Sun, 25 Sep 2005     Volume: 10 Number: 8455

Today's topics:
    Re: complete manual and reference <tadmc@augustmail.com>
    Re: FAQ 4.42 How can I tell whether a certain element i axel@white-eagle.invalid.uk
    Re: Packing/Unpacking bit fields from a byte. <tadmc@augustmail.com>
    Re: Packing/Unpacking bit fields from a byte. <shashank@mia.ece.uic.edu>
    Re: problem with perldoc <tadmc@augustmail.com>
    Re: problem with perldoc <sherm@dot-app.org>
    Re: problem with perldoc axel@white-eagle.invalid.uk
    Re: problem with perldoc <bertilow@gmail.com>
    Re: regex, number of matches <abigail@abigail.nl>
    Re: regex, number of matches <john@castleamber.com>
    Re: regex, number of matches <john@castleamber.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 25 Sep 2005 13:07:59 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: complete manual and reference
Message-Id: <slrndjdprv.abi.tadmc@magna.augustmail.com>

nobody <nomail@nomail.com> wrote:
> 
> where can i get a complete manual and a complete reference for understanding
> perl language?


( I don't know what the distinction between "manual" and "reference" is. )


The documentation for Perl is part of the perl distribution.

If you install perl, you will have installed the docs too.

You can access them using the "perldoc" utility, which is also
part of a normal perl install.


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


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

Date: Sun, 25 Sep 2005 19:44:27 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: FAQ 4.42 How can I tell whether a certain element is contained in a list or array?
Message-Id: <v6DZe.7097$fl6.6646@fe2.news.blueyonder.co.uk>

Bill Segraves <segraves_f13@mindspring.com> wrote:
> "John Bokma" <john@castleamber.com> wrote in message

>> Write? Does it have to be in Perl? There is plenty of Wiki software etc.
>> out there, probably not written in Perl, but I don't care about that. The
>> OS I use is not written in Perl either :-)
 
> OTOH, there is at least one that *is* written in Perl, e.g.,
 
> http://c2.com/cgi/wiki?QuickiWiki
> http://c2.com/cgi/wiki?ClusterWiki
> http://www.wiki.org/
 
>> So what are the next steps to have a Perl wiki? Especially for the FAQ
>> part?
 
> 1. Download and install QuickiWiki.
> 2. Write a script to extract Usenet clpm postings from the PerlFAQ server
> into Wiki format.

And then decide both on a political and technical level how and when the
actual FAQ would be updated; or *if* changes would be fed back in or should
the Wiki version would just develop separately as an additional resource.

Axel
 


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

Date: Sat, 24 Sep 2005 19:17:36 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Packing/Unpacking bit fields from a byte.
Message-Id: <slrndjbr50.taj.tadmc@magna.augustmail.com>

Shashank R Khanvilkar <skhanv1@uic.edu> wrote:

> say 4 bytes long
> and contains many fields which are not byte aligned.


> I have already written a lengthy routing to unpack these fileds from the
> header (using shifts and masks).


   perldoc -f vec


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


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

Date: Sun, 25 Sep 2005 13:21:44 -0500
From: Shashank Khanvilkar <shashank@mia.ece.uic.edu>
Subject: Re: Packing/Unpacking bit fields from a byte.
Message-Id: <Pine.LNX.4.61.0509251317250.26203@mia.ece.uic.edu>


Thanks
I have already checked out vector. It does not help.
Howver I now found out that the following works.

@headerFeilds = unpack("A12A1A2....", unpack("B*", $header));

The innermost unpack first converts the header to a string of bits.
the outer unpack just seperates out these bits into the fields.


Let me know if there is anything better than this.
Shashank


On Sat, 24 Sep 2005, Tad McClellan wrote:

> Shashank R Khanvilkar <skhanv1@uic.edu> wrote:
>
>> say 4 bytes long
>> and contains many fields which are not byte aligned.
>
>
>> I have already written a lengthy routing to unpack these fileds from the
>> header (using shifts and masks).
>
>
>   perldoc -f vec
>
>
> -- 
>    Tad McClellan                          SGML consulting
>    tadmc@augustmail.com                   Perl programming
>    Fort Worth, Texas
>


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

Date: Sat, 24 Sep 2005 19:21:51 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: problem with perldoc
Message-Id: <slrndjbrcv.taj.tadmc@magna.augustmail.com>

Apostolos P. Tsompanopoulos <tosoAplos@earth.space> wrote:

> I have only v5.8.3 installed *BUT* (maybe
> during the upgrade) I probably forgot to upgrade perl-doc(s), which
> is v5.8.1


The perldoc program and the *.pod files are part of a normal install,
so they should have been already upgraded.


> I'll look
> also to the direction of upgrading my perl-doc!


Try simply finding where it was put when you installed v5.8.3 first.


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


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

Date: Sun, 25 Sep 2005 14:35:22 -0400
From: Sherm Pendley <sherm@dot-app.org>
Subject: Re: problem with perldoc
Message-Id: <m21x3dvvv9.fsf@Sherm-Pendleys-Computer.local>

Tad McClellan <tadmc@augustmail.com> writes:

> Apostolos P. Tsompanopoulos <tosoAplos@earth.space> wrote:
>
>> I have only v5.8.3 installed *BUT* (maybe
>> during the upgrade) I probably forgot to upgrade perl-doc(s), which
>> is v5.8.1
>
> The perldoc program and the *.pod files are part of a normal install,
> so they should have been already upgraded.

They're part of a normal manual install, but some Linux distributions
break the docs out into separate optional packages.

sherm--

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


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

Date: Sun, 25 Sep 2005 19:35:35 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: problem with perldoc
Message-Id: <b_CZe.7087$fl6.6497@fe2.news.blueyonder.co.uk>

Sherm Pendley <sherm@dot-app.org> wrote:
> Tad McClellan <tadmc@augustmail.com> writes:
 
>> Apostolos P. Tsompanopoulos <tosoAplos@earth.space> wrote:

>>> I have only v5.8.3 installed *BUT* (maybe
>>> during the upgrade) I probably forgot to upgrade perl-doc(s), which
>>> is v5.8.1

>> The perldoc program and the *.pod files are part of a normal install,
>> so they should have been already upgraded.
 
> They're part of a normal manual install, but some Linux distributions
> break the docs out into separate optional packages.

Mandrake being one I found out much to my annoyance.

Axel
 


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

Date: Mon, 26 Sep 2005 09:26:38 +0900
From: Bertilo Wennergren <bertilow@gmail.com>
Subject: Re: problem with perldoc
Message-Id: <dh7f8f$d98$1@domitilla.aioe.org>

axel@white-eagle.invalid.uk:

>>> The perldoc program and the *.pod files are part of a normal install,
>>> so they should have been already upgraded.

>> They're part of a normal manual install, but some Linux distributions
>> break the docs out into separate optional packages.

> Mandrake being one I found out much to my annoyance.

Ubuntu seems to be another on (as I just found out).
Ubuntu users can do:

   sudo apt-get install perl-doc

The same probably works for many other Debian-based Linux distibutions.

-- 
Bertilo Wennergren <http://bertilow.com>


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

Date: 25 Sep 2005 22:48:07 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: regex, number of matches
Message-Id: <slrndjea96.9lk.abigail@alexandra.abigail.nl>

Dr.Ruud (rvtol+news@isolution.nl) wrote on MMMMCDVIII September MCMXCIII
in <URL:news:dh6ktk.1j4.1@news.isolution.nl>:
,,  Brian Wakem schreef:
,,  
,, > The fastest way is to substitute a match with itself.
,,  
,,  
,,  Not for (counting) random words, the destructive
,,  substition 's/\S+/./g' is faster than 's/(\S+)/\1/'.
,,  (even 50% faster than the '++ while /\S+/g')
,,  
,,    list  => '$list  = 0; $list  += ()     = (/\S+/g) for @data;',
,,    sub   => '$sub   = 0; $sub   +=     s/(\S+)/$1/g  for @data;',
,,    sub2  => '$sub2  = 0; $sub2  +=     s/(\S+)/\1/g  for @data;',
,,    sub3  => '$sub3  = 0; $sub3  +=        s/\S+/./g  for @data;',
,,    while => '$while = 0; do {$while++ while  /\S+/g} for @data;',
,,  
,,             Rate   sub  sub2  list while  sub3
,,    sub    5318/s    --   -2%  -24%  -52%  -68%
,,    sub2   5420/s    2%    --  -22%  -51%  -68%
,,    list   6990/s   31%   29%    --  -37%  -58%
,,    while 11120/s  109%  105%   59%    --  -34%
,,    sub3  16809/s  216%  210%  140%   51%    --


That's not a fair benchmark. After the first iteration, all the sequences
of non-space characters have been collapsed to single characters -
reducing the sizes of the strings to match against. And that's of course
faster.  It will also influence all tests run after the 'sub3' test.

Having said that, there's still a way to speed up the counting of words,
and that involves entering the regexp engine once, instead of once for
each line:


cmpthese -1   => {
    list      => '$list    = 0; $list     += ()     = /\S+/g      for @data;',
    list2     => '$list2   = 0; $list2    += (my @t = /\S+/g)     for @data;',
    while     => '$while   = 0; do {$while ++ while   /\S+/g}     for @data;',
    sub       => '$sub     = 0; $sub      +=        s/(\S+)/$1/g  for @data;',
    sub2      => '$sub2    = 0; $sub2     +=         s/\S+/$&/g   for @data;',
    join      => '$join    = 0; my $c = join "" => @data;
                                $join ++ while $c =~  /\S+/g',
};



        Rate   sub  list list2 while  join
sub   2071/s    --  -28%  -30%  -59%  -65%
list  2890/s   39%    --   -2%  -42%  -52%
list2 2942/s   42%    2%    --  -41%  -51%
while 5019/s  142%   74%   71%    --  -16%
join  5973/s  188%  107%  103%   19%    --



Abigail
-- 
@;=split//=>"Joel, Preach sartre knuth\n";$;=chr 65;%;=map{$;++=>$_}
0,22,13,16,5,14,21,1,23,11,2,7,12,6,8,15,3,19,24,14,10,20,18,17,4,25
;print@;[@;{A..Z}];


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

Date: 25 Sep 2005 23:24:57 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: regex, number of matches
Message-Id: <Xns96DCBACD46142castleamber@130.133.1.4>

"Dr.Ruud" <rvtol+news@isolution.nl> wrote:

> John Bokma schreef:
>> Dr.Ruud:
>>> Dr.Ruud:
> 
>>>> OK, let me read Apocalypse-5 first.
>>>
>>> Looks good:
>>>   my $foo = +/.../;   # numeric context, return count of matches
>>
>> Yup, I would prefer that over the t thingy :-)
> 
> See Apocalypse-5:
> http://www.perl.com/pub/a/2002/06/04/apo5.html?page=18
> "If it turns out we do need an option, it'll probably be: n."

Thanks, I have reading "Perl 6 info" on my list for ages now, time to start 
reading :-)

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: 25 Sep 2005 23:28:42 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: regex, number of matches
Message-Id: <Xns96DCBB7071306castleamber@130.133.1.4>

"Dr.Ruud" <rvtol+news@isolution.nl> wrote:

> John Bokma schreef:
>> Dr.Ruud:
>>> Abigail:
>>>
>>>> [$&]
>>>> it's not easy to determine those special circumstances.
>>>
>>> How about something like '\&' that can only be used in the
>>> replace-part?
>>
>> Just because you don't want to use () in the regexp part?
> 
> The answer is in "can only be used in the replace-part".

Yes, I understand that part :-) Regexes are already extremely complex (I 
have often to look up things), and adding more clutter doesn't seem the 
answer (to me) that is.

How often do you neet the \& thing.

> With () you need $1, and that involves setting up a variable.

And what is \&? And where is the info it contains stored?

-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

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


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