[28538] in Perl-Users-Digest
Perl-Users Digest, Issue: 9902 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 28 18:05:54 2006
Date: Sat, 28 Oct 2006 15:05:07 -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, 28 Oct 2006 Volume: 10 Number: 9902
Today's topics:
Finding form field for this html <nospam@home.com>
Re: Finding form field for this html <mark.clementsREMOVETHIS@wanadoo.fr>
Question from the perlmod man pages. <cdalten@gmail.com>
Re: Question from the perlmod man pages. <jgibson@mail.arc.nasa.gov>
queston about appending a variable to a url <nospam@home.com>
Re: queston about appending a variable to a url anno4000@radom.zrz.tu-berlin.de
Re: queston about appending a variable to a url <nospam@home.com>
Re: queston about appending a variable to a url <jurgenex@hotmail.com>
Re: queston about appending a variable to a url anno4000@radom.zrz.tu-berlin.de
Re: queston about appending a variable to a url <jurgenex@hotmail.com>
Re: Store multi-dimensions array for use in latter form <shareparadise@gmail.com>
Re: Store multi-dimensions array for use in latter form <sbryce@scottbryce.com>
Re: Store multi-dimensions array for use in latter form anno4000@radom.zrz.tu-berlin.de
Re: Store multi-dimensions array for use in latter form <shareparadise@gmail.com>
Re: Store multi-dimensions array for use in latter form xhoster@gmail.com
Re: Store multi-dimensions array for use in latter form xhoster@gmail.com
Re: what are the most frequently used functions? <no-spam@no-spam-no-spam.com>
Re: what are the most frequently used functions? <jurgenex@hotmail.com>
Re: what are the most frequently used functions? <no-spam@no-spam-no-spam.com>
Re: what are the most frequently used functions? <rvtol+news@isolution.nl>
Re: what are the most frequently used functions? <barmar@alum.mit.edu>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 28 Oct 2006 19:38:07 GMT
From: "Nospam" <nospam@home.com>
Subject: Finding form field for this html
Message-Id: <zkO0h.40320$Or2.22715@newsfe7-gui.ntli.net>
I can't seem to find the form field or even form name for this particular
page, the relevant html is:
<form method="post" action="/cgi-bin/add_posting.pl" name="add_posting">
<input type="hidden" name="changedImages" value="">
<input type="hidden" name="pid" value="4112">
<input type="hidden" name="posting_cat" value="3749">
<input type="hidden" name="action" value="preview_or_images">
<input type="hidden" name="site_id" value="79">
<input type="hidden" name="posting_id" value="">
I have tried form(1); and it states there is no such form, I have also tried
form("add_posting.pl") and it said no such form "add_posting", the url to
the site is http://hull.gumtree.com/cgi-bin/add_posting.pl?posting_cat=3749
------------------------------
Date: Sat, 28 Oct 2006 22:31:55 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Finding form field for this html
Message-Id: <4543be31$0$25933$ba4acef3@news.orange.fr>
Nospam wrote:
> I can't seem to find the form field or even form name for this particular
> page, the relevant html is:
>
> <form method="post" action="/cgi-bin/add_posting.pl" name="add_posting">
> <input type="hidden" name="changedImages" value="">
> <input type="hidden" name="pid" value="4112">
> <input type="hidden" name="posting_cat" value="3749">
> <input type="hidden" name="action" value="preview_or_images">
> <input type="hidden" name="site_id" value="79">
> <input type="hidden" name="posting_id" value="">
>
> I have tried form(1); and it states there is no such form, I have also tried
> form("add_posting.pl") and it said no such form "add_posting", the url to
> the site is http://hull.gumtree.com/cgi-bin/add_posting.pl?posting_cat=3749
>
>
Works for me.
mark@owl:~/Dev/perl$ cat form.pl
use strict;
use warnings;
use Data::Dumper;
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
my $url =
q(http://hull.gumtree.com/cgi-bin/add_posting.pl?posting_cat=3749);
my $form_name = q(add_posting);
$mech->get( $url );
my $form = $mech->form_name($form_name);
print $form->method()."\n";
print $form->action()."\n";
print join "\n",$form->param(),"\n";
mark@owl:~/Dev/perl$ perl form.pl
POST
http://hull.gumtree.com/cgi-bin/add_posting.pl
changedImages
pid
posting_cat
action
site_id
posting_id
current_live_date
location
location_required
title
description
contact_email
other_contactable
skype_id
anonymous_email
anti_spam
first_name
last_name
user_email
password
action_images
action_preview
mark@owl:~/Dev/perl$
------------------------------
Date: 28 Oct 2006 09:15:51 -0700
From: "grocery_stocker" <cdalten@gmail.com>
Subject: Question from the perlmod man pages.
Message-Id: <1162052151.603188.40550@b28g2000cwb.googlegroups.com>
I'm sort of drawing a stump on the following:
"Perl packages may be nested inside other package names, so we can have
package names containing ::. But if we used that package name directly
as a filename it would make for unwieldy or impossible filenames on
some systems. Therefore, if a module's name is, say, Text::Soundex,
then its definition is actually found in the library file
Text/Soundex.pm."
Say I have a module name Text::Soundex. I use this in my Perl script
as:
use Text::Soundex;
I know there is a module called Soundex.pm. I also know there is a
directory
name with the name Text. However, would there also be a module named
Text.pm?
Chad
------------------------------
Date: Sat, 28 Oct 2006 09:49:08 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Question from the perlmod man pages.
Message-Id: <281020060949089821%jgibson@mail.arc.nasa.gov>
In article <1162052151.603188.40550@b28g2000cwb.googlegroups.com>,
grocery_stocker <cdalten@gmail.com> wrote:
> I'm sort of drawing a stump on the following:
>
> "Perl packages may be nested inside other package names, so we can have
> package names containing ::. But if we used that package name directly
> as a filename it would make for unwieldy or impossible filenames on
> some systems. Therefore, if a module's name is, say, Text::Soundex,
> then its definition is actually found in the library file
> Text/Soundex.pm."
>
> Say I have a module name Text::Soundex. I use this in my Perl script
> as:
>
> use Text::Soundex;
>
> I know there is a module called Soundex.pm. I also know there is a
> directory
> name with the name Text. However, would there also be a module named
> Text.pm?
No, there need not be a module named Text.pm. The pattern A::B is a
naming convention, and does not establish a hierarchical relationship
between modules A and B or their symbol tables. See 'perldoc perlmod'
for details.
------------------------------
Date: Sat, 28 Oct 2006 17:00:40 GMT
From: "Nospam" <nospam@home.com>
Subject: queston about appending a variable to a url
Message-Id: <Y0M0h.30682$w07.21881@newsfe6-win.ntli.net>
I am wondering how I might append a variable onto a url, say for example, my
variable is $domain, and I wanted to append it to a url to complete the full
url, i.e:
$mech->get(http://."$domain"."\.com");
would the above work in representing the full url?
------------------------------
Date: 28 Oct 2006 17:19:42 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: queston about appending a variable to a url
Message-Id: <4qhhpeFna1gsU1@news.dfncis.de>
Nospam <nospam@home.com> wrote in comp.lang.perl.misc:
> I am wondering how I might append a variable onto a url, say for example, my
> variable is $domain, and I wanted to append it to a url to complete the full
> url, i.e:
>
> $mech->get(http://."$domain"."\.com");
>
> would the above work in representing the full url?
I see a few problems, but it's demeaning to do the work of a machine.
Why don't you run it and see?
Anno
------------------------------
Date: Sat, 28 Oct 2006 17:40:50 GMT
From: "Nospam" <nospam@home.com>
Subject: Re: queston about appending a variable to a url
Message-Id: <CCM0h.23909$iq4.12909@newsfe1-gui.ntli.net>
<anno4000@radom.zrz.tu-berlin.de> wrote in message
news:4qhhpeFna1gsU1@news.dfncis.de...
> Nospam <nospam@home.com> wrote in comp.lang.perl.misc:
> > I am wondering how I might append a variable onto a url, say for
example, my
> > variable is $domain, and I wanted to append it to a url to complete the
full
> > url, i.e:
> >
> > $mech->get(http://."$domain"."\.com");
> >
> > would the above work in representing the full url?
>
> I see a few problems, but it's demeaning to do the work of a machine.
> Why don't you run it and see?
>
> Anno
so far:
#usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
my $mech = WWW::Mechanize=>new();
my $domain = 'example';
$mech->get('http://www.'."$domain".'.com');
print $mech->uri."\n";
I am getting this error msg:
Bareword "WWW::Mechanize" not allowed while "strict subs" in use at
gtexam1.pl l
ine 12.
gtexam1.pl had compilation errors.
I am at a loss as to how to amend the variable http://...www in the get
function
------------------------------
Date: Sat, 28 Oct 2006 17:52:30 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: queston about appending a variable to a url
Message-Id: <yNM0h.1919$WB4.239@trndny04>
Nospam wrote:
> I am wondering how I might append a variable onto a url, say for
> example, my variable is $domain, and I wanted to append it to a url
> to complete the full url, i.e:
>
> $mech->get(http://."$domain"."\.com");
>
> would the above work in representing the full url?
Well, your idea of using the concatenation operator is one way of doing it,
but there are several problems with the way you implemented this idea. What
do you believe
http://."$domain"
is supposed to do? This
http://
is not a valid Perl item.
And why are you escaping the dot in "\.com"?
Instead of bothering with proper quoting and tons of concatenation
operations _I_ would just use a simple stringification:
$mech->get "http://$domain.com";
jue
------------------------------
Date: 28 Oct 2006 17:54:09 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: queston about appending a variable to a url
Message-Id: <4qhjq1Fn6i1lU1@news.dfncis.de>
Nospam <nospam@home.com> wrote in comp.lang.perl.misc:
>
> <anno4000@radom.zrz.tu-berlin.de> wrote in message
> news:4qhhpeFna1gsU1@news.dfncis.de...
> > Nospam <nospam@home.com> wrote in comp.lang.perl.misc:
> > > I am wondering how I might append a variable onto a url, say for
> example, my
> > > variable is $domain, and I wanted to append it to a url to complete the
> full
> > > url, i.e:
> > >
> > > $mech->get(http://."$domain"."\.com");
> > >
> > > would the above work in representing the full url?
> >
> > I see a few problems, but it's demeaning to do the work of a machine.
> > Why don't you run it and see?
> >
> > Anno
>
> so far:
>
> #usr/bin/perl
> use strict;
> use warnings;
> use WWW::Mechanize;
>
>
> my $mech = WWW::Mechanize=>new();
^^
That's the wrong kind of arrow. Try again.
Anno
------------------------------
Date: Sat, 28 Oct 2006 18:00:43 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: queston about appending a variable to a url
Message-Id: <fVM0h.960$Gg5.903@trndny02>
Nospam wrote:
>> Nospam <nospam@home.com> wrote in comp.lang.perl.misc:
>>> I am wondering how I might append a variable onto a url, say for
>>> example, my variable is $domain, and I wanted to append it to a url
>>> to complete the full url, i.e:
>>>
>>> $mech->get(http://."$domain"."\.com");
>
> $mech->get('http://www.'."$domain".'.com');
Do you see the difference between those 2 lines?
Why did you lead us on a wild goose chase with your first posting?
> Bareword "WWW::Mechanize" not allowed while "strict subs" in use at
Why didnt' you include this error message in your first posting?
> I am at a loss as to how to amend the variable http://...www in the
> get function
Why do you think the construction of that string has anything to do with the
error message that you are getting?
Instead you may want to check out how you construct that object that perl is
complaining about in line 12:
Your code:
> my $mech = WWW::Mechanize=>new();
Sample code from the documentation:
my $mech = WWW::Mechanize->new()
Do you see the difference?
jue
------------------------------
Date: 28 Oct 2006 10:05:32 -0700
From: "shareparadise@gmail.com" <shareparadise@gmail.com>
Subject: Re: Store multi-dimensions array for use in latter form?
Message-Id: <1162055132.551111.215920@m7g2000cwm.googlegroups.com>
Unless you can save it into the database or somewhere on the server and
then retrieve it for later use, there is no way to prevent someone to
do something bad to the cookie or even to the hidden field if you are
to use form.
There are many many things to consider if I want to make this project
useful in real world, but that's not the goal of this one. This project
is built based on the assumption that the input file is "well-formed"
and valid, and the users are nice. Anyway, I tried the following code:
use Data::Dumper;
my $table_string = Data::Dumper->Dump(\@table);
# pass it in a hidden field/ or maybe set cookie, it doesnt really
matter tho.
print "<input type='hidden' name = 'table' value = \"$table_string\">";
# retrieve here (of course this is after we submit the form along with
that hidden field already.
my $temp = $query->param("table");
eval $temp;
I was able to retrieve the string back, but couldnt eval it back to the
original table.
------------------------------
Date: Sat, 28 Oct 2006 11:17:22 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Store multi-dimensions array for use in latter form?
Message-Id: <J-WdnTVQ04k_Dd7YnZ2dnUVZ_vqdnZ2d@comcast.com>
shareparadise@gmail.com wrote:
> use Data::Dumper;
> my $table_string = Data::Dumper->Dump(\@table);
> # pass it in a hidden field/ or maybe set cookie, it doesnt really
> matter tho.
> print "<input type='hidden' name = 'table' value = \"$table_string\">";
$table_string probably contains special characters that will need to be
encoded.
http://search.cpan.org/~gaas/HTML-Parser-3.55/lib/HTML/Entities.pm
Also, if I am going to create a string the contains quotes, I would rather
print qq(<input type='hidden' name='table' value="$table_string">);
------------------------------
Date: 28 Oct 2006 20:33:26 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Store multi-dimensions array for use in latter form?
Message-Id: <4qht4mFn8ofuU1@news.dfncis.de>
Mumia W. (reading news) <paduille.4060.mumia.w@earthlink.net> wrote in comp.lang.perl.misc:
> On 10/27/2006 04:50 PM, xhoster@gmail.com wrote:
> > "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net> wrote:
> >> To extract the table data from the cookie, URL-decode the cookie string
> >> and "eval" the decoded string.
> >
> > You shouldn't eval a string that is coming from a cookie. Who knows what
> > someone stuck in that string when you weren't looking.
> >
> > Xho
> >
>
> Yow! You're right. And since the OP can't install modules such as
> FreezeThaw, a custom encoding function is the only way.
Storable is a core module that does what's needed without eval().
Anno
------------------------------
Date: 28 Oct 2006 14:42:18 -0700
From: "shareparadise@gmail.com" <shareparadise@gmail.com>
Subject: Re: Store multi-dimensions array for use in latter form?
Message-Id: <1162071738.781300.273100@e64g2000cwd.googlegroups.com>
@anno4000: I prefer not to store to file, but I'll definetely check it
out right now.
@Scott Bryce: cool, I actually didnt know I could print that way.
Anyway, I tried the encode you suggested + print qq(<input
type='hidden' name='table' value="$table_string">), the result is still
the same tho. BTW, I print out my $table_string here: (It's lots of
lines, Im sorry *_*)
$VAR1 = [ 0, 'element', 'shiporder', undef, undef, undef, undef ];
$VAR2 = [ 1, 'element', 'orderperson', 'string', undef, undef, undef ];
$VAR3 = [ 1, 'element', 'shipto', undef, undef, undef, undef ]; $VAR4 =
[ 2, 'element', 'name', 'string', undef, undef, undef ]; $VAR5 = [ 2,
'element', 'address', 'string', undef, undef, undef ]; $VAR6 = [ 2,
'element', 'city', 'string', undef, undef, undef ]; $VAR7 = [ 2,
'element', 'country', 'string', undef, undef, undef ]; $VAR8 = [ 1,
'element', 'item', undef, undef, 'unbounded', undef ]; $VAR9 = [ 2,
'element', 'title', 'string', undef, undef, undef ]; $VAR10 = [ 2,
'element', 'note', 'string', 0, undef, undef ]; $VAR11 = [ 2,
'element', 'quantity', 'positiveInteger', undef, undef, undef ]; $VAR12
= [ 2, 'element', 'price', 'decimal', undef, undef, undef ]; $VAR13 = [
1, 'attribute', 'orderid', 'string', undef, undef, 'required' ];
And the dump:
# table
* $VAR1 = [
0,
'element',
'shiporder',
undef,
undef,
undef,
undef
];
$VAR2 = [
1,
'element',
'orderperson',
'string',
undef,
undef,
undef
];
$VAR3 = [
1,
'element',
'shipto',
undef,
undef,
undef,
undef
];
$VAR4 = [
2,
'element',
'name',
'string',
undef,
undef,
undef
];
$VAR5 = [
2,
'element',
'address',
'string',
undef,
undef,
undef
];
$VAR6 = [
2,
'element',
'city',
'string',
undef,
undef,
undef
];
$VAR7 = [
2,
'element',
'country',
'string',
undef,
undef,
undef
];
$VAR8 = [
1,
'element',
'item',
undef,
undef,
'unbounded',
undef
];
$VAR9 = [
2,
'element',
'title',
'string',
undef,
undef,
undef
];
$VAR10 = [
2,
'element',
'note',
'string',
0,
undef,
undef
];
$VAR11 = [
2,
'element',
'quantity',
'positiveInteger',
undef,
undef,
undef
];
$VAR12 = [
2,
'element',
'price',
'decimal',
undef,
undef,
undef
];
$VAR13 = [
1,
'attribute',
'orderid',
'string',
undef,
undef,
'required'
];
------------------------------
Date: 28 Oct 2006 21:45:48 GMT
From: xhoster@gmail.com
Subject: Re: Store multi-dimensions array for use in latter form?
Message-Id: <20061028174552.573$OX@newsreader.com>
anno4000@radom.zrz.tu-berlin.de wrote:
> Mumia W. (reading news) <paduille.4060.mumia.w@earthlink.net> wrote in
> comp.lang.perl.misc:
> > On 10/27/2006 04:50 PM, xhoster@gmail.com wrote:
> > > "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
> > >> wrote: To extract the table data from the cookie, URL-decode the
> > >> cookie string and "eval" the decoded string.
> > >
> > > You shouldn't eval a string that is coming from a cookie. Who knows
> > > what someone stuck in that string when you weren't looking.
> > >
> > > Xho
> > >
> >
> > Yow! You're right. And since the OP can't install modules such as
> > FreezeThaw, a custom encoding function is the only way.
>
> Storable is a core module that does what's needed without eval().
Storable is indubitably better than Dumper/eval, but how safe is it?
Can corrupt data cause "thaw" to execute arbitrary code, or take huge
amounts of memory/CPU, or segfault? I was surprised that I couldn't
find a discussion of this under either Storable or perlsec.
Xho
>
> Anno
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 28 Oct 2006 21:53:05 GMT
From: xhoster@gmail.com
Subject: Re: Store multi-dimensions array for use in latter form?
Message-Id: <20061028175309.509$Uk@newsreader.com>
"shareparadise@gmail.com" <shareparadise@gmail.com> wrote:
> Unless you can save it into the database or somewhere on the server and
> then retrieve it for later use, there is no way to prevent someone to
> do something bad to the cookie or even to the hidden field if you are
> to use form.
> There are many many things to consider if I want to make this project
> useful in real world, but that's not the goal of this one. This project
> is built based on the assumption that the input file is "well-formed"
> and valid, and the users are nice. Anyway, I tried the following code:
>
> use Data::Dumper;
> my $table_string = Data::Dumper->Dump(\@table);
> # pass it in a hidden field/ or maybe set cookie, it doesnt really
> matter tho.
> print "<input type='hidden' name = 'table' value = \"$table_string\">";
print CGI->hidden('table', $table_string);
It will automatically escape what needs escaping.
>
> # retrieve here (of course this is after we submit the form along with
> that hidden field already.
> my $temp = $query->param("table");
> eval $temp;
>
> I was able to retrieve the string back, but couldnt eval it back to the
> original table.
Why couldn't you?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Sat, 28 Oct 2006 13:29:18 +0200
From: robert <no-spam@no-spam-no-spam.com>
Subject: Re: what are the most frequently used functions?
Message-Id: <ehvevg$614$1@news.albasani.net>
Xah Lee wrote:
> I had a idea today.
>
> I wanted to know what are the top most frequently used functions in the
> emacs lisp language. I thought i can write a quick script that go thru
> all the elisp library locations and get a word-frequency report i want.
>
> I started with a simple program:
> http://xahlee.org/p/titus/count_word_frequency.py
>
> and applied it to a Shakespeare text. Here's a sample result:
> http://xahlee.org/p/titus/word_frequency.html
>
> Then, i wrote a more elaborate one that recurse thru directories to
> work on elisp code treasury.
>
> The code is here:
> http://xahlee.org/x/count_word_frequency.py
>
> and i got a strange result. The word “the†appeared on the top,
> along with many other English words. I quickly realized that these are
> due to lisp function's doc strings. (not comments)
Would be interesting to see if the type-checking "The" in lisp is still frequent. I doubt.
> At this point, it dawned on me that there's no easy way to work around
> this, Unless, i write this script in elisp which has functions that
> read lisp code and can easily filter out doc strings.
>
> Originally, i planned to use the word-frequency script on Perl, Python,
> as well as Java, as well as Elisp. However, now it seems to me this
> task is nigh impossible. Each of these lang has their own doc string
> syntax. It's gonna be a heavy undertaking if the word-frequency script
> is to work with all these langs, since that amounts to writing a parser
> for each lang.
>
> Alternatively, one can write multiple word-frequency scripts using each
> lang in question, since most lang has facilities to deal with its own
> syntax. However, this is still not trivial, and amounts to several
> programing efforts.
Editor code (best maybe scintilla/sc1, check also emacs itself, ...) has libraries for colorizing comments in all kinds of programming langs ...
> Anyone would be interested in this problem?
I have a theory, that "bad source code" has more if/else/elif/case/switch dispatching statements per number of code words (lines..) than "good code" - independent of the language.
If you can count these ratio and correlate it to maybe a sf-ranking and to languages, that would be highly interesting for me... (in case drop a pointer in this thread / repeated subject)
-robert
------------------------------
Date: Sat, 28 Oct 2006 11:36:44 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: what are the most frequently used functions?
Message-Id: <ghH0h.91$pU3.67@trndny08>
> Xah Lee wrote:
>> I had a idea today.
Oh, really? You should mark your calendar and celebrate the day annually!!!
>> I wanted to know what are the top most frequently used functions in
>> the emacs lisp language.
And the relationship with Perl, Python, Java is exactly what?
jue
------------------------------
Date: Sat, 28 Oct 2006 14:04:56 +0200
From: robert <no-spam@no-spam-no-spam.com>
Subject: Re: what are the most frequently used functions?
Message-Id: <ehvh1b$8q8$1@news.albasani.net>
Jürgen Exner wrote:
>> Xah Lee wrote:
>>> I had a idea today.
>
> Oh, really? You should mark your calendar and celebrate the day annually!!!
>
>>> I wanted to know what are the top most frequently used functions in
>>> the emacs lisp language.
>
> And the relationship with Perl, Python, Java is exactly what?
read more of the context and answer to the OP
------------------------------
Date: Sat, 28 Oct 2006 15:03:53 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: what are the most frequently used functions?
Message-Id: <ehvrno.1d4.1@news.isolution.nl>
robert schreef:
> read more of the context and answer to the OP
That OP is invisible in most relevant contexts.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sat, 28 Oct 2006 10:40:39 -0400
From: Barry Margolin <barmar@alum.mit.edu>
Subject: Re: what are the most frequently used functions?
Message-Id: <barmar-9B3FB2.10403928102006@comcast.dca.giganews.com>
In article <1162020254.660829.124900@e3g2000cwe.googlegroups.com>,
"Xah Lee" <xah@xahlee.org> wrote:
> I had a idea today.
>
> I wanted to know what are the top most frequently used functions in the
> emacs lisp language. I thought i can write a quick script that go thru
> all the elisp library locations and get a word-frequency report i want.
>
> I started with a simple program:
> http://xahlee.org/p/titus/count_word_frequency.py
>
> and applied it to a Shakespeare text. Here's a sample result:
> http://xahlee.org/p/titus/word_frequency.html
>
> Then, i wrote a more elaborate one that recurse thru directories to
> work on elisp code treasury.
>
> The code is here:
> http://xahlee.org/x/count_word_frequency.py
>
> and i got a strange result. The word “the†appeared on the top,
> along with many other English words. I quickly realized that these are
> due to lisp function's doc strings. (not comments)
>
> At this point, it dawned on me that there's no easy way to work around
> this, Unless, i write this script in elisp which has functions that
> read lisp code and can easily filter out doc strings.
For Lisp, just look for symbols that are immediately preceded by ( or
#'. The tokens after ( are not always functions, since this is also
used for constructing literal lists and for subforms of special
operators (e.g. the variable names in LET bindings) but I think the ones
that aren't functions will have low enough frequency that they won't
impact the results.
Perl would be harder, I think. For ordinary function calls you can look
for a word followed by (, but built-in functions allow use without
parentheses around the parameters.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
------------------------------
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 9902
***************************************