[31067] in Perl-Users-Digest
Perl-Users Digest, Issue: 2312 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 1 11:09:43 2009
Date: Wed, 1 Apr 2009 08:09:08 -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 Wed, 1 Apr 2009 Volume: 11 Number: 2312
Today's topics:
Re: Being more restrictive when using blessed hash ref jl_post@hotmail.com
database advice <cartercc@gmail.com>
Re: finding maximum sln@netherlands.com
Re: finding maximum <rjh@see.sig.invalid>
Re: finding maximum sln@netherlands.com
Re: finding maximum (Richard Harter)
Re: finding maximum <josef.moellers@ts.fujitsu.com>
Re: finding maximum <bart.lateur@pandora.be>
Re: finding maximum <fred.l.kleinschmidt@boeing.com>
Re: Interpreting terminal codes in Perl <RedGrittyBrick@spamweary.invalid>
new CPAN modules on Wed Apr 1 2009 (Randal Schwartz)
Re: Pass Match Values to Variable <justin.0903@purestblue.com>
Re: Question about the example in perlthrtut jl_post@hotmail.com
Script Execution time and Use <a_person@anyolddomain.fake>
Re: Script Execution time and Use <peter@makholm.net>
Re: search/replace <molsted@gmail.com>
Re: search/replace <tadmc@seesig.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 1 Apr 2009 07:16:08 -0700 (PDT)
From: jl_post@hotmail.com
Subject: Re: Being more restrictive when using blessed hash ref for OOP
Message-Id: <e3acd9a0-2457-40f1-b37e-e195665ea699@d38g2000prn.googlegroups.com>
> On Tue, 31 Mar 2009 08:32:23 -0700 (PDT), jl_p...@hotmail.com wrote:
> >use fields qw(PLAYERS);
> >sub new
> >{
> > =A0 =A0my Game $self =3D shift;
On Mar 31, 6:59 pm, s...@netherlands.com wrote:
> =A0 =A0 =A0^^^^^^^^^^^^^^^^^^^^^
> I'm not from oldschool. What syntax is this?
I actually got this code (with modifications so that it fits the
"Game" package) from the "perldoc fields" documentation. You can read
about it there.
> > =A0 =A0$self =3D fields::new($self) =A0unless (ref $self);
>
> =A0 =A0 =A0^^^.........
> Can you explain this briefly. No use putting down stuff somebody
> has to explore. Where is the bless?
Again, I got this code from the "perldoc fields" documentation. As
for where is the bless, that's a good questions. I know the "perldoc
fields" documentation covers that (it's not hard to find; just search
for "bless").
> > =A0 I THOUGHT barewords would be checked at compile-time, but my own
> >experimentation just now leads me to believe it's a run-time check.
>
> How did you draw that conclusion? Why wouldn't barewords be compile-time?
I drew that conclusion by placing output statements before the line
that caused the error. Since those lines were run before the error
message was shown, I concluded that part of the program was run, and
therefore the error was caught at run-time. (Although it would be
nice if bareword errors of that type were caught at compile-time.)
If you find the code confusing, or there's something about it you
don't understand, I highly recommend reading perldocs on
"field" (that's what they're there for, after all). Otherwise, I'd
just be stating what you already have access to.
Cheers,
-- Jean-Luc
------------------------------
Date: Wed, 1 Apr 2009 07:49:47 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: database advice
Message-Id: <82b7e6a3-68ec-4f4c-afc3-b74119bf7ae7@z19g2000yqe.googlegroups.com>
I'm building a database app (in Perl) and have a database question.
Ordinarily, when you have a many to many relationship, such as patient/
diagnosis, you deal with it by having a conversion table, where (for
example) patients are not unique, diagnoses are not unique, but a
patient/diagnosis combination is unique.
I my app, I have this situation, but this approach seems to cumbersome
and I quite frankly think it will take too much of an effort for the
little bit of utility that I need, because I don't need to access
diagnoses, just display them, and only display them on infrequent
occasions. I've been using Postgres and have been spoiled by the array
datatype that PG has. If I were using PG, I'd use the array datatype.
(One problem is that the diagnoses are free form and it's just too
difficult to shoe-horn a multiplicity of diagnoses into a manageable
number.)
My client insists on using MySQL. I'm about to create a table, which
has a column 'diagnoses' and a datatype of text. I will append values
to this colum in a CSV format, such as (e.g.) "broken finger|headache|
sprained ankle|influenza". I can then access this cell as a string,
split on the pipe, and manipulate the resulting list as an array.
Has anyone done this? Does it work? What are the disadvantages?
Comments in general?
Thanks, CC.
------------------------------
Date: Wed, 01 Apr 2009 04:29:12 GMT
From: sln@netherlands.com
Subject: Re: finding maximum
Message-Id: <var5t45vrlj7paj4qo6008du690c4b5jtg@4ax.com>
On Wed, 01 Apr 2009 03:33:45 +0000, Richard Heathfield <rjh@see.sig.invalid> wrote:
>[I note that the OP has not yet had any responses that move him
>forward technically (nice try, though, Eric!). So the first part of
>this response is a token effort in that direction.]
>
>sandeep said:
>
>> Hello Friends ~
>>
>> How would you find the maximum of
>> (a) two numbers
>
>Use the comparison operator.
>
>> (b) a set of numbers
>
>Store the first number in the set, making it the "current maximum".
>Then use the comparison operator in a loop, updating the current
>maximum whenever appropriate.
>
>> in idiomatic C?
>
>See above.
>
>> How would you do it in idiomatic Perl?
>
>Well, personally I wouldn't do it in Perl, but no doubt the fine
>folks in comp.lang.perl.misc /would/ do it in Perl, and that is
>their right and privilege.
>
>> Use this as
>> a basis for a discussion of the differences in expressive power of
>> the two languages.
>
>C is expressively powerful, whereas Perl is powerfully expressive.
Pretty lose language. Can you give examples of that?
-sln
------------------------------
Date: Wed, 01 Apr 2009 04:37:42 +0000
From: Richard Heathfield <rjh@see.sig.invalid>
Subject: Re: finding maximum
Message-Id: <94CdnScgsvREck_UnZ2dnUVZ8tti4p2d@bt.com>
sln@netherlands.com said:
> On Wed, 01 Apr 2009 03:33:45 +0000, Richard Heathfield
> <rjh@see.sig.invalid> wrote:
<snip>
>>
>>C is expressively powerful, whereas Perl is powerfully expressive.
>
> Pretty lose language.
That's wonderfully self-referential. Thanks for the smile.
> Can you give examples of that?
See IOCCC for examples of expressively powerful C. See CPAN for
examples of expressively powerful Perl.
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
------------------------------
Date: Wed, 01 Apr 2009 05:36:55 GMT
From: sln@netherlands.com
Subject: Re: finding maximum
Message-Id: <kav5t4h529958754q9nam26qaak7hvo1fm@4ax.com>
On Wed, 01 Apr 2009 04:37:42 +0000, Richard Heathfield <rjh@see.sig.invalid> wrote:
>sln@netherlands.com said:
>
>> On Wed, 01 Apr 2009 03:33:45 +0000, Richard Heathfield
>> <rjh@see.sig.invalid> wrote:
>
><snip>
>>>
>>>C is expressively powerful, whereas Perl is powerfully expressive.
>>
>> Pretty lose language.
>
>That's wonderfully self-referential. Thanks for the smile.
>
>> Can you give examples of that?
>
>See IOCCC for examples of expressively powerful C. See CPAN for
>examples of expressively powerful Perl.
Why don't you 'C' a doctor for examples.
-sln
------------------------------
Date: Wed, 01 Apr 2009 06:11:35 GMT
From: cri@tiac.net (Richard Harter)
Subject: Re: finding maximum
Message-Id: <49d3040f.467624765@text.giganews.com>
On Tue, 31 Mar 2009 23:13:09 +0100, sandeep <nospam@nospam.com>
wrote:
>Hello Friends ~
>
>How would you find the maximum of
>(a) two numbers
Form a set containing the two numbers. Remove the smaller one
from the set. The one remaining in the set is the maximum.
>(b) a set of numbers
Divide the set into two subsets. Find the maximum of each
subset. Apply the method in step (a) to find the maximum of the
two maximums.
>in idiomatic C? How would you do it in idiomatic Perl? Use this as a basis
>for a discussion of the differences in expressive power of the two
>languages.
I would post a query in usenet and let real experts answer the
question.
Richard Harter, cri@tiac.net
http://home.tiac.net/~cri, http://www.varinoma.com
If I do not see as far as others, it is because
I stand in the footprints of giants.
------------------------------
Date: Wed, 01 Apr 2009 09:28:06 +0200
From: Josef Moellers <josef.moellers@ts.fujitsu.com>
Subject: Re: finding maximum
Message-Id: <gqv521$p25$2@nntp.fujitsu-siemens.com>
sandeep wrote:
> Hello Friends ~
>
> How would you find the maximum of
> (a) two numbers
> (b) a set of numbers
> in idiomatic C? How would you do it in idiomatic Perl? Use this as a basis
> for a discussion of the differences in expressive power of the two
> languages.
The simple answer is: "Post the problem to the usenet and wait for
others to solve it for you".
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
------------------------------
Date: Wed, 01 Apr 2009 11:52:39 +0200
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: finding maximum
Message-Id: <hae6t41b7e2tn1qfotimbfcoctpq18o9vh@4ax.com>
Josef Moellers wrote:
>sandeep wrote:
>> Hello Friends ~
>>
>> How would you find the maximum of
>> (a) two numbers
>> (b) a set of numbers
>> in idiomatic C? How would you do it in idiomatic Perl? Use this as a basis
>> for a discussion of the differences in expressive power of the two
>> languages.
>
>The simple answer is: "Post the problem to the usenet and wait for
>others to solve it for you".
Well, that doesn't seem to work too well.
--
Bart.
------------------------------
Date: Wed, 1 Apr 2009 07:44:43 -0700 (PDT)
From: Fred <fred.l.kleinschmidt@boeing.com>
Subject: Re: finding maximum
Message-Id: <06190278-d134-4b19-900c-b60a43c70745@r5g2000prh.googlegroups.com>
On Mar 31, 8:24=A0pm, Tad J McClellan <ta...@seesig.invalid> wrote:
> ["Followup-To:" header set to comp.lang.perl.misc.]
>
> Eric Sosman <esos...@ieee-dot-org.invalid> wrote:
> > sandeep wrote:
> >> in idiomatic C?
>
> > =A0 =A0 =A0There is no such thing as "idiomatic C." =A0There are only
> > "High C" (as practiced during the High C Era), and "Trade C"
> > (the patois that has taken hold among those who'd rather get
> > things done than argue about the proprieties). =A0There are also
> > some debased C-ish dialects, notably "Rapper's C" or "CRap."
>
> Leaving out "Tenne C" is inexcusable.
>
Or just use ordinary C, sometimes called C-plain
--
Fred K
------------------------------
Date: Wed, 01 Apr 2009 09:20:46 +0100
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: Interpreting terminal codes in Perl
Message-Id: <49d323e1$0$16165$db0fefd9@news.zen.co.uk>
Martijn Lievaart wrote:
> On Tue, 31 Mar 2009 08:07:39 +0200, Martijn Lievaart wrote:
>
[translating terminal control codes to human readable descriptions]
>
> I am currently encoding the full xterm set, I need to cover all the
> cases, not just those described by terminfo/termcap (although that covers
> 99.99% of the cases). In the end I hope to fully cover xterm*/ansi*/vt*,
> and will do the rest through reversing the termcap.
>
Yikes. ansi, sco-ansi, old sco-ansi, ansic, dosansi, hpansi ... vt52,
vt102, vt105, vt125, ... vt220 ... what about all the emulators? That's
hundreds, perhaps thousands of variants.
May I ask why you want to take on this enormous task? There must be a
good reason, but I'm having trouble imagining what it might be.
--
RGB
------------------------------
Date: Wed, 1 Apr 2009 04:42:26 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Apr 1 2009
Message-Id: <KHEnqq.J5B@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.
API-ISPManager-0.02
http://search.cpan.org/~nrg/API-ISPManager-0.02/
interface to the ISPManager Hosting Panel API ( http://ispsystem.com )
----
Acme-BadExample-1.01
http://search.cpan.org/~adamk/Acme-BadExample-1.01/
Perl document, yes. Perl code, no damn way!
----
Apache-Bootstrap-0.05
http://search.cpan.org/~phred/Apache-Bootstrap-0.05/
Bootstraps dual life mod_perl1 and mod_perl2 Apache modules
----
Bio-Glite-0.10
http://search.cpan.org/~gaou/Bio-Glite-0.10/
G-language Genome Analysis Environment REST service interface module
----
CGI-Application-Plugin-Authentication-0.13
http://search.cpan.org/~ceeshek/CGI-Application-Plugin-Authentication-0.13/
Authentication framework for CGI::Application
----
CGI-Application-Plugin-Menu-1.05
http://search.cpan.org/~leocharre/CGI-Application-Plugin-Menu-1.05/
manage navigation menus for cgi apps
----
CGI-Application-Plugin-Stream-2.10
http://search.cpan.org/~purdy/CGI-Application-Plugin-Stream-2.10/
CGI::Application Plugin for streaming files
----
CPAN-ParseDistribution-1.0
http://search.cpan.org/~dcantrell/CPAN-ParseDistribution-1.0/
index a file from the BackPAN
----
Catalyst-Controller-ActionRole-0.05
http://search.cpan.org/~flora/Catalyst-Controller-ActionRole-0.05/
Apply roles to action instances
----
Catalyst-Plugin-Session-Store-FastMmap-0.07
http://search.cpan.org/~flora/Catalyst-Plugin-Session-Store-FastMmap-0.07/
FastMmap session storage backend.
----
Config-Perl-V-0.02
http://search.cpan.org/~hmbrand/Config-Perl-V-0.02/
Structured data retreival of perl -V output
----
DBD-SQLite-1.19_03
http://search.cpan.org/~adamk/DBD-SQLite-1.19_03/
Self Contained RDBMS in a DBI Driver
----
DBIx-CheckConnectivity-0.01
http://search.cpan.org/~sunnavy/DBIx-CheckConnectivity-0.01/
util to check database's connectivity
----
Devel-Declare-0.003005
http://search.cpan.org/~flora/Devel-Declare-0.003005/
Adding keywords to perl, in perl
----
Getopt-Long-2.38
http://search.cpan.org/~jv/Getopt-Long-2.38/
Extended processing of command line options
----
Hessian-Client-0.1.10
http://search.cpan.org/~heytrav/Hessian-Client-0.1.10/
RPC via Hessian with a remote server.
----
Hessian-Client-0.1.11
http://search.cpan.org/~heytrav/Hessian-Client-0.1.11/
RPC via Hessian with a remote server.
----
Net-Whois-Raw-1.67
http://search.cpan.org/~despair/Net-Whois-Raw-1.67/
Get Whois information for domains
----
News-Pictures-0.09
http://search.cpan.org/~cguine/News-Pictures-0.09/
The great new News::Pictures!
----
Nginx-ParseLog-1.01
http://search.cpan.org/~nrg/Nginx-ParseLog-1.01/
module for parsing Nginx access log files (nginx.net).
----
Parallel-Fork-BossWorkerAsync-0.01
http://search.cpan.org/~jvannucci/Parallel-Fork-BossWorkerAsync-0.01/
Perl extension for creating asynchronous forking queue processing applications.
----
Parse-Dia-SQL-0.06
http://search.cpan.org/~aff/Parse-Dia-SQL-0.06/
Convert Dia class diagrams into SQL.
----
Perldoc-Server-0.01
http://search.cpan.org/~jonallen/Perldoc-Server-0.01/
local Perl documentation server
----
Pod-Simple-Vim-0.02
http://search.cpan.org/~pshangov/Pod-Simple-Vim-0.02/
Render pod for display in vim
----
SSH-Command-0.04
http://search.cpan.org/~nrg/SSH-Command-0.04/
interface to execute multiple commands on host by SSH protocol without certificates ( only login + password )
----
Search-Sitemap-2.07
http://search.cpan.org/~jasonk/Search-Sitemap-2.07/
Perl extension for managing Search Engine Sitemaps
----
Smolder-1.32
http://search.cpan.org/~wonko/Smolder-1.32/
Web-based smoke test aggregator
----
Smolder-1.33
http://search.cpan.org/~wonko/Smolder-1.33/
Web-based Continuous Integration Smoke Server
----
Test-Database-0.99
http://search.cpan.org/~book/Test-Database-0.99/
Database handles ready for testing
----
Text-Darts-0.05
http://search.cpan.org/~dankogai/Text-Darts-0.05/
Perl interface to DARTS by Taku Kudoh
----
Text-Darts-0.06
http://search.cpan.org/~dankogai/Text-Darts-0.06/
Perl interface to DARTS by Taku Kudoh
----
Text-TypingEffort-0.25
http://search.cpan.org/~mndrix/Text-TypingEffort-0.25/
Calculate the effort required to type a given text
----
Tk-ForDummies-Graph-1.00
http://search.cpan.org/~djibel/Tk-ForDummies-Graph-1.00/
Extension of Canvas widget to create a graph like GDGraph.
----
Tk-ForDummies-Graph-1.01
http://search.cpan.org/~djibel/Tk-ForDummies-Graph-1.01/
Extension of Canvas widget to create a graph like GDGraph.
----
Tk-ForDummies-Graph-1.02
http://search.cpan.org/~djibel/Tk-ForDummies-Graph-1.02/
Extension of Canvas widget to create a graph like GDGraph.
----
Tk-ForDummies-Graph-1.03
http://search.cpan.org/~djibel/Tk-ForDummies-Graph-1.03/
Extension of Canvas widget to create a graph like GDGraph.
----
UNIVERSAL-require-0.13
http://search.cpan.org/~mschwern/UNIVERSAL-require-0.13/
require() modules from a variable
----
URI-GoogleChart-0.03
http://search.cpan.org/~gaas/URI-GoogleChart-0.03/
Generate Google Chart URIs
----
WWW-Opentracker-Stats-1.10
http://search.cpan.org/~hovenko/WWW-Opentracker-Stats-1.10/
Perl module for retrieve statistics from Opentracker
----
stockmonkey-2.13
http://search.cpan.org/~jettero/stockmonkey-2.13/
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Wed, 01 Apr 2009 09:52:30 -0000
From: Justin C <justin.0903@purestblue.com>
Subject: Re: Pass Match Values to Variable
Message-Id: <36b4.49d3395e.dc7f@zem>
On 2009-03-31, perl Newbie <Ansher.M@gmail.com> wrote:
>
> Thanks for your detailed explanation.
>
> I am new to Perl (learning for the last 15 days) and using "Learning
> Perl" book. But it doesn?t help me much in understanding the way you
> have explained the details here :( Some of the other links I freq. use
> are
Learning Perl is the most read book I have. Until you've actually read
it, and worked through the exercises, it's not that helpful to 'dip'
into. You really need to work through it, cover to cover, do all the
exercises, and then you can use it as a reference.
Don't dismiss that book!
Justin.
--
Justin C, by the sea.
------------------------------
Date: Wed, 1 Apr 2009 07:37:19 -0700 (PDT)
From: jl_post@hotmail.com
Subject: Re: Question about the example in perlthrtut
Message-Id: <4e58b1b8-7cc1-462e-8e69-8248fce43845@s22g2000prg.googlegroups.com>
> On Tue, 31 Mar 2009 20:38:11 -0700, Xho Jingleheimerschmidt <xhos...@gmai=
l.com> wrote:
> >You would generally want to avoid that. =A0But this code is for playing,
> >not for practical applications.
>
> >Xho
On Mar 31, 10:05 pm, s...@netherlands.com wrote:
> You haven't a clue about this algo or threading. Disgracefull explanation=
s.
>
> -sln
I don't agree. Personally, I thought Xho's explanation was great.
And yours was good, too.
Thank you both for your responses. I had a feeling the code was
just for demonstrating (and not for production), but I found no
explanation in the perldoc to support that. So I wasn't sure how
"kosher" the code was.
Thanks again.
-- Jean-Luc
------------------------------
Date: Wed, 1 Apr 2009 12:14:59 +0100
From: "Bigus" <a_person@anyolddomain.fake>
Subject: Script Execution time and Use
Message-Id: <61IAl.47553$HF6.40157@newsfe08.iad>
Hi
I have a load of scripts that use various different cpan modules and I
thought to tidy up the header of each script I'd try bundling all the "use
.." commands into one init file in my modules folder. So in each script, at
the top, I have:
use strict;
use Modules::Init;
In Init.pm there are about 30 "use ..." lines. Using a basic test script
(test.pl) I enclosed the two lines above with a timer, ie:
use Devel::Timer;
my $t = Devel::Timer->new();
$t->mark("inits");
use strict;
use Modules::Init;
$t->mark("done init");
print $t->report();
That tells me that it took about 10 microseconds to run, which would be
great, however if I time the test script from the linux command line using:
time perl test.pl
it tells me that the script took about 1.6 seconds.
Evidently, the idea of use'ing all the modules in one place isn't going to
be a good one as it'll slow things down too much, but what I don't
understand, and was wondering if someone could clarify for me, is why there
is such a big difference in the two methods of timing?
Thanks
Bigus
------------------------------
Date: Wed, 01 Apr 2009 13:47:23 +0200
From: Peter Makholm <peter@makholm.net>
Subject: Re: Script Execution time and Use
Message-Id: <8763howq7o.fsf@vps1.hacking.dk>
"Bigus" <a_person@anyolddomain.fake> writes:
> use Devel::Timer;
> my $t = Devel::Timer->new();
> $t->mark("inits");
> use strict;
> use Modules::Init;
> $t->mark("done init");
> print $t->report();
use-statements happens at compile time, so you really havn't any
operations between you two marks.
------------------------------
Date: Wed, 1 Apr 2009 00:20:03 -0700 (PDT)
From: molsted <molsted@gmail.com>
Subject: Re: search/replace
Message-Id: <894ca64f-863b-401f-aa4a-89d87e4a20f6@q9g2000yqc.googlegroups.com>
On 30 Mar., 14:41, Tad J McClellan <ta...@seesig.invalid> wrote:
> Does your data really have caret-M in it or does it instead have
> carriage return-linefeed in it?
>
> You should write the data in Real Perl Code so that there is no ambiguity=
.
>
> Have you seen the Posting Guidelines that are posted here frequently?
>
> --------------------------
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> my @lang =3D qw/ <Style:GB> <Style:DE> <Style:FR> <Style:ES> <Style:DK> /=
;
>
> $_ =3D "&00Antiques\r\n&00Antiquit<0x00E4>ten\r\n&00Antiquit<0x00E9>s\r\n=
"
> =A0 =A0. "&00Antig<0x00FC>edades\r\n&00Antikviteter\r\n";
> print;
> print "\n";
>
> my $capture_num =3D 0;
> s/&00([^\r]+)\r\n/$lang[$capture_num++]$1\n/g;
> print;
> --------------------------
Hi Tad,
I haven't seen Posting Guidelines, this my first post to the group,
can i read them some where?
I'm going with your suggestion but it only matches the first line.
However if I put more sequences in the @lang-array it will work.
How would I overcome that?
----------------------------
#!/usr/bin/perl
use strict;
my $fileName=3D$ARGV[0];
open(FILE,"$fileName") || die("Cannot Open File");
my(@fcont) =3D <FILE>;
close FILE;
open(FOUT,">$fileName.txt") || die("Cannot Open File");
foreach my $line (@fcont) {
$line =3D~ s/\r/\r\n/g;
#### METHOD #1 BEGIN ####
my @lang =3D qw/ <Style:GB> <Style:DE> <Style:FR> <Style:ES>
<Style:DK> /;
my $capture_num =3D 0;
$line =3D~ s/&00([^\r]+)\r\n/$lang[$capture_num++]$1\n/g;
#### METHOD #1 END ####
print FOUT $line;
}
close FOUT;
exit 0
----------------------------
--
Rene
------------------------------
Date: Wed, 1 Apr 2009 07:32:22 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: search/replace
Message-Id: <slrngt6nmm.q4q.tadmc@tadmc30.sbcglobal.net>
molsted <molsted@gmail.com> wrote:
> I haven't seen Posting Guidelines, this my first post to the group,
> can i read them some where?
http://tinyurl.com/dg27de
> I'm going with your suggestion but it only matches the first line.
To analyse the behavior of a pattern match, we need two things:
1) the pattern that is to be matched
2) the string that the pattern is to be matched against
Since we only have access to one of them, we cannot analyse why it
fails to match.
> #!/usr/bin/perl
>
> use strict;
use warnings;
> my $fileName=$ARGV[0];
>
> open(FILE,"$fileName") || die("Cannot Open File");
You should not quote lone variables:
perldoc -q vars
What's wrong with always quoting "$vars"?
You should use the 3-argument form of open() and a lexical filehandle.
You should include the name of the file in the diag message.
You should put delimiters around the filename in your diag message.
You should include the $! variable in the diag messages.
open my $FILE, '<', $file_name or die "could not open '$file_name' $!";
> my(@fcont) = <FILE>;
my @fcont = <$FILE>;
(but see below)
> foreach my $line (@fcont) {
You should not read the entire file into memory if you only need
one line of the file at a time.
while ( my $line = <$FILE> ) {
> $line =~ s/\r/\r\n/g;
Why are you doing this?
Is the file a MAC-OS (not OS X) text file?
It is too late to fix line endings after you have used <> to read "lines".
You need to fix them *before* applying the <> operator.
Perhaps by setting the $/ variable to an appropriate value.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
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 2312
***************************************