[29825] in Perl-Users-Digest
Perl-Users Digest, Issue: 1068 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 27 09:09:50 2007
Date: Tue, 27 Nov 2007 06:09:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 27 Nov 2007 Volume: 11 Number: 1068
Today's topics:
Ambiguous method call <ch.l.ngre@online.de>
Re: Help needed regarding RPC::XML return value <darcykahle@gmail.com>
Re: How to append a file accordingly? xhoster@gmail.com
Re: How to append a file accordingly? <abigail@abigail.be>
Re: How to append a file accordingly? sheinrich@my-deja.com
Re: How to append a file accordingly? <stoupa@practisoft.cz>
Re: how to write non-compatible perl scripts to run on <peter@makholm.net>
how to write non-compatible perl scripts to run on diff <torben_surmer@msn.com>
Re: interesting case of data corruption, and its cause <bugbear@trim_papermule.co.uk_trim>
new CPAN modules on Tue Nov 27 2007 (Randal Schwartz)
Omitting data from a single line.. <privy@private.com>
Re: Omitting data from a single line.. xhoster@gmail.com
Re: Omitting data from a single line.. <ben@morrow.me.uk>
Re: Perl usage <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 27 Nov 2007 13:29:47 +0100
From: Ch Lamprecht <ch.l.ngre@online.de>
Subject: Ambiguous method call
Message-Id: <fih2jr$lp4$1@online.de>
Examining the example below, I find the following behavior:
The (ambiguous) expression
A::B->new( test => 1 )
is evaluated as
A::B()->new( test => 1 )
or as
'A::B'->new( test => 1 )
depending on whether A is loaded with
use A;
or with
require A;
(package A::B could as well be required/used separately from a different file
without changing the result)
Is that behavior expected?
Regards, Christoph
#!/usr/bin/perl
use strict;
use warnings;
use A;
#require A;
use Data::Dumper;
my $test = A::B->new(test => 1);
print Dumper $test;
__END__
file A.pm:
package A;
use strict;
use warnings;
sub B{
print "A::B called with args <@_>\n";
#return 'A::B' unless (@_);
shift;
return A::B->new(@_);
}
package A::B;
sub new{
print "A::B::new called with args: <@_>\n";
my $class = shift;
my $self = {@_};
bless $self, $class;
return $self;
}
1;
Output:
A::B called with args <>
A::B::new called with args: <A::B>
A::B::new called with args: <A::B=HASH(0x225314) test 1>
Attempt to bless into a reference at A.pm line 18.
Vs.:
A::B::new called with args: <A::B test 1>
$VAR1 = bless( {
'test' => 1
}, 'A::B' );
------------------------------
Date: Tue, 27 Nov 2007 06:02:59 -0800 (PST)
From: Darcy <darcykahle@gmail.com>
Subject: Re: Help needed regarding RPC::XML return value
Message-Id: <a3220551-31fb-47aa-9511-37f0626b9566@w40g2000hsb.googlegroups.com>
On Nov 26, 11:31 pm, Todd Wade <waveri...@gmail.com> wrote:
> On Nov 26, 7:19 pm, Darcy <darcyka...@gmail.com> wrote:
>
>
>
> > On Nov 26, 5:22 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> > > Quoth Darcy <darcyka...@gmail.com>:
>
> > > > I am trying to write an XML-RPC server method in perl using RPC::XML,
> > > > and I am having a rather perplexing problem when I attempt to return a
> > > > data structure to the caller (a Java app). I am told that the caller
> > > > is expecting an array of structs as the result.
> <snip/>
> > > > This is the error that the Java app is generating when it receives the
> > > > response:
>
> > > > ERROR 26 Nov 2007 16:56:50
> > > > (org.wh.client.frontend.listener.WHAbstractFrontEndActionListener) -
> > > > java.lang.ClassCastException: java.lang.Integer
>
> > > Just a completely random guess: have you tried using numbers instead of
> > > strings? That is,
>
> > > return [{
> > > SELL_LINE_NUMBER => 1, # note absence of quotes
> > > ERROR_CODE => 0,
> > > MESSAGE => 'test',
> > > CURRENT_TOTAL => 1,
> > > }];
>
> > The reason for quoting the numbers, is because, the specs for the
> > return list all four as "string". I did try as straight numbers, but
> > got the same error.
>
> What does the XML that client sending to the server look like? Thats
> what you need to be looking at. For example, you said the spec expects
> strings for each value. Chances are that "quoting" the numbers isn't
> going to suffice RPC::XML's purposes.
>
> You can coerce a value to a specific type by passing RPC::XML data
> objects instead of scalars:
>
> return [{
> SELL_LINE_NUMBER => RPC::XML::string->new(1),
> ERROR_CODE => RPC::XML::string->new(0),
> MESSAGE => 'test',
> CURRENT_TOTAL => RPC::XML::string->new(1),
> }];
>
> This will format the value as a <string> instead of an <int> in the
> XML.
>
> Regards,
>
> trwww
Thanks. That worked like a charm. I will remember from now on that I
need to force those that are to be strings in this manner, or else
rather cryptic errors could result.
Darcy
------------------------------
Date: 27 Nov 2007 05:27:53 GMT
From: xhoster@gmail.com
Subject: Re: How to append a file accordingly?
Message-Id: <20071127002757.492$as@newsreader.com>
Tad McClellan <tadmc@seesig.invalid> wrote:
> Abigail <abigail@abigail.be> wrote:
> > _
> > Tad McClellan (tadmc@seesig.invalid) wrote on VCC September MCMXCIII in
> ><URL:news:slrnfkkjrg.env.tadmc@tadmc30.sbcglobal.net>:
> >:) Petr Vileta <stoupa@practisoft.cz> wrote:
> >:)
> >:) > if($some_text =~ m/(\r\n|\n|\r)$/s)
> >:) ^
> >:) the m//s modifier is a no-op for that regex.
> >:)
> >:) You should not use modifiers that do not do any modification...
> >
> >
> > Hmmmpf.
> >
> >
> > Although I don't necessarely disagree with you, I don't think such
> > posts are useful. What might be useful is a reasoning why you think
> > you shouldn't do so.
>
> My folks often told me "look both ways before you cross the street"
> without explaining why I should.
>
> A modifier says "something out of the ordinary is going on here".
>
> Modifiers that don't modify are "crying wolf" to the maintenance
> programmer.
On the other hand, you could argue that /sm *is* ordinary, and their
removal is the mark of the unusual. If that is the standard to which the
maintenance programmer is accustomed, than their unwarranted absence would
be what is calling wolf, not their unwarranted presence. Sure, it would
have been nice if Perl had inverted their meanings in the first place, so
that the usual would be shorter than the unusual, but should we be
prisoners to a design flaw when we can just learn a new custom instead?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: 27 Nov 2007 07:39:28 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: How to append a file accordingly?
Message-Id: <slrnfknidg.pcu.abigail@alexandra.abigail.be>
_
Tad McClellan (tadmc@seesig.invalid) wrote on VCCI September MCMXCIII in
<URL:news:slrnfkmpd4.uml.tadmc@tadmc30.sbcglobal.net>:
:) Abigail <abigail@abigail.be> wrote:
:) > _
:) > Tad McClellan (tadmc@seesig.invalid) wrote on VCC September MCMXCIII in
:) ><URL:news:slrnfkkjrg.env.tadmc@tadmc30.sbcglobal.net>:
:) >:) Petr Vileta <stoupa@practisoft.cz> wrote:
:) >:)
:) >:) > if($some_text =~ m/(\r\n|\n|\r)$/s)
:) >:) ^
:) >:) the m//s modifier is a no-op for that regex.
:) >:)
:) >:) You should not use modifiers that do not do any modification...
:) >
:) >
:) > Hmmmpf.
:) >
:) >
:) > Although I don't necessarely disagree with you, I don't think such
:) > posts are useful. What might be useful is a reasoning why you think
:) > you shouldn't do so.
:)
:)
:) My folks often told me "look both ways before you cross the street"
:) without explaining why I should.
:)
:)
:) A modifier says "something out of the ordinary is going on here".
:)
:) Modifiers that don't modify are "crying wolf" to the maintenance programmer.
:)
:)
:) > Preferably also with reasons why people (Damian
:) > for instance, in PBP) do think you should.
:)
:)
:) I don't really remember why he said to use m//msx, but I think it was
:) "because they will be enabled by default in Perl 6", ie. to get
:) yourself ready for Perl 6.
No, that's not the reason. They are by default enabled in Perl6 because
the people developing Perl6 think it's a good idea to have them enabled
by default (and no way to easily turn them off). And for the same reasons
they are on in Perl6, Damian advocates to use them - and to make it easier
for the maintainance programmer, he advocates to turn them always on (that
way, when you see an unescaped '.', '^', '$', '#' or ' ' in a regexp, it
always means the same thing).
I don't buy your argument, and I don't by Damians either. Anyone who
considers /s or /m to be an alarm, or loses track when sometimes /s is
used, and sometimes isn't, shouldn't program Perl in the first place.
Abigail
--
perl -wle 'sub _ "Just another Perl Hacker"; print prototype q ^_^'
------------------------------
Date: Tue, 27 Nov 2007 03:14:45 -0800 (PST)
From: sheinrich@my-deja.com
Subject: Re: How to append a file accordingly?
Message-Id: <4ced8b9d-16fe-45b3-9fee-2d1049bd5c27@e10g2000prf.googlegroups.com>
On Nov 27, 8:39 am, Abigail <abig...@abigail.be> wrote:
...
>
> No, that's not the reason. They are by default enabled in Perl6 because
> the people developing Perl6 think it's a good idea to have them enabled
> by default (and no way to easily turn them off). And for the same reasons
> they are on in Perl6, Damian advocates to use them - and to make it easier
> for the maintainance programmer, he advocates to turn them always on (that
> way, when you see an unescaped '.', '^', '$', '#' or ' ' in a regexp, it
> always means the same thing).
>
> I don't buy your argument, and I don't by Damians either. Anyone who
> considers /s or /m to be an alarm, or loses track when sometimes /s is
> used, and sometimes isn't, shouldn't program Perl in the first place.
>
> Abigail
> --
While I share your point of view on the usage of modifiers, I'm afraid
that the outspoken 'perl-enabled' folk's snobbish attitude might be
cause for people feeling rebuffed and for the language's slowly ebbing
popularity.
TIMTOWTDI
Cheers,
Steffen
------------------------------
Date: Tue, 27 Nov 2007 07:09:46 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: How to append a file accordingly?
Message-Id: <fih6qr$16l$1@ns.felk.cvut.cz>
Ben Morrow wrote:
> Quoth Why Tea <ytlim1@gmail.com>:
>> On Nov 27, 3:41 am, "Petr Vileta" <sto...@practisoft.cz> wrote:
>>>
>>> open FH "< $myfile";
>
> Use three-arg open.
> Use lexical filehandles.
> Check the open succeeded.
>
>>> binmode FH; # not need for *nix systems
>
> Yes, it is *always* needed as of 5.8. You can also combine this step
> with the open:
>
Maybe you are right, I don't know. I'm old-fashioned, I still write scripts
for (and using) Perl 5.6.1 :-)
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>
------------------------------
Date: Tue, 27 Nov 2007 12:17:33 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: how to write non-compatible perl scripts to run on differnet operating systems?
Message-Id: <87wss3hogy.fsf@hacking.dk>
Torben <torben_surmer@msn.com> writes:
> is it possible to make some kind of pragmas in perl scripts, so for
> example I can run a perl script like this:
You can use $^O or $Conifg{osname} with Config.pm.
//Makholm
------------------------------
Date: Tue, 27 Nov 2007 04:10:45 -0800 (PST)
From: Torben <torben_surmer@msn.com>
Subject: how to write non-compatible perl scripts to run on differnet operating systems?
Message-Id: <9215a1f8-25eb-4f27-93f6-f44e6d240454@e4g2000hsg.googlegroups.com>
Hi to all,
is it possible to make some kind of pragmas in perl scripts, so for
example I can run a perl script like this:
__BEGIN__
#use Win32::Sound;
Win32::Sound::Play("SystemExclamation");
print "sound only plays on windows\n";
__END__
on Linux, which there of cause only shows the message?
Thanks
torben.
------------------------------
Date: Tue, 27 Nov 2007 12:37:53 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: interesting case of data corruption, and its cause
Message-Id: <13ko3t29ll43l43@corp.supernews.com>
Ben Morrow wrote:
> Attempting to fix the problem by localising $_ is tricky, as well,
> because C<local $_> doesn't always work due to some very boring bugs in
> some versions of perl when $_ is an element of a tied array. The
> workaround (local *_) doesn't buy you much, because you lose your sub
> arguments. About the only time I use while (<>) is at the very top level
> with -n, when it can't do any harm.
Thanks to all for the discussion.
Do I take it "best practice" is (simply) not to
assign to $_, either explicitly (rare) or
implicitly (while(<>) or while(<H>)) ?
BugBear
------------------------------
Date: Tue, 27 Nov 2007 05:42:14 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Nov 27 2007
Message-Id: <Js5H6E.GJw@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.
AI-MegaHAL-0.06
http://search.cpan.org/~chorny/AI-MegaHAL-0.06/
Perl interface to the MegaHAL natural language conversation simulator.
----
Acme-MetaSyntactic-buzzwords-1.00
http://search.cpan.org/~jquelin/Acme-MetaSyntactic-buzzwords-1.00/
Pointy-haired boss lingo
----
Acme-Tie-Eleet-1.0.2
http://search.cpan.org/~jquelin/Acme-Tie-Eleet-1.0.2/
Perl extension to 5pE4k 1Ik3 4n 3l337!
----
Algorithm-EquivalenceSets-0.01
http://search.cpan.org/~marcel/Algorithm-EquivalenceSets-0.01/
FIXME
----
Apache-Session-1.84_01
http://search.cpan.org/~chorny/Apache-Session-1.84_01/
A persistence framework for session data
----
Apache-Test-1.30
http://search.cpan.org/~phred/Apache-Test-1.30/
Test.pm wrapper with helpers for testing Apache
----
Audio-MPD-0.18.3
http://search.cpan.org/~jquelin/Audio-MPD-0.18.3/
class to talk to MPD (Music Player Daemon) servers
----
Audio-MPD-Common-0.1.2
http://search.cpan.org/~jquelin/Audio-MPD-Common-0.1.2/
a bunch of common helper classes for mpd
----
CORBA-XMLSchemas-2.61
http://search.cpan.org/~perrad/CORBA-XMLSchemas-2.61/
----
CPANPLUS-Dist-Mdv-0.3.3
http://search.cpan.org/~jquelin/CPANPLUS-Dist-Mdv-0.3.3/
a cpanplus backend to build mandriva rpms
----
Catalyst-Controller-SOAP-0.1.1
http://search.cpan.org/~druoso/Catalyst-Controller-SOAP-0.1.1/
Catalyst SOAP Controller
----
Catalyst-Model-JDBI-Schemas-0.02
http://search.cpan.org/~ishigaki/Catalyst-Model-JDBI-Schemas-0.02/
Jifty::DBI Model Class with some magic on top
----
Chart-Clicker-1.4.1
http://search.cpan.org/~gphat/Chart-Clicker-1.4.1/
Powerful, extensible charting.
----
Class-MOP-0.48
http://search.cpan.org/~stevan/Class-MOP-0.48/
A Meta Object Protocol for Perl 5
----
Crypt-Elijah-0.10
http://search.cpan.org/~bomb/Crypt-Elijah-0.10/
cipher module
----
Devel-Declare-0.001006
http://search.cpan.org/~mstrout/Devel-Declare-0.001006/
----
Dunce-0.04
http://search.cpan.org/~mschwern/Dunce-0.04/
----
ExtUtils-MakeMaker-6.37_02
http://search.cpan.org/~mschwern/ExtUtils-MakeMaker-6.37_02/
Create a module Makefile
----
ExtUtils-MakeMaker-6.37_03
http://search.cpan.org/~mschwern/ExtUtils-MakeMaker-6.37_03/
Create a module Makefile
----
File-NCopy-0.36
http://search.cpan.org/~chorny/File-NCopy-0.36/
Deprecated module. Use File::Copy::Recursive instead. Copy file, file. Copy file[s] | dir[s], dir
----
Finance-Card-Citibank-1.63
http://search.cpan.org/~mgrimes/Finance-Card-Citibank-1.63/
Check your Citigroup credit card accounts from Perl
----
Finance-Currency-Convert-BChile-0.03
http://search.cpan.org/~huguei/Finance-Currency-Convert-BChile-0.03/
Currency conversion module between Chilean Pesos (CLP) and USA Dollars (USD).
----
Function-Override-0.03
http://search.cpan.org/~mschwern/Function-Override-0.03/
Add callbacks to existing functions.
----
Fuse-PDF-0.06
http://search.cpan.org/~cdolan/Fuse-PDF-0.06/
Filesystem embedded in a PDF document
----
Geo-ICAO-0.35
http://search.cpan.org/~jquelin/Geo-ICAO-0.35/
Airport and ICAO codes lookup
----
Gungho-0.09005_01
http://search.cpan.org/~dmaki/Gungho-0.09005_01/
???Web????????????
----
HTML-BBCode-2.01
http://search.cpan.org/~blom/HTML-BBCode-2.01/
Perl extension for converting BBcode to HTML.
----
HTML-Template-Compiled-Filter-Whitespace-0.02
http://search.cpan.org/~steffenw/HTML-Template-Compiled-Filter-Whitespace-0.02/
whitespace filter for HTML output
----
HTML-TurboForm-0.05
http://search.cpan.org/~camelcase/HTML-TurboForm-0.05/
----
HTML-WikiConverter-DokuWiki-0.53
http://search.cpan.org/~diberri/HTML-WikiConverter-DokuWiki-0.53/
Convert HTML to DokuWiki markup
----
IO-CaptureOutput-1.06
http://search.cpan.org/~dagolden/IO-CaptureOutput-1.06/
capture STDOUT and STDERR from Perl code, subprocesses or XS
----
Inline-Befunge-1.1.1
http://search.cpan.org/~jquelin/Inline-Befunge-1.1.1/
write Perl subs in Befunge
----
Language-Befunge-3.02
http://search.cpan.org/~jquelin/Language-Befunge-3.02/
a Befunge-98 interpreter
----
Language-Befunge-Debugger-0.3.4
http://search.cpan.org/~jquelin/Language-Befunge-Debugger-0.3.4/
a graphical debugger for Language::Befunge
----
Language-Ook-1.0.2
http://search.cpan.org/~jquelin/Language-Ook-1.0.2/
a Ook! interpreter.
----
Lingua-ZH-CCDICT-0.04
http://search.cpan.org/~drolsky/Lingua-ZH-CCDICT-0.04/
An interface to the CCDICT Chinese dictionary
----
Log-Dynamic-0.02
http://search.cpan.org/~jconerly/Log-Dynamic-0.02/
(__VERSION__) - OOish dynamic and customizable logging
----
Logfile-EPrints-1.19
http://search.cpan.org/~timbrody/Logfile-EPrints-1.19/
Process Web log files for institutional repositories
----
Mail-Builder-1.04
http://search.cpan.org/~maros/Mail-Builder-1.04/
Easily create e-mails with attachments, html and inline images
----
Moose-0.31
http://search.cpan.org/~stevan/Moose-0.31/
A complete modern object system for Perl 5
----
Net-IPTrie-v0.3
http://search.cpan.org/~cvicente/Net-IPTrie-v0.3/
Perl module for building IPv4 and IPv6 address space hierarchies fast
----
POE-Component-Client-MPD-0.8.1
http://search.cpan.org/~jquelin/POE-Component-Client-MPD-0.8.1/
a full-blown mpd client library
----
Roman-1.21
http://search.cpan.org/~chorny/Roman-1.21/
Perl module for conversion between Roman and Arabic numerals.
----
Sepia-0.95
http://search.cpan.org/~seano/Sepia-0.95/
Simple Emacs-Perl Interface
----
Test-Aggregate-0.02
http://search.cpan.org/~ovid/Test-Aggregate-0.02/
Aggregate *.t tests to make them run faster.
----
Test-Virtual-Filesystem-0.08
http://search.cpan.org/~cdolan/Test-Virtual-Filesystem-0.08/
Validate a filesystem
----
Text-CSV_PP-Simple-0.0.5
http://search.cpan.org/~cohtan/Text-CSV_PP-Simple-0.0.5/
Simpler parsing of CSV files [PP version]
----
Tie-VecArray-0.03
http://search.cpan.org/~mschwern/Tie-VecArray-0.03/
An array interface to a bit vector.
----
Time-Fuzzy-0.36
http://search.cpan.org/~jquelin/Time-Fuzzy-0.36/
Time read like a human, with some fuzziness
----
Tk-GraphItems-0.08
http://search.cpan.org/~lamprecht/Tk-GraphItems-0.08/
Display relation-graphs on a Tk::Canvas
----
Tk-RotatingGauge-0.25
http://search.cpan.org/~jquelin/Tk-RotatingGauge-0.25/
a rotating gauge for Tk
----
URI-crid-0.01
http://search.cpan.org/~alic/URI-crid-0.01/
URI scheme as defined in RFC 4078
----
WWW-Domain-Registry-Joker-0.05
http://search.cpan.org/~roam/WWW-Domain-Registry-Joker-0.05/
an interface to the Joker.com DMAPI
----
dmake-4.11-SHAY
http://search.cpan.org/~shay/dmake-4.11-SHAY/
----
dmake-4.9-SHAY
http://search.cpan.org/~shay/dmake-4.9-SHAY/
----
re-engine-Oniguruma-0.03
http://search.cpan.org/~andya/re-engine-Oniguruma-0.03/
Use the Oniguruma regex engine with Perl
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: Mon, 26 Nov 2007 23:36:13 -0600
From: Cranky <privy@private.com>
Subject: Omitting data from a single line..
Message-Id: <f5bnk3dgfp396o3nahbb6785irg6d29t3u@4ax.com>
I have files that are 1 liners that have data that I would like to
sed, grep, or awk out. Here is an example:
<title>Book of Love</title><UPC>0574638694274</UPC><description>Love
has no fury and therefore this is no different than any other
insipidity that we come across. Read this and
weep.</description><sell>12.95</sell><author>Jane
Russo</author><title>Chastising
Daisy</title><UPC>095736485284</UPC><description>Not the usual driving
miss daisy that we are used to. This will set the mood for
demeanor.</description><sell>8.95</sell><author>Jack Palance</author>
Basically I would like to omit everything between the <description>
and </description> tags. As far as the "description" tags themselves,
it really doesn't matter whether those go or not so long as everything
in between them does.
Thanks,
Cranky
------------------------------
Date: 27 Nov 2007 05:49:50 GMT
From: xhoster@gmail.com
Subject: Re: Omitting data from a single line..
Message-Id: <20071127004954.265$gZ@newsreader.com>
Cranky <privy@private.com> wrote:
> I have files that are 1 liners that have data that I would like to
> sed, grep, or awk out. Here is an example:
Are you aware that this is Perl newsgroup, not an sed, awk, or grep one?
...
> Basically I would like to omit everything between the <description>
> and </description> tags. As far as the "description" tags themselves,
> it really doesn't matter whether those go or not so long as everything
> in between them does.
In Perl:
$line =~ s/<description>.*?<\/description>//g;
There are various gotcha that occur with this. In general it is a good
idea to use an XML processor to process XML, but I do do things like this
occasionally and generally get away with it.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Tue, 27 Nov 2007 13:15:57 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Omitting data from a single line..
Message-Id: <dtht15-e41.ln1@osiris.mauzo.dyndns.org>
Quoth Cranky <privy@private.com>:
> I have files that are 1 liners that have data that I would like to
> sed, grep, or awk out.
Then why are you asking in a Perl group? :)
> Here is an example:
>
> <title>Book of Love</title><UPC>0574638694274</UPC><description>Love
> has no fury and therefore this is no different than any other
> insipidity that we come across. Read this and
> weep.</description><sell>12.95</sell><author>Jane
> Russo</author><title>Chastising
> Daisy</title><UPC>095736485284</UPC><description>Not the usual driving
> miss daisy that we are used to. This will set the mood for
> demeanor.</description><sell>8.95</sell><author>Jack Palance</author>
>
> Basically I would like to omit everything between the <description>
> and </description> tags. As far as the "description" tags themselves,
> it really doesn't matter whether those go or not so long as everything
> in between them does.
You need to be clearer about what can appear between the tags. If this
is a fragment of real XML, then the right answer is to temporarily add a
fake outermost <books> element and parse it with a real XML parser, then
extract the bits you want (using SAX or DOM/XPath as takes your fancy)
and remove the outer tags again. If it isn't, you will need to answer
questions like 'can a description ever contain a '<'?' and 'how is it
encoded if it does?'.
Ben
------------------------------
Date: Tue, 27 Nov 2007 13:18:29 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl usage
Message-Id: <141ok35n7lgq6rqceb53rvvkbc2ihqvfmf@4ax.com>
On Mon, 26 Nov 2007 13:47:54 -0800 (PST), Kevin <kbadinger@gmail.com>
wrote:
>I was wondering if someone on this group could help out here. I know
>there are alot of positions posted on this, but was hoping someone had
>some solid info to point to.
>
>I have used Perl for projects here and there. However my manager
>keeps telling me that Perl should not be used for real projects. It
>seems like a pretty solid language to me. Are there certain types of
>applications that Perl should not be used for? I am trying to put
>together feedback from experts as to why perl is just as valid as many
>other languages. Can someone help?
This is often discussed. In addition to the good pointers you've
already been given, a recent discussion in a Perl community about what
people actually use Perl for is reachable at:
http://perlmonks.org/?node_id=652612
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 1068
***************************************