[28992] in Perl-Users-Digest
Perl-Users Digest, Issue: 236 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 18 16:10:38 2007
Date: Sun, 18 Mar 2007 13:09:09 -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, 18 Mar 2007 Volume: 11 Number: 236
Today's topics:
Re: anyone could explain this to me? anno4000@radom.zrz.tu-berlin.de
Re: anyone could explain this to me? <spamtrap@dot-app.org>
Re: anyone could explain this to me? <hjp-usenet2@hjp.at>
array question <"v.niekerk at hccnet.nl">
Re: array question <jurgenex@hotmail.com>
Re: array question <wahab-mail@gmx.de>
Re: array question <"v.niekerk at hccnet.nl">
Re: array question <"v.niekerk at hccnet.nl">
Re: array question <m@rtij.nl.invlalid>
Demo of a shrinking perl script <hjp-usenet2@hjp.at>
Install Perl on windows 2000 PRO environment ehtisham@gmail.com
Re: Install Perl on windows 2000 PRO environment <bart.lateur@pandora.be>
Re: Module for random array distribution <bik.mido@tiscalinet.it>
Re: new CGI::Session creates a new session every visit. <paduille.4060.mumia.w+nospam@earthlink.net>
Re: new CGI::Session creates a new session every visit. <uri@stemsystems.com>
Re: new CGI::Session creates a new session every visit. <mark.clementsREMOVETHIS@wanadoo.fr>
new CPAN modules on Sun Mar 18 2007 (Randal Schwartz)
Re: Philippine Sex Scandal & Sex Tips <uri@stemsystems.com>
Re: Reading STDIN seems to be breaking my script <ramon@conexus.net>
Reformatting file - basic question <pklund@gmail.com>
Re: Reformatting file - basic question <bik.mido@tiscalinet.it>
Re: Scope and Arrays <uri@stemsystems.com>
Re: Screen Scrapping <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Mar 2007 18:45:06 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: anyone could explain this to me?
Message-Id: <565fliF27ee7vU1@mid.dfncis.de>
Dr.Ruud <rvtol+news@isolution.nl> wrote in comp.lang.perl.misc:
> anno4000@radom.zrz.tu-berlin.de schreef:
>
> > The regex could be simplified: /(.*)=(.*)/ would capture the same
> > things, given greediness and the structure of env output.
>
> Not if any environment variable would contain an "=".
>
> echo test=a=b |perl -wnle'
> print "$1/$2" if /^(test.*)=(.*)/
Well, it's a shell variable, it can't. That's in the structure of
env output.
Anno
------------------------------
Date: Sun, 18 Mar 2007 15:52:31 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: anyone could explain this to me?
Message-Id: <m2hcsigwhs.fsf@local.wv-www.com>
anno4000@radom.zrz.tu-berlin.de writes:
> Dr.Ruud <rvtol+news@isolution.nl> wrote in comp.lang.perl.misc:
>>
>> Not if any environment variable would contain an "=".
>>
>> echo test=a=b |perl -wnle'
>> print "$1/$2" if /^(test.*)=(.*)/
>
> Well, it's a shell variable, it can't. That's in the structure of
> env output.
local:~ sherm$ export FOO=BAR\=BAZ
local:~ sherm$ env | grep FOO
FOO=BAR=BAZ
sherm--
--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Sun, 18 Mar 2007 20:54:27 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: anyone could explain this to me?
Message-Id: <slrnevr67j.eks.hjp-usenet2@yoyo.hjp.at>
On 2007-03-18 18:45, anno4000@radom.zrz.tu-berlin.de <anno4000@radom.zrz.tu-berlin.de> wrote:
> Dr.Ruud <rvtol+news@isolution.nl> wrote in comp.lang.perl.misc:
>> anno4000@radom.zrz.tu-berlin.de schreef:
>> > The regex could be simplified: /(.*)=(.*)/ would capture the same
>> > things, given greediness and the structure of env output.
>>
>> Not if any environment variable would contain an "=".
>>
>> echo test=a=b |perl -wnle'
>> print "$1/$2" if /^(test.*)=(.*)/
>
> Well, it's a shell variable, it can't.
Sure it can:
yoyo:~/tmp 17:22 187% export foo=bar=baz
yoyo:~/tmp 20:53 188% env | grep foo
foo=bar=baz
hp
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
Date: Sun, 18 Mar 2007 13:20:26 +0100
From: Huub <"v.niekerk at hccnet.nl">
Subject: array question
Message-Id: <45fd2e8c$0$3394$e4fe514c@dreader29.news.xs4all.nl>
Hi,
In my script I read 4 fields (2 numerical and 4 strings (i.e.
'char'-type)) from a MySQL database to print it. This works well, but I
want to sort the array on one of the numerical fields before printing.
I've looked through CPAN but get lost on looking for array. Can I store
those fields in 1 array (how?) and sort the array or is there another
way I should do this?
Thanks,
Huub
------------------------------
Date: Sun, 18 Mar 2007 12:46:51 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: array question
Message-Id: <%waLh.4235$FS5.2940@trndny09>
Huub" <"v.niekerk at hccnet.nl wrote:
> In my script I read 4 fields (2 numerical and 4 strings (i.e.
> 'char'-type)) from a MySQL database to print it. This works well, but
> I want to sort the array
Which array?
> on one of the numerical fields before
> printing. I've looked through CPAN but get lost on looking for array.
If you want to sort then the documentation for sort() should probably be
your first information source.
Also, there are quite a few tips in the FAQ: "How do I sort an array by
(anything)?"
> Can I store those fields in 1 array (how?)
Well, technically yes, but it doesn't make much sense to store disparate
items in the same list. You don't put your shopping list for gorceries, time
for your next oil change, and contact list of your friends on the same sheet
of paper either.
> and sort the array or is there another way I should do this?
What about an AoH (aka Array of Hash)?
jue
------------------------------
Date: Sun, 18 Mar 2007 14:31:52 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: array question
Message-Id: <etjfcf$kcn$1@mlucom4.urz.uni-halle.de>
Huub wrote:
> In my script I read 4 fields (2 numerical and 4 strings (i.e.
> 'char'-type)) from a MySQL database to print it. This works well, but I
> want to sort the array on one of the numerical fields before printing.
> I've looked through CPAN but get lost on looking for array. Can I store
> those fields in 1 array (how?) and sort the array or is there another
> way I should do this?
What exactly do you do? (Working-)code snippets?
Why isn't it in your case possible to retrieve
sorted records from the sql? Do you have accsess
to the sql command?
SELECT h.firstnumber, h.secondnumber, h.firststring, h.secondstring
FROM huubtable as h
ORDER BY h.secondnumber
BTW:
perldoc -q "How do I sort an array by (anything)?"
Regards
Mirco
------------------------------
Date: Sun, 18 Mar 2007 14:39:47 +0100
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: array question
Message-Id: <45fd413e$0$7674$e4fe514c@dreader12.news.xs4all.nl>
Jürgen Exner wrote:
> Huub" <"v.niekerk at hccnet.nl wrote:
>> In my script I read 4 fields (2 numerical and 4 strings (i.e.
>> 'char'-type)) from a MySQL database to print it. This works well, but
>> I want to sort the array
>
> Which array?
>
>> on one of the numerical fields before
>> printing. I've looked through CPAN but get lost on looking for array.
>
> If you want to sort then the documentation for sort() should probably be
> your first information source.
> Also, there are quite a few tips in the FAQ: "How do I sort an array by
> (anything)?"
>
>> Can I store those fields in 1 array (how?)
>
> Well, technically yes, but it doesn't make much sense to store disparate
> items in the same list. You don't put your shopping list for gorceries, time
> for your next oil change, and contact list of your friends on the same sheet
> of paper either.
>
>> and sort the array or is there another way I should do this?
>
> What about an AoH (aka Array of Hash)?
>
> jue
>
>
Thank you.
------------------------------
Date: Sun, 18 Mar 2007 14:41:26 +0100
From: Huub <"v.niekerk at hccnet.nl">
Subject: Re: array question
Message-Id: <45fd41a1$0$7674$e4fe514c@dreader12.news.xs4all.nl>
Mirco Wahab wrote:
> Huub wrote:
>
>> In my script I read 4 fields (2 numerical and 4 strings (i.e.
>> 'char'-type)) from a MySQL database to print it. This works well, but
>> I want to sort the array on one of the numerical fields before
>> printing. I've looked through CPAN but get lost on looking for array.
>> Can I store those fields in 1 array (how?) and sort the array or is
>> there another way I should do this?
>
> What exactly do you do? (Working-)code snippets?
>
> Why isn't it in your case possible to retrieve
> sorted records from the sql? Do you have accsess
> to the sql command?
>
> SELECT h.firstnumber, h.secondnumber, h.firststring, h.secondstring
> FROM huubtable as h
> ORDER BY h.secondnumber
>
Didn't think of this way.
>
>
> BTW:
> perldoc -q "How do I sort an array by (anything)?"
>
Thank you.
------------------------------
Date: Sun, 18 Mar 2007 15:43:37 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: array question
Message-Id: <pan.2007.03.18.14.43.41@rtij.nl.invlalid>
On Sun, 18 Mar 2007 14:41:26 +0100, Huub wrote:
> Mirco Wahab wrote:
>> Huub wrote:
>>
>>> In my script I read 4 fields (2 numerical and 4 strings (i.e.
>>> 'char'-type)) from a MySQL database to print it. This works well, but
>>> I want to sort the array on one of the numerical fields before
>>> printing. I've looked through CPAN but get lost on looking for array.
>>> Can I store those fields in 1 array (how?) and sort the array or is
>>> there another way I should do this?
>>
>> What exactly do you do? (Working-)code snippets?
>>
>> Why isn't it in your case possible to retrieve sorted records from the
>> sql? Do you have accsess to the sql command?
>>
>> SELECT h.firstnumber, h.secondnumber, h.firststring, h.secondstring
>> FROM huubtable as h
>> ORDER BY h.secondnumber
>>
>>
> Didn't think of this way.
>
If the table is large and you create an index on secondnumber, this is
also very fast, at the expense of slower insertion times.
M4
------------------------------
Date: Sun, 18 Mar 2007 17:19:14 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Demo of a shrinking perl script
Message-Id: <slrnevqpk2.8an.hjp-usenet2@yoyo.hjp.at>
Some time ago we had a discussion about the FAQ "How can I free an array
or hash so my program shrinks?". I claimed that on Linux and other OSs
with modern malloc implementations (probably BSDs including MacOS and
Windows) perl can and does return memory to the OS, but couldn't come up
with an example. Now I found one:
#!/usr/bin/perl
use warnings;
use strict;
sub a {
print "a\tcall\t", vm(), "\n";
my $h;
for ('a' .. 'z') {
$h->{$_} = $_ x 1_000_000;
}
print "a\treturn\t", vm(), "\n";
return $h;
}
sub c {
print "c\tcall\t", vm(), "\n";
a();
print "c\treturn\t", vm(), "\n";
}
c();
sub vm {
open(my $fh, '<', "/proc/$$/status");
while (<$fh>) {
chomp;
return $_ if (/^VmSize:/);
}
}
__END__
On my Linux box, this prints:
c call VmSize: 5056 kB
a call VmSize: 5056 kB
a return VmSize: 31516 kB
c return VmSize: 6036 kB
demonstrating that the process grows by roughly 26 MB as the anonymous
hash is created and then shrinks again when the reference to it goes out
of scope. This also works with a simple hash or array. For simple
(large) scalars it is more complicated: Memory does get freed sometimes,
but it isn't easy to determine when.
hp
--
_ | Peter J. Holzer | Blaming Perl for the inability of programmers
|_|_) | Sysadmin WSR | to write clearly is like blaming English for
| | | hjp@hjp.at | the circumlocutions of bureaucrats.
__/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
------------------------------
Date: 18 Mar 2007 06:28:50 -0700
From: ehtisham@gmail.com
Subject: Install Perl on windows 2000 PRO environment
Message-Id: <1174224530.421063.281220@b75g2000hsg.googlegroups.com>
Hi: Can any one please tell me how to i install Perl on windows 2000
PRO environment?
Thanks,
------------------------------
Date: Sun, 18 Mar 2007 13:55:04 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Install Perl on windows 2000 PRO environment
Message-Id: <q0hqv2p9chs7v2733c06974scpdtdoo3be@4ax.com>
ehtisham@gmail.com wrote:
>Hi: Can any one please tell me how to i install Perl on windows 2000
>PRO environment?
Same as on any other Windows: go to Activestate.com, and download
ActivePerl.
<http://activestate.com/store/activeperl/download/>
--
Bart.
------------------------------
Date: Sun, 18 Mar 2007 11:33:37 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Module for random array distribution
Message-Id: <d05qv2lnjsbqtot3p5hpj35210ibuube2d@4ax.com>
On Sun, 18 Mar 2007 01:11:33 +0100, Tomek <balrog2000@o2.pl> wrote:
>First of all, it is very hard to search CPAN for that module, cause almost
>all modules contain words array and distribution ;)
*Which* module?
>What am I going to achieve is to semi-randomly fill an array. There are 2
>main goals: sum of elements, and min/max for each elem)
It's too early in the morning (well, not truely, but it is for me now)
to really reason about this but at first sight I suspect you have too
many constraints to be statisfied by a given distribution.
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: Sun, 18 Mar 2007 09:32:32 GMT
From: "Mumia W." <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: new CGI::Session creates a new session every visit. GRRR!!!
Message-Id: <QG7Lh.128656$_73.90743@newsread2.news.pas.earthlink.net>
On 03/15/2007 05:43 PM, TonyV wrote:
> [...]
> use strict;
> use CGI::Session;
> use CGI;
>
> my $cgi = new CGI;
> my $session = new CGI::Session(undef, undef, {Directory=>'/websessions/
The second parameter should be a CGI object like so:
my $session = new CGI::Session(undef, $cgi, {Directory => ...
> [...]
HTH
------------------------------
Date: Sun, 18 Mar 2007 14:13:02 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: new CGI::Session creates a new session every visit. GRRR!!!
Message-Id: <x7odmq1i2p.fsf@mail.sysarch.com>
>>>>> "x" == xhoster <xhoster@gmail.com> writes:
x> While I'll be. That will teach me not to read the perldocs for my
x> locally installed version rather than the version the OP was
x> talking about.
i am not sure if english is your first language so i will assume it is
not. the expression is, "well, i'll be ..." with ... being one of many
subphrases (damned, hornswoggled, etc. :).
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 18 Mar 2007 20:31:50 +0100
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: new CGI::Session creates a new session every visit. GRRR!!!
Message-Id: <45fd93a6$0$25950$ba4acef3@news.orange.fr>
Uri Guttman wrote:
>>>>>> "x" == xhoster <xhoster@gmail.com> writes:
>
>
> x> While I'll be. That will teach me not to read the perldocs for my
> x> locally installed version rather than the version the OP was
> x> talking about.
>
> i am not sure if english is your first language so i will assume it is
> not. the expression is, "well, i'll be ..." with ... being one of many
> subphrases (damned, hornswoggled, etc. :).
>
Very often it's just plain "Well I'll be," the expletive being implied.
It works fine on its own.
------------------------------
Date: Sun, 18 Mar 2007 04:42:10 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Mar 18 2007
Message-Id: <JF312A.11wp@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.
Alien-GvaScript-1.02
http://search.cpan.org/~dami/Alien-GvaScript-1.02/
Gva extension to the prototype javascript framework
----
App-REPL-0.011
http://search.cpan.org/~ayrnieu/App-REPL-0.011/
A container for functions for the iperl program
----
Audio-MPD-0.14.0
http://search.cpan.org/~jquelin/Audio-MPD-0.14.0/
Class for talking to MPD (Music Player Daemon) servers
----
Audio-MPD-0.15.0
http://search.cpan.org/~jquelin/Audio-MPD-0.15.0/
Class for talking to MPD (Music Player Daemon) servers
----
Bloom-Faster-1.3.1
http://search.cpan.org/~palvaro/Bloom-Faster-1.3.1/
Perl extension for the c library libbloom.
----
Bloom-Faster-1.4
http://search.cpan.org/~palvaro/Bloom-Faster-1.4/
Perl extension for the c library libbloom.
----
Business-CCProcessor-0.09
http://search.cpan.org/~hesco/Business-CCProcessor-0.09/
Pass transaction off to secure processor
----
Business-OnlinePayment-CashCow-0.08
http://search.cpan.org/~jonasbn/Business-OnlinePayment-CashCow-0.08/
Online payment processing via CashCow
----
Catalyst-Plugin-EmailValid-0.013
http://search.cpan.org/~franckc/Catalyst-Plugin-EmailValid-0.013/
Email::Valid for Catalyst
----
Crypt-ECDSA-0.047
http://search.cpan.org/~billh/Crypt-ECDSA-0.047/
Elliptical Cryptography Digital Signature Algorithm
----
Data-YAML-0.0.3
http://search.cpan.org/~andya/Data-YAML-0.0.3/
Easy YAML serialisation of Perl data structures
----
Data-YAML-0.0.4
http://search.cpan.org/~andya/Data-YAML-0.0.4/
Easy YAML serialisation of Perl data structures
----
Devel-ebug-Wx-0.04
http://search.cpan.org/~mbarbon/Devel-ebug-Wx-0.04/
GUI interface for your (d)ebugging needs
----
Device-TNC-0.01
http://search.cpan.org/~rbdavison/Device-TNC-0.01/
A module to talk to a TNC
----
Games-Bingo-Print-0.03
http://search.cpan.org/~jonasbn/Games-Bingo-Print-0.03/
a PDF Generation Class for Games::Bingo
----
Games-WoW-Armory-0.0.1
http://search.cpan.org/~franckc/Games-WoW-Armory-0.0.1/
Access to the WoW Armory
----
Graphics-ColorUtils-0.07
http://search.cpan.org/~janert/Graphics-ColorUtils-0.07/
Easy-to-use color space conversions and more.
----
Gtk2-CV-1.4
http://search.cpan.org/~mlehmann/Gtk2-CV-1.4/
----
JSON-DWIW-0.02
http://search.cpan.org/~dowens/JSON-DWIW-0.02/
JSON converter that Does What I Want
----
Java-JCR-0.08
http://search.cpan.org/~hanenkamp/Java-JCR-0.08/
Use JSR 170 (JCR) repositories from Perl
----
Language-Kemuri-0.02
http://search.cpan.org/~tokuhirom/Language-Kemuri-0.02/
Kemuri Interpreter.
----
Lingua-AlignmentSet-1.1
http://search.cpan.org/~plambert/Lingua-AlignmentSet-1.1/
Tools library to manage an Alignment Sets, i.e. a set of sentences aligned at the word (or phrase) level.
----
MSDOS-Descript-1.02
http://search.cpan.org/~cjm/MSDOS-Descript-1.02/
Manage 4DOS style DESCRIPT.ION files
----
Module-Info-File-0.11
http://search.cpan.org/~jonasbn/Module-Info-File-0.11/
retrieves module information from a file or script
----
Net-Bonjour-0.92
http://search.cpan.org/~chlige/Net-Bonjour-0.92/
Module for DNS service discovery (Apple's Bonjour)
----
Net-Bonjour-0.95
http://search.cpan.org/~chlige/Net-Bonjour-0.95/
Module for DNS service discovery (Apple's Bonjour)
----
OpenOffice-OODoc-2.033
http://search.cpan.org/~jmgdoc/OpenOffice-OODoc-2.033/
The Perl Open OpenDocument Connector
----
OpenOffice-OODoc-2.034
http://search.cpan.org/~jmgdoc/OpenOffice-OODoc-2.034/
The Perl Open OpenDocument Connector
----
PDF-API2-0.59.001
http://search.cpan.org/~areibens/PDF-API2-0.59.001/
A Perl Module Chain to faciliate the Creation and Modification of High-Quality "Portable Document Format (aka. PDF)" Files.
----
PDF-API2-0.59.002
http://search.cpan.org/~areibens/PDF-API2-0.59.002/
A Perl Module Chain to faciliate the Creation and Modification of High-Quality "Portable Document Format (aka. PDF)" Files.
----
Taint-Util-0.03
http://search.cpan.org/~avar/Taint-Util-0.03/
Test for and flip the taint flag without regex matches or eval
----
Test-Prereq-1.033
http://search.cpan.org/~bdfoy/Test-Prereq-1.033/
check if Makefile.PL has the right pre-requisites
----
Test-Run-0.0107
http://search.cpan.org/~shlomif/Test-Run-0.0107/
----
Test-Run-0.0108
http://search.cpan.org/~shlomif/Test-Run-0.0108/
----
Test-Run-Plugin-AlternateInterpreters-0.0102
http://search.cpan.org/~shlomif/Test-Run-Plugin-AlternateInterpreters-0.0102/
Define different interpreters for different test scripts with Test::Run.
----
Test-Run-Plugin-CollectStats-0.01
http://search.cpan.org/~shlomif/Test-Run-Plugin-CollectStats-0.01/
Test::Run plugin to collect statistics and data.
----
Tk-Canvas-Point-0.03
http://search.cpan.org/~srezic/Tk-Canvas-Point-0.03/
----
XML-MyXML-0.0969
http://search.cpan.org/~karjala/XML-MyXML-0.0969/
A simple-to-use XML module, for parsing and creating XML documents
----
XML-RSS-FromHTML-Simple-0.03
http://search.cpan.org/~mschilli/XML-RSS-FromHTML-Simple-0.03/
Create RSS feeds for sites that don't offer them
----
forks-0.21
http://search.cpan.org/~rybskej/forks-0.21/
drop-in replacement for Perl threads using fork()
----
namespace-clean-0.04
http://search.cpan.org/~phaylon/namespace-clean-0.04/
Keep imports and functions out of your namespace
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/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sun, 18 Mar 2007 14:20:00 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Philippine Sex Scandal & Sex Tips
Message-Id: <x7fy821hr3.fsf@mail.sysarch.com>
>>>>> "s" == sidoy <karajutsu@yahoo.com> writes:
s> you can find it here the SEX SCANDAL of the Philippines at
s> http://www.pinoysexguru.blogspot.com
it is about time that perl had a good sex scandal! she has been pining
for one since the days of perl4!
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 18 Mar 2007 13:06:21 -0700
From: "Ramon F Herrera" <ramon@conexus.net>
Subject: Re: Reading STDIN seems to be breaking my script
Message-Id: <1174248381.360076.215200@y66g2000hsf.googlegroups.com>
On Mar 17, 6:23 pm, Abigail <abig...@abigail.be> wrote:
>
> 'my' was introduced in Perl 5.000, which dates from 1994. The same
> version introduced 'strict.pm', a module that you must use to get the
> 'Global symbol "$Welcome" requires explicit package name' error message.
Abigail:
I began learning Perl around 1993. The llama book did not mention the
'my' feature. I have been writing my-less scripts, and I didn't need
it until now. Perl is not my primary programming language, which are C
and Java. But I be using Perl much more often now, since I chose it
(among a wide array of choices) for my AGI and other scripts.
>
> I'm a bit baffled that you claim to be ignorant of Perl5 features, yet
> you do use them.
>
I just lifted some code (from a demo AGI script) which I am trying to
integrate into my code.
-Ramon
------------------------------
Date: 17 Mar 2007 22:01:34 -0700
From: "per" <pklund@gmail.com>
Subject: Reformatting file - basic question
Message-Id: <1174194094.815052.295390@e1g2000hsg.googlegroups.com>
I have very limited knowledge about Perl (used to know the basics, but
that is a while ago) and hope someone can help with advice.
I need to reformat a text file with several segments as listed below.
The reformatting consists of (a) extracting a string (cats, dogs,
fish, etc. in the example below), and copy them into the "CATEGORIES:"
part of the text. The source file is an exported blog, and have
several entries, so this procedure will be repeated several times.
*** This is what I have (only showing the relevant segment for one
entry) ***
CATEGORIES:
DATE: 03/20/2007 04:13:00 PM
-----
BODY:
text here text here some urls as well more text.
Labels: <a rel='tag' href="http://blogname.wordpress.com/tag/
cats">cats</a>,
<a rel='tag' href="http://blogname.wordpress.com/tag/dogs">dogs</a>,
<a rel='tag' href="http://blogname.wordpress.com/tag/fish">fish</a>,
<a rel='tag' href="http://blogname.wordpress.com/tag/
chameleons">chameleons</a>
*** And this is how it should look when finished ***
CATEGORIES: cats
CATEGORIES: dogs
CATEGORIES: fish
CATEGORIES: chameleons
DATE: 03/20/2007 04:13:00 PM
-----
BODY:
text here text here some urls as well more text.
Labels: <a rel='tag' href="http://blogname.wordpress.com/tag/
cats">cats</a>,
<a rel='tag' href="http://blogname.wordpress.com/tag/dogs">dogs</a>,
<a rel='tag' href="http://blogname.wordpress.com/tag/fish">fish</a>,
<a rel='tag' href="http://blogname.wordpress.com/tag/
chameleons">chameleons</a>
.............................
I initially tried using BK ReplaceEm, but it seems to not be the right
application for this task. Someone at a Regular Expression forum
suggested I use this Perl script instead:
perl -0777pe 's{
^CATEGORIES:\s*(.*?Labels:\s*)
((?:<a[^>]*>(.*?)(?{$x .="CATEGORIES: $3\n"})</a>(,\s)?)*)
}{$x\n$1$2}msx
' mydoc.txt
This should do the job, but I need help with making it work for me.
So the question is: What needs to be added?
I have Active Perl installed on Windows XP, and I need to read from
one text file, and output the result to another (copying the whole
file, and adding the labels to where it says "CATEGORIES:") The
source file has a series of entries like what is shown above, so the
Perl script needs to do this for each one.
Any help is greatly appreciated!
Per
------------------------------
Date: Sun, 18 Mar 2007 12:13:51 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Reformatting file - basic question
Message-Id: <b47qv2dv7029ln8ad9l2n90b49t34ccfb4@4ax.com>
On 17 Mar 2007 22:01:34 -0700, "per" <pklund@gmail.com> wrote:
>I have very limited knowledge about Perl (used to know the basics, but
>that is a while ago) and hope someone can help with advice.
That's fine. But this is *not* a help desk, you know...
>
>I need to reformat a text file with several segments as listed below.
>The reformatting consists of (a) extracting a string (cats, dogs,
>fish, etc. in the example below), and copy them into the "CATEGORIES:"
>part of the text. The source file is an exported blog, and have
>several entries, so this procedure will be repeated several times.
Exported? In which sense?
>Labels: <a rel='tag' href="http://blogname.wordpress.com/tag/
>cats">cats</a>,
><a rel='tag' href="http://blogname.wordpress.com/tag/dogs">dogs</a>,
><a rel='tag' href="http://blogname.wordpress.com/tag/fish">fish</a>,
><a rel='tag' href="http://blogname.wordpress.com/tag/
>chameleons">chameleons</a>
Ah, ok, so you have HTML, and you want to parse it. (*)
>I initially tried using BK ReplaceEm, but it seems to not be the right
What is "BK ReplaceEm"? Is it relevant for the question you're asking
anyway?
>application for this task. Someone at a Regular Expression forum
>suggested I use this Perl script instead:
(*) And you want to parse it with regexen!
>
>perl -0777pe 's{
> ^CATEGORIES:\s*(.*?Labels:\s*)
> ((?:<a[^>]*>(.*?)(?{$x .="CATEGORIES: $3\n"})</a>(,\s)?)*)
> }{$x\n$1$2}msx
>' mydoc.txt
Not only do you want to parse it with regexen, but also do the
substitution, all with *one* regex. Now, this is bat(TM). Use a HTML
parsing module as is always recommended instead. This minimal example
may help to get you started:
#!/usr/bin/perl -ln0777
use strict;
use warnings;
use HTML::TokeParser;
my $p=HTML::TokeParser->new(\$_);
while ( my $t=$p->get_tag('a') ) {
print $p->get_trimmed_text if $t->[1]{rel} eq 'tag';
}
__END__
This writing the found tags to the "CATEGORIES" section is left as an
exercise. Do not hesitate to ask for further help should you have any
difficulty doing so.
>This should do the job, but I need help with making it work for me.
>
>So the question is: What needs to be added?
To do what? How is it unsatisfactory for you?
>I have Active Perl installed on Windows XP, and I need to read from
>one text file, and output the result to another (copying the whole
>file, and adding the labels to where it says "CATEGORIES:") The
>source file has a series of entries like what is shown above, so the
>Perl script needs to do this for each one.
>
>Any help is greatly appreciated!
I have not tested nor cared to actually read in detail the simple
oneliner that has been suggested to you, but it is pure Perl not using
any particular module so I don't see what could be missing. Since
you're under Windows you would only have to change CLI quoting, but
that's not a major obstacle after all. Who knows, maybe it may suit
your needs after all. Have you tried it?!?
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: Sun, 18 Mar 2007 14:17:52 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Scope and Arrays
Message-Id: <x7k5xe1hun.fsf@mail.sysarch.com>
>>>>> "a" == anno4000 <anno4000@radom.zrz.tu-berlin.de> writes:
a> Brian McCauley <nobull67@gmail.com> wrote in comp.lang.perl.misc:
>>
>> To see my epiphany:
>>
>> http://groups.google.com/group/comp.lang.perl.misc/browse_frm/thread/e00e827ea3f9ab6f/2fbfe18a8d5e7acd#2fbfe18a8d5e7acd
a> I haven't followed your example in detail but I've seen similar cases.
a> I think it's no coincidence that your problem was recursive. Some
a> recursive knots can be solved by introduction of a global variable or
a> two. The sword of globality, as it were.
i haven't looked at the epiphany yet (may do it later) but you can still
use lexicals in such cases if they are file or block scoped with the
recursive code. or in some cases closures can solve tricky problems. of
course i am assuming globals are proper symbol table vars and that you
technically (almost? :) never need them.
a> However, the code the OP has to deal with seems to be based on the
a> Design Pattern of "Make Everything Global and Access at Will". (MEGAW?)
a> That only works for small, one-off scripts. The problem is that small
a> one-off scripts get re-used and extended in infinitesimal steps way
a> beyond the breaking point.
call it fortran common block coding! :)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 18 Mar 2007 11:21:33 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Screen Scrapping
Message-Id: <1k4qv2tu7u9jkadrispstd1lis7n3magkp@4ax.com>
On 17 Mar 2007 16:28:40 -0700, "Anna" <colleen1980@gmail.com> wrote:
>Name, Birth, Death in my computer. I heard some thing about screen
>scrapping but no idea how to i use it
I suppose the buzzword is "web scraping". Well, not really a word...
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: 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 236
**************************************