[25919] in Perl-Users-Digest
Perl-Users Digest, Issue: 8142 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 2 06:05:23 2005
Date: Thu, 2 Jun 2005 03:05:05 -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, 2 Jun 2005 Volume: 10 Number: 8142
Today's topics:
Re: confused constructing a regex (Anno Siegel)
Re: confused constructing a regex <uk.ac.ox.physics.teaching@leeg.invalid>
Re: confused constructing a regex (Anno Siegel)
Re: Neat way of setting default values <xennar@yahoo.com>
Re: Neat way of setting default values <1usa@llenroc.ude.invalid>
Re: Neat way of setting default values <noreply@gunnar.cc>
Re: Neat way of setting default values <nobull@mail.com>
Re: Perl: Win-32 vs. linux <john@castleamber.com>
Re: Perl: Win-32 vs. linux <daveandniki@ntlworld.com>
Re: Suppression of error messages if a regex does not m <flavell@ph.gla.ac.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 2 Jun 2005 07:09:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: confused constructing a regex
Message-Id: <d7mbb6$r91$1@mamenchi.zrz.TU-Berlin.DE>
leeg <uk.ac.ox.physics.teaching@leeg.invalid> wrote in comp.lang.perl.misc:
> Tad McClellan wrote:
> > leeg <uk.ac.ox.physics.teaching@leeg.invalid> wrote:
> >>Tad McClellan wrote:
> >>>leeg <uk.ac.ox.physics.teaching@leeg.invalid> wrote:
> >>>>I have an input file of a format that looks something like this:
> >
> > What generates the data?
> >
> Apple/NeXT's EOModeller application. It's an old variant of the plist
> format (before XML came along).
Then look at the module Mac::PropertyList. It may be the solution,
but even if it isn't you may be able to steal some useful stuff from
it.
[...]
Anno
------------------------------
Date: Thu, 02 Jun 2005 09:18:45 +0100
From: leeg <uk.ac.ox.physics.teaching@leeg.invalid>
Subject: Re: confused constructing a regex
Message-Id: <d7mfd5$ogl$1@news.ox.ac.uk>
Anno Siegel wrote:
> leeg <uk.ac.ox.physics.teaching@leeg.invalid> wrote in comp.lang.perl.misc:
>
>>Tad McClellan wrote:
>>
>>>leeg <uk.ac.ox.physics.teaching@leeg.invalid> wrote:
>>>
>>>>Tad McClellan wrote:
>>>>
>>>>>leeg <uk.ac.ox.physics.teaching@leeg.invalid> wrote:
>
>
>>>>>>I have an input file of a format that looks something like this:
>>>
>>>What generates the data?
>>>
>>
>>Apple/NeXT's EOModeller application. It's an old variant of the plist
>>format (before XML came along).
>
>
> Then look at the module Mac::PropertyList. It may be the solution,
> but even if it isn't you may be able to steal some useful stuff from
> it.
>
It isn't, as it only deals with the XML format. I am in e-mail contact
with its author regarding my plists though ;-)
Cheers.
------------------------------
Date: 2 Jun 2005 09:20:47 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: confused constructing a regex
Message-Id: <d7mj1f$340$1@mamenchi.zrz.TU-Berlin.DE>
leeg <uk.ac.ox.physics.teaching@leeg.invalid> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> >>Apple/NeXT's EOModeller application. It's an old variant of the plist
> >>format (before XML came along).
> >
> >
> > Then look at the module Mac::PropertyList. It may be the solution,
> > but even if it isn't you may be able to steal some useful stuff from
> > it.
> >
>
> It isn't, as it only deals with the XML format. I am in e-mail contact
> with its author regarding my plists though ;-)
Okay...
Each time I come across this thread I'm more convinced that the right
way to go about this is to write a real parser. The process of tweaking
things while you discover more variants of the format will be *much*
easier when you have a Parse::RecDescent (say) grammar to tweak instead
of one or more monster-regexes.
You *will* have to spend an afternoon or so acquainting yourself with
Parse::RecDescent, but it will pay. Write one or two very simple
grammars of your own before trying to tackle full property lists.
Something like parsing numeric expressions made out of + - * / ( ) and
integers is a good start.
Anno
------------------------------
Date: Thu, 02 Jun 2005 07:44:15 +0200
From: Xenna <xennar@yahoo.com>
Subject: Re: Neat way of setting default values
Message-Id: <429e9c73$0$51513$e4fe514c@dreader17.news.xs4all.nl>
Gunnar Hjalmarsson wrote:
> Xenna wrote:
>
>> Gunnar Hjalmarsson wrote:
>>
>>> Berk Birand wrote:
>>>
>>>> Gunnar Hjalmarsson wrote:
>>>>
>>>>> Berk Birand wrote:
>>>>>
>>>>>>
>>>>>> my $tag = (get_mp3tag($file) or "No tag\n");
>>>>>
>>>>>
>>>>> Why isn't that smart enough?
>>>>
>>>>
>>>> It is not smart enough because it doesn't work.
>>>
>>>
>>> It works fine. So does:
>>>
>>> my $tag = get_mp3tag($file) || "No tag\n";
>>
>>
>> Sometimes those of us who are great at communicating with computers
>> are not so great at communicating with people.
>>
>> Instead of kindly telling you what they know you want to hear they
>> revel in explaining you how you stupidly misphrased your questions.
>
> Even if that may be true once in a while, I don't understand how it
> would be applicable in this case. How did you figure out what the OP
> "wants" to know? I still don't know what it is...
Well, Mark & Brian figured it out *and* were able to explain the
underlying issue clearly.
X.
------------------------------
Date: Thu, 02 Jun 2005 05:51:23 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Neat way of setting default values
Message-Id: <Xns966912AB08B8Fasu1cornelledu@127.0.0.1>
Xenna <xennar@yahoo.com> wrote in news:429e9c73$0$51513
$e4fe514c@dreader17.news.xs4all.nl:
> Gunnar Hjalmarsson wrote:
>> Xenna wrote:
>>
>>> Gunnar Hjalmarsson wrote:
>>>
>>>> Berk Birand wrote:
>>>>
>>>>> Gunnar Hjalmarsson wrote:
>>>>>
>>>>>> Berk Birand wrote:
>>>>>>
>>>>>>>
>>>>>>> my $tag = (get_mp3tag($file) or "No tag\n");
>>>>>>
>>>>>>
>>>>>> Why isn't that smart enough?
>>
>> How did you figure out what the OP
>> "wants" to know? I still don't know what it is...
>
> Well, Mark & Brian figured it out *and* were able to explain the
> underlying issue clearly.
So what? What does it mean to ask "Why isn't that smart enough?" The OP
did not do not put any effort into asking an intelligble question.
*You* did not put any effort into answering the OP's question, but
instead decided to pick on Gunnar for his legitimate question. In fact,
you did not even answer Gunnar's question: How did you figure out what
the OP wants to know?
I hadn't noticed any posts by you up to this point, and I won't be
seeing them in the future either.
*PLONK*
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Thu, 02 Jun 2005 09:28:17 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Neat way of setting default values
Message-Id: <3g7ru3Fahu02U1@individual.net>
Xenna wrote:
> Well, Mark & Brian figured it out *and* were able to explain the
> underlying issue clearly.
The underlying issue??
I don't know from where you get your info, but it can't be from the
postings in this thread.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 02 Jun 2005 09:14:01 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Neat way of setting default values
Message-Id: <d7mf4e$8oe$1@slavica.ukpost.com>
Xenna wrote:
> Gunnar Hjalmarsson wrote:
>
>> Xenna wrote:
>>
>>> Gunnar Hjalmarsson wrote:
>>>
>>>> Berk Birand wrote:
>>>>
>>>>> Gunnar Hjalmarsson wrote:
>>>>>
>>>>>> Berk Birand wrote:
>>>>>>
>>>>>>>
>>>>>>> my $tag = (get_mp3tag($file) or "No tag\n");
>>>>>>
>>>>>> Why isn't that smart enough?
>>>>>
>>>>> It is not smart enough because it doesn't work.
>>>>
>>>> It works fine. So does:
>>>>
>>>> my $tag = get_mp3tag($file) || "No tag\n";
>>>
>>> Instead of kindly telling you what they know you want to hear they
>>> revel in explaining you how you stupidly misphrased your questions.
>>
>> Even if that may be true once in a while, I don't understand how it
>> would be applicable in this case. How did you figure out what the OP
>> "wants" to know? I still don't know what it is...
>
> Well, Mark & Brian figured it out *and* were able to explain the
> underlying issue clearly.
Er, no. There was nothing wrong with the original code that Berk posted.
Mark posted alternative version of the code that would work no better or
worse.
I (Brian) pointed out that Berk's original code was as far as perl is
concerned exactly the same as Mark's. This is just what Gunnar did.
Nobody here (unless they've had private correspondance with Berk) can
know what the original problem was.
------------------------------
Date: 2 Jun 2005 04:19:03 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Perl: Win-32 vs. linux
Message-Id: <Xns9668ED1A43186castleamber@130.133.1.4>
Maqo wrote:
> Is there any reason the following would work on a linux installation
> of Perl, but not using ActivePerl-5.8 on a Win-32 system? The tr///
> operation successfully removes UTF-8 encoded characters from
> the string in linux, but not Win-32, even after verifying that all
> required modules are installed. Any thoughts would be greatly
> appreciated!
>
> -----------------------------------------------------------------------
>
> use LWP::Simple;
> use Encode;
>
> my $URL =
> "http://www.pimco.com/LeftNav/Late+Breaking+Commentary/IO/2004/IO_07_04
> .htm";
>
> $content = get($URL);
> $decoded = decode("utf-8"=>$content);
> $decoded =~ tr/\x{00a0}/ /;
>
> print $decoded;
By best guess: decode maps to the internal encoding used by Perl, and I
guess on Windows this is Win-something, and on Linux ISO-something.
Why not remove the utf-8 encoded non-breakable spaces before the decoding
step?
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Thu, 02 Jun 2005 08:19:19 GMT
From: "Dave" <daveandniki@ntlworld.com>
Subject: Re: Perl: Win-32 vs. linux
Message-Id: <bizne.4418$cN2.2362@newsfe4-gui.ntli.net>
"John Bokma" <john@castleamber.com> wrote in message
news:Xns9668ED1A43186castleamber@130.133.1.4...
> Maqo wrote:
>
>> Is there any reason the following would work on a linux installation
>> of Perl, but not using ActivePerl-5.8 on a Win-32 system? The tr///
>> operation successfully removes UTF-8 encoded characters from
>> the string in linux, but not Win-32, even after verifying that all
>> required modules are installed. Any thoughts would be greatly
>> appreciated!
>>
>> -----------------------------------------------------------------------
>>
>> use LWP::Simple;
>> use Encode;
>>
>> my $URL =
>> "http://www.pimco.com/LeftNav/Late+Breaking+Commentary/IO/2004/IO_07_04
>> .htm";
>>
>> $content = get($URL);
>> $decoded = decode("utf-8"=>$content);
>> $decoded =~ tr/\x{00a0}/ /;
>>
>> print $decoded;
>
> By best guess: decode maps to the internal encoding used by Perl, and I
> guess on Windows this is Win-something, and on Linux ISO-something.
>
> Why not remove the utf-8 encoded non-breakable spaces before the decoding
> step?
>
> --
> John Small Perl scripts: http://johnbokma.com/perl/
> Perl programmer available: http://castleamber.com/
> Happy Customers: http://castleamber.com/testimonials.html
>
two thoughts and a question:
1) does adding:
use utf8;
make any difference?
2) Print $decoded to a file before the tr// step to see if it has a string
or U+00a0 or just a mess. This will help in finding where in the code
the problem is.
Question.
Where in the script is the string in the original html being parsed
into a U+00a0 ? Does get() do this automatically? I can't see anything in
the documentation that mentions this, but I can't see why it would happen on
a Linux system and not on Windows.
Dave
------------------------------
Date: Thu, 2 Jun 2005 10:53:46 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Suppression of error messages if a regex does not match
Message-Id: <Pine.LNX.4.62.0506021041070.20513@ppepc56.ph.gla.ac.uk>
On Wed, 1 Jun 2005, brian d foy wrote:
> Alan J. Flavell <flavell@ph.gla.ac.uk> wrote:
>
> > Anyone who advises turning warnings off to hide the warning may be
> > technically accurate about what Perl does or can do - but
> > operationally it's a disaster.
>
> Well, I don't think it's always an operational disaster. I think
> warnings are something we can use to understand what the code is
> doing.
Accepted...
> When we know what it is doing and accept that in some cases
> we know better than perl, turning off warnings is not a disaster.
Accepted - but first we *do* need to "know what it is doing", and be
sure that we really *do* know better than perl. I was intending to
talk about this development phase, but omitted to make that clear,
sorry.
> I generally advise people to turn off warnings in production scripts.
Fair enough, but only after the development is complete; and be ready
to turn them back on again before thinking of posting a problem here
and asking for help.
> Turn on warnings in development and debugging,
Right.
> but don't fill your disk with warning messages just because someone
> upgraded perl (and the new perl has a different idea about
> warnings). I've had clients run out of disk space from that (back in
> the days before Gb was a common measurement) situation, and those
> were minor disasters.
OK. On the other hand I've had one case (maybe others have had their
own examples) where an upgraded perl started issuing warnings which
revealed a program logic error in my code. The error had always been
there, but previously un-noticed, and was easy to fix.
In a context where we're talking about CGI scripts, I'd also do
development with warnings sent to the browser (CGI::Carp), but I'd
turn that off in production, since it can reveal internal details
about a script to a hostile attacker.
------------------------------
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 8142
***************************************