[30965] in Perl-Users-Digest
Perl-Users Digest, Issue: 2210 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 15 09:09:44 2009
Date: Sun, 15 Feb 2009 06:09:06 -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 Sun, 15 Feb 2009 Volume: 11 Number: 2210
Today's topics:
* Take it like a man live screen shots job8v9@gmail.com
new CPAN modules on Sun Feb 15 2009 (Randal Schwartz)
Re: question on de-referencing expressions <jurgenex@hotmail.com>
Regexp discovery - using ^ with /m is a time sink <koszalekopalek@interia.pl>
Re: Regexp discovery - using ^ with /m is a time sink <nospam-abuse@ilyaz.org>
restrict a hash to 15 pairs and iterate over it <mstep@podiuminternational.org>
Re: restrict a hash to 15 pairs and iterate over it <ben@morrow.me.uk>
Re: restrict a hash to 15 pairs and iterate over it <mstep@podiuminternational.org>
Re: time and place of satellite coincidence <larry@example.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 14 Feb 2009 01:14:27 -0800 (PST)
From: job8v9@gmail.com
Subject: * Take it like a man live screen shots
Message-Id: <f57d13b0-9f4d-41db-99fa-d87c28ba5965@q25g2000vbn.googlegroups.com>
Get stuffed wow http://imival.blogspot.com/ its unbelievable live
screen footage of a professor of lots of little things society of the
mentally gifted.
------------------------------
Date: Sun, 15 Feb 2009 05:42:25 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Feb 15 2009
Message-Id: <KF3EIp.1I1u@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Acme-Mom-Yours-0.01
http://search.cpan.org/~adamk/Acme-Mom-Yours-0.01/
Your mom is so fat she takes 2 months to compile
----
App-Maisha-0.02
http://search.cpan.org/~barbie/App-Maisha-0.02/
A command line social micro-blog networking tool.
----
App-Maisha-0.03
http://search.cpan.org/~barbie/App-Maisha-0.03/
A command line social micro-blog networking tool.
----
App-Sequence-0.03_01
http://search.cpan.org/~kimoto/App-Sequence-0.03_01/
pluggable subroutine engine.
----
App-Sequence-0.03_02
http://search.cpan.org/~kimoto/App-Sequence-0.03_02/
pluggable subroutine engine.
----
Audio-MPD-0.19.6
http://search.cpan.org/~jquelin/Audio-MPD-0.19.6/
class to talk to MPD (Music Player Daemon) servers
----
CGI-Application-Plugin-AutoRunmode-0.16
http://search.cpan.org/~thilo/CGI-Application-Plugin-AutoRunmode-0.16/
CGI::App plugin to automatically register runmodes
----
CPAN-Mini-ProjectDocs-0.02.5
http://search.cpan.org/~nkh/CPAN-Mini-ProjectDocs-0.02.5/
Generates nice module documentation from you CPAN mini
----
CPANPLUS-Dist-Gentoo-0.06
http://search.cpan.org/~vpit/CPANPLUS-Dist-Gentoo-0.06/
CPANPLUS backend generating Gentoo ebuilds.
----
Capture-Tiny-0.01
http://search.cpan.org/~dagolden/Capture-Tiny-0.01/
Capture STDOUT and STDERR from Perl, XS or external programs
----
Chart-Clicker-2.18
http://search.cpan.org/~gphat/Chart-Clicker-2.18/
Powerful, extensible charting.
----
Class-MOP-0.77
http://search.cpan.org/~drolsky/Class-MOP-0.77/
A Meta Object Protocol for Perl 5
----
Class-MethodMaker-2.14
http://search.cpan.org/~schwigon/Class-MethodMaker-2.14/
Create generic methods for OO Perl
----
Class-Monadic-0.01
http://search.cpan.org/~gfuji/Class-Monadic-0.01/
Provides monadic methods (a.k.a. singleton methods)
----
DateTime-Format-Duration-XSD-0.01
http://search.cpan.org/~nuf/DateTime-Format-Duration-XSD-0.01/
----
DateTimeX-Lite-0.00001_02
http://search.cpan.org/~dmaki/DateTimeX-Lite-0.00001_02/
A Low Calorie DateTime
----
EV-3.53
http://search.cpan.org/~mlehmann/EV-3.53/
perl interface to libev, a high performance full-featured event loop
----
Getopt-GUI-Long-0.9
http://search.cpan.org/~hardaker/Getopt-GUI-Long-0.9/
----
Google-Adwords-v1.12
http://search.cpan.org/~rohan/Google-Adwords-v1.12/
an interface which abstracts the Google Adwords SOAP API
----
Graphics-Primitive-0.38
http://search.cpan.org/~gphat/Graphics-Primitive-0.38/
Device and library agnostic graphic primitives
----
HTTP-Engine-Middleware-0.03
http://search.cpan.org/~yappo/HTTP-Engine-Middleware-0.03/
middlewares distribution
----
HeliosX-ExtLoggerService-0.02_0761
http://search.cpan.org/~lajandy/HeliosX-ExtLoggerService-0.02_0761/
Alternative Helios::Service class to log to external logging systems
----
IO-Lambda-1.09
http://search.cpan.org/~karasik/IO-Lambda-1.09/
non-blocking I/O as lambda calculus
----
IPC-MMA-0.5
http://search.cpan.org/~mackenna/IPC-MMA-0.5/
Shared Memory using Ralf Engelschall's mm library
----
Method-Lexical-0.01
http://search.cpan.org/~chocolate/Method-Lexical-0.01/
private methods and lexical method overrides
----
Moose-0.70
http://search.cpan.org/~drolsky/Moose-0.70/
A postmodern object system for Perl 5
----
MooseX-MethodAttributes-0.02
http://search.cpan.org/~flora/MooseX-MethodAttributes-0.02/
code attribute introspection
----
Net-NAT-PMP-0.9.1
http://search.cpan.org/~david/Net-NAT-PMP-0.9.1/
Poke holes in a router's NAT using the nat-pmp protocol
----
Net-NAT-PMP-0.9.2
http://search.cpan.org/~david/Net-NAT-PMP-0.9.2/
Poke holes in a router's NAT using the nat-pmp protocol
----
Net-SloppyXMPP-0.02
http://search.cpan.org/~wilsond/Net-SloppyXMPP-0.02/
A rather sloppy XMPP client implementation
----
Net-Twitter-Cabal-0.02
http://search.cpan.org/~pfig/Net-Twitter-Cabal-0.02/
Manage posters to a Twitter stream
----
Net-Twitter-Cabal-0.03
http://search.cpan.org/~pfig/Net-Twitter-Cabal-0.03/
Manage posters to a Twitter stream
----
Parse-Eyapp-1.138
http://search.cpan.org/~casiano/Parse-Eyapp-1.138/
Extensions for Parse::Yapp
----
Set-Relation-0.7.0
http://search.cpan.org/~duncand/Set-Relation-0.7.0/
Relation data type for Perl
----
Text-RewriteRules-0.17
http://search.cpan.org/~ambs/Text-RewriteRules-0.17/
A system to rewrite text using regexp-based rules
----
TryCatch-1.000001
http://search.cpan.org/~ash/TryCatch-1.000001/
first class try catch semantics for Perl, without source filters.
----
Variable-OnDestruct-0.02
http://search.cpan.org/~leont/Variable-OnDestruct-0.02/
Call a subroutine on destruction of a variable.
----
WWW-Freshmeat-0.10
http://search.cpan.org/~chorny/WWW-Freshmeat-0.10/
automates searches on Freshmeat.net
----
WWW-Spinn3r-3.00700001
http://search.cpan.org/~vipul/WWW-Spinn3r-3.00700001/
An interface to the Spinn3r API (http://www.spinn3r.com)
----
WordNet-SenseRelate-AllWords-0.15
http://search.cpan.org/~tpederse/WordNet-SenseRelate-AllWords-0.15/
Disambiguate All Words in a Text based on semantic similarity and relatedness in WordNet
----
XML-Grammar-Fortune-0.0105
http://search.cpan.org/~shlomif/XML-Grammar-Fortune-0.0105/
convert the FortunesXML grammar to other formats and from plaintext.
----
XML-Table2XML-1.2
http://search.cpan.org/~rkapl/XML-Table2XML-1.2/
Generic conversion of tabular data to XML by reverting Excel's flattener methodology.
----
XML-Table2XML-1.2-withoutworldwriteables
http://search.cpan.org/~rkapl/XML-Table2XML-1.2-withoutworldwriteables/
Generic conversion of tabular data to XML by reverting Excel's flattener methodology.
----
XML-Table2XML-1.3
http://search.cpan.org/~rkapl/XML-Table2XML-1.3/
Generic conversion of tabular data to XML by reverting Excel's flattener methodology.
----
pod-mode-0.502
http://search.cpan.org/~schwigon/pod-mode-0.502/
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Sat, 14 Feb 2009 07:00:24 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: question on de-referencing expressions
Message-Id: <crmdp457fm2pljdscopu8pt1tj0jegvp83@4ax.com>
Ted Zlatanov <tzz@lifelogs.com> wrote:
>GH> my %hash = %{ functionReturningReference() };
>
>It's worth noting here that if the returned value is undef, the program
>will die here. This is why I always use an intermediate variable and
>test if for definedness, even if it takes a few more lines.
If undef is a possible return value according to the function's
specificiation, then that is certainly a very good idea.
If not then something must have gone terribly wrong and die()ing in the
face of an illegal return value is maybe not such a bad thing.
jue
------------------------------
Date: Sat, 14 Feb 2009 15:06:03 -0800 (PST)
From: Koszalek Opalek <koszalekopalek@interia.pl>
Subject: Regexp discovery - using ^ with /m is a time sink
Message-Id: <15209417-30f8-49df-94cc-2710d2f69b57@b38g2000prf.googlegroups.com>
#!/usr/bin/perl
=pod
The code below benchmarks two regexp's that look for lines
starting with the equals sign in a multiline string. The
regexps differ only by how the line break is detected.
The first regexp uses the ^ metacharacter and the /m flag:
qr{\G^=[^\n]*}ism
The other relies on a negative look-behind assertion:
qr{\G(?<=\n)=[^\n]*}ism
One difference between the two regexps is that the ^
version matches '=' at the beginning of the string,
whereas the other does not. But there is something
else as well. The second version is at least 50 times
faster!
Note that both regexps use the \G assertion (match only at
pos()) -- and the position is set to a random number in each
loop iteration. I assumed both regexp's will be very fast
(because the have to be checked only at one pos in string)
-- apparently not so.
Could someone explain what's going behind the scenes in
the regexp engine? Is it scanning the complete string for
line breaks if I use ^, even though it has to match only
at pos() ?
K.
=cut
use strict;
use Time::HiRes qw( time );
$| = 1;
my $gibberish;
for( 1 .. 1000 ) {
for( 1 .. int(rand 50) ) {
$gibberish .= chr( int( rand 60) + 32 );
};
$gibberish .= "\n";
}
my $l = length $gibberish;
my $cnt = 100_000;
my @positions;
for( 1 .. $cnt ) { push @positions, int( rand $l) };
print "String length: $l.\n\n";
for my $re (
qr{\G(?<=\n)=[^\n]*}ism,
qr{\G^=[^\n]*}ism,
) {
my $succ = 0;
my $start = time;
foreach ( @positions ) {
pos $gibberish = $_;
$succ++ if( $gibberish =~ m/$re/g );
};
print "Regexp: $re.\n";
print "Successful matches $succ.\n";
printf "Time = %f[s].\n\n", time - $start;
};
print "$cnt matches for each regexp.\n";
------------------------------
Date: Sun, 15 Feb 2009 12:20:25 GMT
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Regexp discovery - using ^ with /m is a time sink
Message-Id: <slrngpg2ep.mli.nospam-abuse@chorin.math.berkeley.edu>
On 2009-02-14, Koszalek Opalek <koszalekopalek@interia.pl> wrote:
> Note that both regexps use the \G assertion (match only at
> pos()) -- and the position is set to a random number in each
> loop iteration. I assumed both regexp's will be very fast
> (because the have to be checked only at one pos in string)
> -- apparently not so.
>
> Could someone explain what's going behind the scenes in
> the regexp engine? Is it scanning the complete string for
> line breaks if I use ^, even though it has to match only
> at pos() ?
There is something fishy with how optimizer treats \G. I might have
skipped some case(s), and it was not corrected in the years passed...
I also found it by benchmarking. Had no time to look into the
sources...
Yours,
Ilya
------------------------------
Date: Sat, 14 Feb 2009 23:51:34 -0800 (PST)
From: Marek <mstep@podiuminternational.org>
Subject: restrict a hash to 15 pairs and iterate over it
Message-Id: <7371a4a0-9797-425e-873d-5d6eb856cc50@p20g2000yqi.googlegroups.com>
Hello all!
I am still a beginner, so please be patient with me.
I have a big file with numbers and dates like follows here:
01.01.98
31
33
14
7
35
16
20
20
13
55
1
1
7
etc etc
I need a complicate hash to know the occurrences of numbers in a scope
of 15:
We skip the dates, and we count the lines. The structure of my %hash
looks like follows:
($number{$line, $line, ...}) => $how_many_times
In my example the 20 occurs in line 7 and 8 -> two times:
20{7,8} => 2
And we iterate over it, and keep only 15 numbers in the hash and count
each time the occurrences of each number.
Could somebody help me with this?
Thank you in advance
marek
------------------------------
Date: Sun, 15 Feb 2009 09:06:47 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: restrict a hash to 15 pairs and iterate over it
Message-Id: <7i2l66-ml6.ln1@osiris.mauzo.dyndns.org>
Quoth Marek <mstep@podiuminternational.org>:
>
> I am still a beginner, so please be patient with me.
That's fine; however, your description isn't really clear enough to
follow. Also, you are expected to at least make an attempt to write the
program yourself before posting.
> I have a big file with numbers and dates like follows here:
>
>
> 01.01.98
> 31
> 33
> 14
> 7
> 35
> 16
> 20
> 20
> 13
> 55
> 1
> 1
> 7
>
>
> etc etc
>
> I need a complicate hash to know the occurrences of numbers in a scope
> of 15:
What do you mean by 'the occurrences of numbers'? Do you mean the number
of times each number shows up, so for a list like
1 2 1 4 2
you would get the results
1: 2 times
2: 2 times
4: 1 time
or do you mean a list of the lines each number shows up on?
> We skip the dates, and we count the lines. The structure of my %hash
> looks like follows:
>
> ($number{$line, $line, ...}) => $how_many_times
While this is valid Perl, it probably isn't what you want to use.
If you need a data structure like this (I'm not yet sure whether you do)
you want something more like
my %numbers = (
20 => [7, 8]
);
You don't need to record the count separately: Perl arrays know how long
they are.
> In my example the 20 occurs in line 7 and 8 -> two times:
>
> 20{7,8} => 2
>
> And we iterate over it, and keep only 15 numbers in the hash and count
> each time the occurrences of each number.
How do you choose which 15 numbers to keep?
> Could somebody help me with this?
Post the code you've got so far, in as close to working condition as you
can get it (that is, make sure there aren't any syntax errors, or bits
left over from things you've tried before).
Ben
------------------------------
Date: Sun, 15 Feb 2009 04:21:04 -0800 (PST)
From: Marek <mstep@podiuminternational.org>
Subject: Re: restrict a hash to 15 pairs and iterate over it
Message-Id: <0d5b47cb-99f3-4ae3-b52f-2c3a669bfceb@z1g2000yqn.googlegroups.com>
On Feb 15, 10:06 am, Ben Morrow <b...@morrow.me.uk> wrote:
>
> What do you mean by 'the occurrences of numbers'? Do you mean the number
> of times each number shows up, so for a list like
>
> 1 2 1 4 2
>
> you would get the results
>
> 1: 2 times
> 2: 2 times
> 4: 1 time
>
yes! :-)
>
> If you need a data structure like this (I'm not yet sure whether you do)
> you want something more like
>
> my %numbers = (
> 20 => [7, 8]
> );
>
> You don't need to record the count separately: Perl arrays know how long
> they are.
>
Thank you! Good idea!
> How do you choose which 15 numbers to keep?
>
>
> Post the code you've got so far, in as close to working condition as you
> can get it (that is, make sure there aren't any syntax errors, or bits
> left over from things you've tried before).
>
> Ben
Thank you Ben for your patience!
1. You are asking for a code. But I am ashamed to post it here,
because it is too childish. I have tried with an array of a reference
to a hash.
2. What I need, you guessed already well:
I have a large file with many numbers in it. Each line a number and
sometimes some dates. I read in from the beginning 15 numbers, here
separated with a tab:
1 2 3 4 1 5 6 7 8 9 10 2 11 12 13 14 15 16 17
^ ^
So the first step would be to read in the numbers until 15th line and
see if there are double numbers or triple numbers. In my example here
there are two 1 and two 2 ... Then I do something with this result and
I read in the next 15 numbers starting with 2 ...
1 2 3 4 1 5 6 7 8 9 10 2 11 12 13 14 15 16 17
^ ^
next step we read in starting with 3
1 2 3 4 1 5 6 7 8 9 10 2 11 12 13 14 15 16 17
^ ^
But you gave already a valuable hint: we only need a hash of each
%number = (1 => [1,5]);
And see how long is the anonymous array. No need to add one level more
to each number and counting their occurrences.
Hope this is clearer now? Thank you again!
marek
------------------------------
Date: Sat, 14 Feb 2009 04:32:54 -0700
From: Larry Gates <larry@example.invalid>
Subject: Re: time and place of satellite coincidence
Message-Id: <az0k2ka63o5p$.1wts49kwabczy$.dlg@40tude.net>
On Fri, 13 Feb 2009 23:42:26 -0600, Tad J McClellan wrote:
> Larry Gates <larry@example.invalid> wrote:
>
>> I have this as a leftover part from previous inquiries:
>>
>> foreach my $elem ( $tree->find_by_attribute('name', 'jd') ) {
>> print $elem->attr('value'), "\n";
>> }
>>
>> This will get me the julian time from this point north and west of the
>> cosmopolitan of yakutsk. How do I instead, give IT the julian time from a
>> perl script?
>
>
> perldoc -q form
>
> How do I automate an HTML form submission?
How do I automate an HTML form submission?
If you are doing something complex, such as moving through many pages
and forms or a web site, you can use "WWW::Mechanize". See its
documentation for all the details.
If you're submitting values using the GET method, create a URL and
encode the form using the "query_form" method:
use LWP::Simple;
use URI::URL;
my $url = url('http://www.perl.com/cgi-bin/cpan_mod');
$url->query_form(module => 'DB_File', readme => 1);
$content = get($url);
If you're using the POST method, create your own user agent and encode
the content appropriately.
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = LWP::UserAgent->new();
my $req = POST 'http://www.perl.com/cgi-bin/cpan_mod',
[ module => 'DB_File', readme => 1 ];
$content = $ua->request($req)->as_string;
I think I can get my head around this.
>
>
>><center><h1>Sky above 65N 90E at Sat 2009 Feb 14 4:33 UTC</h1></center>
>><center>
>>
>> How do I grab what lies between the center tags?
>
>
> ------------------------------
> #!/usr/bin/perl
> use warnings;
> use strict;
> use HTML::TreeBuilder;
> use LWP::Simple;
>
> my $site_url = 'http://www.fourmilab.ch/cgi-bin/Yoursky';
> my $url_args = 'z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
> my $t = get "$site_url?$url_args" || "Problem";
>
> my $tree = HTML::TreeBuilder->new_from_content($t);
>
> foreach my $elem ( $tree->look_down('_tag', 'center') ) {
> print $elem->as_text(), "\n";
> }
> ------------------------------
4:30 local. cputz hago.
--
larry gates
Obviously I was either onto something, or on something.
-- Larry Wall on the creation of Perl
------------------------------
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 V11 Issue 2210
***************************************