[29183] in Perl-Users-Digest
Perl-Users Digest, Issue: 427 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 11 14:10:04 2007
Date: Fri, 11 May 2007 11:09: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 Fri, 11 May 2007 Volume: 11 Number: 427
Today's topics:
Firefox -- browsing activity logger? <ignoramus6365@NOSPAM.6365.invalid>
Re: Firefox -- browsing activity logger? <phus@live.com>
Re: How to restart all hashes and arrays halfway throug <nobull67@gmail.com>
Re: Identify if a scalar is int, double or text <klaus03@gmail.com>
Re: Identify if a scalar is int, double or text <klaus03@gmail.com>
Re: need a quick script <edMbj@aes-intl.com>
Re: need a quick script <bik.mido@tiscalinet.it>
Re: Perl regularexpression problem with the Input file <paduille.4061.mumia.w+nospam@earthlink.net>
Script to compare two directory structures <usenet@sta.samsung.com>
Re: Script to compare two directory structures <morton@lsupcaemnt.com>
Re: Script to compare two directory structures <usenet@sta.samsung.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 11 May 2007 12:20:27 -0500
From: Ignoramus6365 <ignoramus6365@NOSPAM.6365.invalid>
Subject: Firefox -- browsing activity logger?
Message-Id: <O9qdnfF__L1GONnbnZ2dnUVZ_uCinZ2d@giganews.com>
I would like to know if there is a Firefox extension that would log
all browsing activity (URLs, cookies, form parameters and retrieved
HTML).
The reason for this is that I am trying to write a perl script that
would log on to adsense and find out how much money I made today, or
yesterday, or do some stats by ad channel also. I would then further
integrate it with my scripts.
I have a hell of a time in doing so, due to Google's use of
javascript, which is not known to WWW::Mechanize. This is by far not
my first web scraping script, I did maybe a dozen or two prior, but I
am not getting headway with it. I tried and tried and thought that I
was doing a perfect job, but still I fail.
Unfortunately, the Adsense notifier mozilla plugin, is becoming broken
as google is switching to new forms.
So I would like to track my browser activity completely (ie 100% data
capture).
I did try using TamperData, and I would prefer something even more
verbose when it comes to logging, and more file friendly.
Perhaps my real answer is using a web proxy, which I do not mind
trying.
i
------------------------------
Date: 11 May 2007 10:56:19 -0700
From: phus <phus@live.com>
Subject: Re: Firefox -- browsing activity logger?
Message-Id: <1178906179.613506.311900@e65g2000hsc.googlegroups.com>
On 5=D4=C212=C8=D5, =C9=CF=CE=E71=CA=B120=B7=D6, Ignoramus6365 <ignoramus6.=
.=2E@NOSPAM.6365.invalid>
wrote:
> I would like to know if there is a Firefox extension that would log
> all browsing activity (URLs, cookies, form parameters and retrieved
> HTML).
>
> The reason for this is that I am trying to write a perl script that
> would log on to adsense and find out how much money I made today, or
> yesterday, or do some stats by ad channel also. I would then further
> integrate it with my scripts.
>
> I have a hell of a time in doing so, due to Google's use of
> javascript, which is not known to WWW::Mechanize. This is by far not
> my first web scraping script, I did maybe a dozen or two prior, but I
> am not getting headway with it. I tried and tried and thought that I
> was doing a perfect job, but still I fail.
>
> Unfortunately, the Adsense notifier mozilla plugin, is becoming broken
> as google is switching to new forms.
>
> So I would like to track my browser activity completely (ie 100% data
> capture).
>
> I did try using TamperData, and I would prefer something even more
> verbose when it comes to logging, and more file friendly.
>
> Perhaps my real answer is using a web proxy, which I do not mind
> trying.
>
> i
try livehttpheaders
http://livehttpheaders.mozdev.org/
------------------------------
Date: 11 May 2007 10:07:03 -0700
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: How to restart all hashes and arrays halfway through script
Message-Id: <1178903223.252608.196570@h2g2000hsg.googlegroups.com>
On May 11, 8:26 am, "Ken Soon" <c...@xilinx.com> wrote:
> I am using dynamic arrays and hashes to store data. The names of the hashes
> and arrays changes to a certain groups of names and there are alot of names.
It sounds to me like you are saying you are using symbolic references.
This is probably the cause of you problem. Stop doing it and your
problems will probably go away.
>
> Then i did some operations on this data with file::find, write to some files
> and others....
> However, as i continue on to another new operation on those hashes and
> arrays, somehow all the values are gone or different (I'm not sure yet
> whether is gone or different as I'm having trouble debugging to find out the
> confirmed erroneous output)
> Thus I am hoping if there such a thing to reset everything before i start on
> that next operation. (as if i am restarting the script at that point)
Hey, a SAQ! But you really do _not_ want the reset() function. Declare
all your variables as lexically in the smallest applicable scope and
you'll probably find your problem goes away.
> Hmm all this sound abit weird though but i guess it is because haven't been
> able to debug the problem.
Lots of global variables and symbolic references will do that.
> hope my point is clear :X
Your point would be much clearer if you'd made it by showing us a
_minimal_ but _complete_ (strict, warning-free) script that you'd run
and found to reproduce the problem you are having.
------------------------------
Date: 11 May 2007 08:18:34 -0700
From: Klaus <klaus03@gmail.com>
Subject: Re: Identify if a scalar is int, double or text
Message-Id: <1178896709.046692.95770@u30g2000hsc.googlegroups.com>
On May 11, 2:49 pm, anno4...@radom.zrz.tu-berlin.de wrote:
> Klaus <klau...@gmail.com> wrote in comp.lang.perl.misc:
> > I have a list of 4 scalars
> > my @L = (3, '3', 3.0, '3.0');
> > I want to write a subroutine type_id which returns either 'int',
> > 'double', 'text' (or '?') for each of the scalars
> > I have found a solution where I use Devel::Peek, call Dump(), redirect
> > STDERR into an "in-memory" file ( \$data ) and analyse the "in-memory"
> > content:
[snip]
> The B::* set of modules should have the means to get the info
> without catching printed output.
That's it - it's the B module which I was looking for (I knew it
existed, but I never thought I would ever use it).
Thanks a million !!
I am now using a simple "use B qw(svref_2object class);" and my
program is now much smaller and more to the point without any
redirection of STDERR:
Here is my new program:
============================
use strict;
use warnings;
use B qw(svref_2object class);
my @L = (3, '3', 3.0, '3.0');
print type_id($_), ' ' for (@L);
print "\n";
sub type_id {
my $cl = class svref_2object \$_[0];
if ($cl eq 'IV') { return 'int' }
if ($cl eq 'NV') { return 'double' }
if ($cl eq 'PV') { return 'text' }
return "?020 [Invalid: class(SV-Object) = '$cl']";
}
============================
--
Klaus
------------------------------
Date: 11 May 2007 08:56:33 -0700
From: Klaus <klaus03@gmail.com>
Subject: Re: Identify if a scalar is int, double or text
Message-Id: <1178898993.174141.207380@u30g2000hsc.googlegroups.com>
On May 11, 2:23 pm, "Sisyphus" <sisyph...@nomail.afraid.org> wrote:
> "Klaus" <klau...@gmail.com> wrote in message
> > I want to write a subroutine type_id which returns either 'int',
> > 'double', 'text' (or '?') for each of the scalars
> Be aware that a variable can change from one type to
> another in rather sneaky ways - as the following
> demonstrates:
[ snip ]
> # int text double text
>
> my $string = '7';
> print type_id($string), "\n"; # text
> $string *= 1;
> print type_id($string), "\n"; # int
>
> my $var = ~0;
> print type_id($var), "\n"; # int
> $var *= -1;
> print type_id($var), "\n"; # double (though that might
> # differ on 64-bit perls)
I see your point.
Here is another example of how a variable can change from one type to
another in rather sneaky ways:
=============================
use strict;
use warnings;
use B qw(svref_2object class);
my $num = 1;
while (1) {
my $id = type_id($num);
printf "id = %-6s num = %s\n", $id, $num;
last if $id ne 'int';
$num *= 10;
}
while ($num > 1) {
$num /= 10;
my $id = type_id($num);
printf "id = %-6s num = %s\n", $id, $num;
}
sub type_id {
my $cl = class svref_2object \$_[0];
if ($cl =~ m{IV$}) { return 'int' }
if ($cl =~ m{NV$}) { return 'double' }
if ($cl =~ m{PV$}) { return 'text' }
return "[$cl]";
}
=============================
And here is the output:
=============================
id = int num = 1
id = int num = 10
id = int num = 100
id = int num = 1000
id = int num = 10000
id = int num = 100000
id = int num = 1000000
id = int num = 10000000
id = int num = 100000000
id = int num = 1000000000
id = double num = 10000000000
id = double num = 1000000000
id = double num = 100000000
id = double num = 10000000
id = double num = 1000000
id = double num = 100000
id = double num = 10000
id = double num = 1000
id = double num = 100
id = double num = 10
id = double num = 1
=============================
--
Klaus
------------------------------
Date: Fri, 11 May 2007 08:10:54 -0700
From: Ed Jay <edMbj@aes-intl.com>
Subject: Re: need a quick script
Message-Id: <jr1943ddeneacptaihgdliipvtv75c68q2@4ax.com>
Michele Dondi scribed:
>On Sun, 06 May 2007 17:39:31 -0400, Sherm Pendley
><spamtrap@dot-app.org> wrote:
>
>>> Does anyone have a script lying around that will take firstname
>>> lastname and create first initial lastname: Bob Schmo --> BSchmo
>>
>>Careful with that! I worked in an office where we generated logins using
>>the same scheme. That changed when Sue Hitts needed a login. :-) (First
>>name changed to protect the innocent.)
>
>Has anybody seen Mark Hunt? (Op. Cit.)
>
Don't you mean Mike?
--
Ed Jay (remove 'M' to respond by email)
------------------------------
Date: Fri, 11 May 2007 17:40:33 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: need a quick script
Message-Id: <hb39431rvn2fmha7csvrddoq0c9fsepjgs@4ax.com>
On Fri, 11 May 2007 08:10:54 -0700, Ed Jay <edMbj@aes-intl.com> wrote:
>>Has anybody seen Mark Hunt? (Op. Cit.)
>>
>Don't you mean Mike?
In the book it's Mark. It even gives the title to a section: "The
elusive Mr Hunt." But Kelly thinks for a second it's Mark Renton,
they're really talking about.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 11 May 2007 16:42:10 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Perl regularexpression problem with the Input file
Message-Id: <C111i.14117$3P3.6651@newsread3.news.pas.earthlink.net>
On 05/11/2007 09:19 AM, paul wrote:
> Hello,
>
> The following code is to read data from the file and store it into the
> hash-arrayreference, it seems to work for the data in the code but not
> for the file.
> ===== the file that the program reading is
> 1- what is psychologist?
> a- study of mental processing
> b- study about human intelligent
> c- study both human and animal
> d- study biolpsychology
> 2- what is neuron?
> a- a connection between cell body
> b- a electro chemical
> c- chimal reaction between oxygen and water
> d- part of soma
> ===============
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my $file_name = shift;
> my %question_answer_haf;
>
> open(OFILE, "$file_name") || die("Can't open the file: $!");
>
> while(<OFILE>){
> my $question;
> my @answers;
$Question and @answers probably need to go outside of the while loop.
> #print "$2\n" if(/(\d)+\s*-\s*(.*)/) ;
> #print "$2\n" if(/(?i)(\w)+\s*-\s*(.*)/);
>
> if(/\d+\s*-\s*(.*)/) {
> $question = ${1};
> }
This seems to eliminate the question number from the question.
> if(/(?i)(\w)+\s*-\s*(.*)/) {
> push @{$question_answer_haf{$question}}, $2;
> }
And this eliminates the answer letter.
>
> }
>
> close(OFILE);
>
> ==========================
> the work version,
>
> my %hashQuestion= (
> "1 - What is Psychology? "=>[ "A- study about mind and mental
> concept*",
> "B- is part of a seudopsychology",
> "C- about all the life and ",
> "d- none of the above"],
> "2- what is neuron? "=>[ "a- is an electro in the body* ",
> "b- a fuid in the boyd"]
> );
>
> my %hash2 ;
>
> foreach my $question1 (keys %hashQuestion) {
> print "$question1 \n";
>
> foreach my $i (0..$#{$hashQuestion{$question1}}) {
> print $hashQuestion{$question1}[$i] . "\n";
> push @{$hash2{$question1}}, $hashQuestion{$question1}
> [$i];
> }
> }
>
>
> thank
>
I also think that the questions and answers are not well worded;
however, I suspect that you posted a simplified version of a program
that is being written in another natural language.
------------------------------
Date: 11 May 2007 08:10:12 -0700
From: Generic Usenet Account <usenet@sta.samsung.com>
Subject: Script to compare two directory structures
Message-Id: <1178896212.528360.296440@o5g2000hsb.googlegroups.com>
We had a need to compare two directory structures to see if they are
identical (meaning if they have the same structure, same contents and
same versions of files). I wrote a shell script for this purpose
(posted to the comp.sources.d newsgroup). It works, but given my
scant knowledge of scripting, it is rather crude. I am looking for
something more professional and robust, perhaps using perl. Any help
would be appreciated.
Thanks,
Bhta
------------------------------
Date: Fri, 11 May 2007 10:14:20 -0500
From: Ed Morton <morton@lsupcaemnt.com>
Subject: Re: Script to compare two directory structures
Message-Id: <g5ednYCG5bfQFdnbnZ2dnUVZ_oHinZ2d@comcast.com>
Generic Usenet Account wrote:
> We had a need to compare two directory structures to see if they are
> identical (meaning if they have the same structure, same contents and
> same versions of files). I wrote a shell script for this purpose
> (posted to the comp.sources.d newsgroup). It works, but given my
> scant knowledge of scripting, it is rather crude. I am looking for
> something more professional and robust, perhaps using perl. Any help
> would be appreciated.
>
> Thanks,
> Bhta
>
diff -r dir1 dir2
If that doesn't work for you, explain why.
Ed.
------------------------------
Date: 11 May 2007 08:24:17 -0700
From: Generic Usenet Account <usenet@sta.samsung.com>
Subject: Re: Script to compare two directory structures
Message-Id: <1178897057.450094.18160@o5g2000hsb.googlegroups.com>
On May 11, 10:14 am, Ed Morton <mor...@lsupcaemnt.com> wrote:
>
> diff -r dir1 dir2
>
> If that doesn't work for you, explain why.
>
> Ed.
Sheepishly I must admit that you are absolutely right. Thanks for
pointing this out ----- you made me realize how I wasted a couple of
hours of precious time on a wild goose chase.
------------------------------
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 427
**************************************