[24296] in Perl-Users-Digest
Perl-Users Digest, Issue: 6487 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 29 14:05:50 2004
Date: Thu, 29 Apr 2004 11:05:06 -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 Thu, 29 Apr 2004 Volume: 10 Number: 6487
Today's topics:
Re: Count how many times find and replaced happened (Anno Siegel)
Re: Count how many times find and replaced happened <dwall@fastmail.fm>
Re: Count how many times find and replaced happened <tadmc@augustmail.com>
Re: Count how many times find and replaced happened <webmaster @ infusedlight . net>
Re: Help! maintaining/upgrading Perl on Windows <1usa@llenroc.ude>
Re: I'm just curious about sleep (Bryan Castillo)
LWP, Applets and Secure Certs. (Fawaz Shatat)
perl memry free problem (sachin)
Re: perl memry free problem <mark.clements@kcl.ac.uk>
Re: Please Recommend A Good Perl Book. <alien_resident@sbcglobal.net>
Re: Please Recommend A Good Perl Book. <jwillmore@remove.adelphia.net>
Printing PDF directly from Perl Win2000, Perl 5.8 (Aqua)
Re: Problems accessing a hash reference using each <remorse@partners.org>
Re: RFC: Text similarity <jwillmore@remove.adelphia.net>
Re: Socket version 1.3 <bart.lateur@pandora.be>
Re: Socket version 1.3 <bart.lateur@pandora.be>
Suggestions on editing multiple files <porter970@lycos.com>
Re: Suggestions on editing multiple files <ittyspam@yahoo.com>
Re: Suggestions on editing multiple files <dwall@fastmail.fm>
Re: Suggestions on editing multiple files <postmaster@castleamber.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Apr 2004 13:14:38 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Count how many times find and replaced happened
Message-Id: <c6qv3u$mqt$1@mamenchi.zrz.TU-Berlin.DE>
blnukem <bill@hotmail.com> wrote in comp.lang.perl.misc:
> Hi All
>
> Is there a way to count how many times $Line =~ s///; has happened?
>
> foreach my $Line (@ArrayToRead) {
> $Line =~ s/TextToFind/TextToReplace/i;
> }
Use grep in scalar context:
my $count = grep s/TextToFind/TextToReplace/i, @ArrayToRead;
Anno
------------------------------
Date: Thu, 29 Apr 2004 13:52:16 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Count how many times find and replaced happened
Message-Id: <Xns94DA646A1A611dkwwashere@216.168.3.30>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> blnukem <bill@hotmail.com> wrote in comp.lang.perl.misc:
>>
>> Is there a way to count how many times $Line =~ s///; has
>> happened?
>>
>> foreach my $Line (@ArrayToRead) {
>> $Line =~ s/TextToFind/TextToReplace/i;
>> }
>
> Use grep in scalar context:
>
> my $count = grep s/TextToFind/TextToReplace/i, @ArrayToRead;
That's an interesting use of grep and s///.
My first thought was that he meant the number of substitutions, which
can be very different. That is,
my $count;
$count += s/TextToFind/TextToReplace/g for @array;
(note 'g' option)
/me shrugs...
------------------------------
Date: Thu, 29 Apr 2004 08:44:18 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Count how many times find and replaced happened
Message-Id: <slrnc921li.38u.tadmc@magna.augustmail.com>
blnukem <bill@hotmail.com> wrote:
> Is there a way to count how many times $Line =~ s///; has happened?
my $how_many_times = $Line =~ s///;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 29 Apr 2004 08:51:35 -0800
From: "Robin" <webmaster @ infusedlight . net>
Subject: Re: Count how many times find and replaced happened
Message-Id: <c6rbrk$8ro$1@reader2.nmix.net>
"blnukem" <bill@hotmail.com> wrote in message
news:S%6kc.42117$Gd3.9618519@news4.srv.hcvlny.cv.net...
> Hi All
>
> Is there a way to count how many times $Line =~ s///; has happened?
>
> foreach my $Line (@ArrayToRead) {
> $Line =~ s/TextToFind/TextToReplace/i;
> }
>
my $count = 0;
foreach my $Line (@ArrayToRead) {
$Line =~ s/TextToFind/TextToReplace/i and $count += 1;
}
-Robin
------------------------------
Date: 29 Apr 2004 15:38:45 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: Help! maintaining/upgrading Perl on Windows
Message-Id: <Xns94DA7678A214Casu1cornelledu@132.236.56.8>
Sherm Pendley <spamtrap@dot-app.org> wrote in
news:aN2dnVO9BcSLDw3d4p2dnA@adelphia.com:
> http://tinyurl.com/3en5o
Sherm, thank you very much. It looks like I missed the original thread, and
I would have remained unaware of this download had you not posted this.
Sinan.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: 29 Apr 2004 08:09:59 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: I'm just curious about sleep
Message-Id: <1bff1830.0404290709.7aed81e4@posting.google.com>
"Robin" <robin @ infusedlight.net> wrote in message news:<c6pggb$p76$2@news.f.de.plusline.net>...
> I'm just wondering what it would take to write your own function without
> using modules or anything that is identical or at least performs identically
> to the internal perl function, sleep?
> has anyone tried this...etc?
> I thought of just doing some heavy operations that don't really do anything
> and try to line it up to last seconds in interation, but I don't think this
> would be productive or really be the way to do it.
Off-topic
I used that technique when I was in high school to create a video game
on a TI-86 graphing calculator. I later found out that the timing
changed as the battery started to loose its charge. (Really, its not
a good idea)
> It's just a curiousity.
>
> Thanks.
>
> --
> Regards,
> -Robin
------------------------------
Date: 29 Apr 2004 08:06:15 -0700
From: fshatat@hotmail.com (Fawaz Shatat)
Subject: LWP, Applets and Secure Certs.
Message-Id: <600551b8.0404290706.249bbc5@posting.google.com>
I have to log into a server that asks for a previously downloaded
Digital Certificate. After login, I select a link that openes an
applet that I have to interact with. In the applet I have to to select
from a menue, fill few text fields and click a button to get the
results.
I have used the LWP::UserAgent in a previous project. And during my
Java years, I was able to have javascript interact with an applet that
I wrote for another project (ran in a browser).
Can these three be combined? Can I use Perl to automate connecting to
a server(remote, someone elses) and validate a stored certificate, and
then interact with the applet (don't have applet code, but maybe able
to use SourceAgain on the downloaded applet)?
ANY tips?
------------------------------
Date: 29 Apr 2004 06:38:11 -0700
From: sachindurge@hotmail.com (sachin)
Subject: perl memry free problem
Message-Id: <3291035e.0404290538.7472a92b@posting.google.com>
Hi All
I have written a perl extension for a library mymodule I have used
swig to genarate this .
In this module there is a function get_prop which has one in
parameter and two out parameter
sub get_obj_prop {
($ret,$prop,) =&mymodule::get_prop($obj);
if($ret==$mymodule::MY_EOK) {
print "OK \n";
}
else {
print "Error $ret \n";
}
}
all variables have a global scope
$prop is a pointer to struct obj_prop
$prop is a pointer to a structure allocated by the library
when i call this function second time or i assign some other prop
structure pointer like
$prop = $prop1;
the perl internally calls
the delete_obj_prop function which deletes the structure pointed by
$prop
I dont want such thing to happen because the library internally takes
care of the allocated memory the library maintains the cache of the
allocated memory
Is there is any way so that i can prevent perl from freeing the
structure
Thanks in advance
Sachin.
------------------------------
Date: Thu, 29 Apr 2004 17:05:07 +0100
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: perl memry free problem
Message-Id: <409127b0$1@news.kcl.ac.uk>
sachin wrote:
>
> all variables have a global scope
> $prop is a pointer to struct obj_prop
>
> $prop is a pointer to a structure allocated by the library
> when i call this function second time or i assign some other prop
> structure pointer like
> $prop = $prop1;
> the perl internally calls
> the delete_obj_prop function which deletes the structure pointed by
If you reassign $prop then the reference count of to whatever it was
pointing is reduced by one, and if there are no other references to that
object then it is liable to be garbage-collected. Or am I misreading this?
Mark
------------------------------
Date: Thu, 29 Apr 2004 15:25:57 GMT
From: Alien Resident <alien_resident@sbcglobal.net>
Subject: Re: Please Recommend A Good Perl Book.
Message-Id: <989kc.57751$Yp.14338@newssvr25.news.prodigy.com>
Daniel N. Andersen wrote:
[snip]
> If it wasn't for that site, I wouldn't own all the new editions of
> those books [snip]
You know, I guess I half agree with you. A few weeks back someone posted links to sites
like these, one of which had about 7 CD libraries posted on the site. Many of them I
wasn't familiar with, one especially the Linux Web Sever CD had programming the Perl DBI
on it. So I went to Amazon and found it used (actually to my surprise it was new) for
$7.99 US. Although I never would have reposted the link to the site, that was butt
thinking ;-), butt hey what are you gonna do? Nobadi'z purFFict.
-AR
------------------------------
Date: Thu, 29 Apr 2004 13:57:05 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Please Recommend A Good Perl Book.
Message-Id: <pan.2004.04.28.22.57.13.369586@remove.adelphia.net>
On Wed, 28 Apr 2004 14:27:24 +0000, Randal L. Schwartz wrote:
>>>>>> "Daniel" == Daniel N Andersen <daniel_n_andersen@yahoo.com> writes:
>
> Daniel> If I were you, I would check out http://XXXXXXXXXXXXX/ . This is
> Daniel> O'Reilly's Perl CD Bookshelf v1.0 from 1999, which contain the
> Daniel> following 6 books in HTML format:
[ ... ]
> THINK PEOPLE. THINK. THESE CDs CANNOT BE ON THE WEB. THIS IS A
> COPYRIGHT VIOLATION.
>
> {sigh}
Now we know why the DMCA was passed and the EU is doing what it's doing as
far as copyrights are concerned - there are just plain STUPID people in
the world ;-)
Folks - if you *CAN'T* find it for *FREE* at O'Reilly, then it's *NOT*
free - simple. O'Reilly DOES offer free publications (like "Free as in
Freedom ..." and an MH book that's no longer in print) in it's open
publication web site - the "Perl CD Bookshelf" is *NOT* one of them.
Like Randal says - "THINK PEOPLE. THINK.".
--
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 ...
Dentist, n.: A Prestidigitator who, putting metal in one's
mouth, pulls coins out of one's pockets. -- Ambrose Bierce,
"The Devil's Dictionary"
------------------------------
Date: 29 Apr 2004 10:29:18 -0700
From: junk@dlink.org (Aqua)
Subject: Printing PDF directly from Perl Win2000, Perl 5.8
Message-Id: <55d7995c.0404290929.541128b4@posting.google.com>
I am very new to Windows based Perl. Is there any way to print a PDF
(or a DOC) from a windows Perl Script. I appreciate any samples.
I cannot buy any products at this moment.
Regards
Dominic
------------------------------
Date: Thu, 29 Apr 2004 09:46:47 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: Problems accessing a hash reference using each
Message-Id: <remorse-F681CA.09464729042004@plato.harvard.edu>
In article <a3376e0d.0404290108.34c6b0d7@posting.google.com>,
niall.macpherson@moneyline.com (Niall Macpherson) wrote:
> I was using strict and warnings and I actually got
>
> Global symbol "%value" requires explicit package name at ....
>
> for the line
>
> print("\nGot $value{\"date\"}");
>
> which wouldn't compile.
Try:
print "\nGot $value{'date'}";
or
print "\nGot $value{date}";
Also, of course, may sure you declared %value with either 'my' or 'our'.
HTH,
Ricky
--
Pukku
------------------------------
Date: Thu, 29 Apr 2004 13:56:52 -0400
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: RFC: Text similarity
Message-Id: <pan.2004.04.29.17.56.48.895475@remove.adelphia.net>
On Tue, 27 Apr 2004 00:37:29 +0200, Tore Aursand wrote:
> On Fri, 23 Apr 2004 11:46:44 -0400, James Willmore wrote:
[ ... ]
>> There are Statistics modules as well. You could perform tests againist
>> two documents and get a statistically correlation between the documents
>> to see *how* similar they are.
>
> Hmm. Do you have any module names? A "brief search" didn't yield any
> useful hits.
>
>> I'm rusty on Statistics 101, but my thinking is maybe using a t-test
>> between the two documents might be the way to go.
>
> I don't even know what a "t-test" is, but googling for "t-test" may give
> me the answer...? Or should I search for something else (specific)?
A t-test is a statistical test. It measures variance between two groups.
In other words, is it possible that the results seen are by chance or they
are actually similar. If you use Google, try searching for "t-test" (use
the quotes to insure the search will give the proper results). The first
URL (http://trochim.human.cornell.edu/kb/stat_t.htm) gives a pretty good
explaination.
Sad thing is, I had a thought about where to go with this and lost the
thought :-( I worked some crazy hours the last few days, as well as
fighting off a cold - that may have something to do with it :-(
There are Statistics modules available. Statistics::DependantTTest is one
that will do t-tests for you. I'm not sure now if this is a good way to
go.
Which every way you go, I'd me interested in knowing. I had tried doing
something similar some time back, but stoped the effort in favor of a
pre-made solution.
--
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 did the Roman Empire collapse? What is the Latin for office
automation?
------------------------------
Date: Thu, 29 Apr 2004 16:23:57 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Socket version 1.3
Message-Id: <ina2901b1cac7840g4i04io1lf4ch7re8q@4ax.com>
Sean Berry wrote:
>This is perl, version 5.005_03 built for i386-freebsd
Perl 5.005_04 was released a few months ago.
<http://use.perl.org/article.pl?sid=04/03/01/181242>
I'm not sure what upgrading would buy *you*.
--
Bart.
------------------------------
Date: Thu, 29 Apr 2004 16:25:30 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Socket version 1.3
Message-Id: <71b2905ukcen9fqg6qh5au9fqu1d83hmp9@4ax.com>
Sean Berry wrote:
>Are there any known issues to be aware of when upgrading from 5 to 5.8? 5
>and 5.8 are ported on my FreeBSD.
Yes. Programs that rely on the old version of perl, couldbreak.
Best is to install the new version in a different location, continue to
use the old version for those programs, and develop for the newer
version.
--
Bart.
------------------------------
Date: Thu, 29 Apr 2004 12:01:14 -0600
From: "porter970" <porter970@lycos.com>
Subject: Suggestions on editing multiple files
Message-Id: <1092d70kvh66q8f@corp.supernews.com>
I saw a post once, or and article or an example somewhere talking about
opening a number of different files and replacing a common line of text.
I have a lot of files, maybe 100, that contain an old e-mail address. Is
there a way to use Perl to go out to the different directories, search the
files for the address and replace the old address with a new one?
Even if I get flamed by someone saying "You lazy idiot, go read
xyz_perldoc.html before you ask stupid questions" ... it would be a help.
Thanks,
Steve
------------------------------
Date: Thu, 29 Apr 2004 13:19:11 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Suggestions on editing multiple files
Message-Id: <20040429131551.G1160@dishwasher.cs.rpi.edu>
On Thu, 29 Apr 2004, porter970 wrote:
> I saw a post once, or and article or an example somewhere talking about
> opening a number of different files and replacing a common line of text.
>
> I have a lot of files, maybe 100, that contain an old e-mail address. Is
> there a way to use Perl to go out to the different directories, search the
> files for the address and replace the old address with a new one?
>
> Even if I get flamed by someone saying "You lazy idiot, go read
> xyz_perldoc.html before you ask stupid questions" ... it would be a help.
Telling you to read perldoc is not a flame.
In that vain, I humbly suggest you read
perldoc File::Find
This is assuming the files are all in different directories as you
state. If they are actually all in the same directory, or if you actually
know the specific directories which contain all of the relevant files,
this becomes a one-liner, using the -i and -p command-line options.
Please read
perldoc perlrun
and search for those two options.
If, after reading these documents, you get stuck, feel free to post what
you have written and we'll be happy to help you along.
Paul Lalli
------------------------------
Date: Thu, 29 Apr 2004 17:50:20 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Suggestions on editing multiple files
Message-Id: <Xns94DA8CC6CA4CDdkwwashere@216.168.3.30>
[Paul Lalli already posted a good reponse, but since I typed this
before his showed up on my news server I'll go ahead and post it.]
porter970 <porter970@lycos.com> wrote:
> I saw a post once, or and article or an example somewhere talking
> about opening a number of different files and replacing a common
> line of text.
>
> I have a lot of files, maybe 100, that contain an old e-mail
> address. Is there a way to use Perl to go out to the different
> directories, search the files for the address and replace the old
> address with a new one?
Yes.
How do you know which files to open()? Do you have a list of the
directories and files, or can you just scan through a directory tree
looking for files that match a criterion? Do you want backups made of
the edited files? And so on....
> Even if I get flamed by someone saying "You lazy idiot, go read
> xyz_perldoc.html before you ask stupid questions" ... it would be
> a help.
Without more details I don't know exactly where to point you. Some
suggestions:
perldoc File::Find
perldoc Tie::File
perldoc perlop (look for s/PATTERN/REPLACEMENT/)
perldoc -f open
perldoc -f glob
perldoc perlrun
perldoc perlfaq5 (general background stuff on files)
That should give you ideas for some possible solutions.
HTH.
------------------------------
Date: Thu, 29 Apr 2004 12:54:35 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Suggestions on editing multiple files
Message-Id: <4091415e$0$211$58c7af7e@news.kabelfoon.nl>
porter970 wrote:
> I saw a post once, or and article or an example somewhere talking about
> opening a number of different files and replacing a common line of text.
>
> I have a lot of files, maybe 100, that contain an old e-mail address. Is
> there a way to use Perl to go out to the different directories, search the
> files for the address and replace the old address with a new one?
>
> Even if I get flamed by someone saying "You lazy idiot, go read
> xyz_perldoc.html before you ask stupid questions" ... it would be a help.
There are search and replace tools that do this [1], better if you have
no clue how to do it using Perl. Otherwise read documentation of,
File::Find, File::Slurp (probably must be installed using ppm) and
probably about using regular expressions, and / or index and substr.
An attempt at Google [1] gives http://www.unixgods.org/~tilo/replace_string/
but the unixgods are not what they used to be :-D.
I guess you are using win32. I often start at Freshmeat, using win32 and
some keywords, but couldn't find anything, so then I go to
http://www.tucows.com/, search for replace, and presto:
http://www.inforapid.de/html/searchreplace.htm
[1] http://www.google.com/search?q=search+replace+recursive
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced Perl programmer available: http://castleamber.com/
------------------------------
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 6487
***************************************