[30889] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2134 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 16 14:09:50 2009

Date: Fri, 16 Jan 2009 11:09:14 -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           Fri, 16 Jan 2009     Volume: 11 Number: 2134

Today's topics:
    Re: Circular lists <xhoster@gmail.com>
    Re: Circular lists <xhoster@gmail.com>
    Re: Circular lists <burner+usenet@imf.au.dk>
    Re: Circular lists <syscjm@sumire.gwu.edu>
    Re: Cygwin or Windows: file permission functions are br (Tim McDaniel)
    Re: fastest way to allocate memory ? xhoster@gmail.com
    Re: Integration Watch: The end for Perl? (SD Times) <cwilbur@chromatico.net>
    Re: opening a file <cartercc@gmail.com>
    Re: opening a file <jurgenex@hotmail.com>
    Re: opening a file <cartercc@gmail.com>
    Re: opening a file <tim@burlyhost.com>
    Re: opening a file <glex_no-spam@qwest-spam-no.invalid>
    Re: opening a file <tim@burlyhost.com>
    Re: opening a file <jurgenex@hotmail.com>
    Re: processing text <tim@burlyhost.com>
    Re: processing text <brian.helterline@hp.com>
        String replacement involving special characters. <mrlawrencelam@gmail.com>
    Re: What do you need to have to be considered a Master  (Randal L. Schwartz)
    Re: XML::Parser help (hymie!)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 15 Jan 2009 22:37:58 -0800
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: Circular lists
Message-Id: <4970b50a$0$25488$ed362ca5@nr5c.newsreader.com>

Jürgen Exner wrote:

>>> But there are proven and established ways to generate all permutations
>>> of a given (multi)-set of items. Why don't those work?
>> Are any of them on CPAN?  I couldn't find any so made a couple of my own.
> 
> Maybe
> http://search.cpan.org/~edpratomo/Algorithm-Permute-0.12/Permute.pm
> 
> It mentions some other permute implementations in a benchmark, too.

That (and the others I've seen ) handles sets of course, but not 
multi-sets. Well, it handles them, just not well.  For example,
the multiset of 10 'a's and 10 'b's has 184756 distinct permutations, 
but Algorithm Permute will return each one of them 1.32E+013 times.

So something efficient for multi-sets, like dpermute or 
Distinct::Permute posted earlier, is essential.


> 
> However -as others have discussed already- I doubt that it will be very
> useful for larger lists (more than 10 to 15 elements) , because the OP
> will run out of space and time if he tries to generate all permutations
> first and then filter second. 
> The filter for rotational equivalence has to be incorporated into the
> generating algorithm.

It's far more important to filter for degenerate linear permutations in 
the generating algorithm.  Once you pin a rare element in the first 
position, trying to implement more of the rotational equivalence 
short-circuiting during the linear permutation generation doesn't get 
you a whole lot of extra benefit for the effort it would  take. Probably 
better to take the simpler algorithm into C than make the Perl algorithm 
insanely complex.

Xho


------------------------------

Date: Thu, 15 Jan 2009 21:58:44 -0800
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: Circular lists
Message-Id: <4970b509$0$25488$ed362ca5@nr5c.newsreader.com>

gamo wrote:

> The thing could change radically if there is a method to canonicalize all
> the rotations of a list in a compact string. Did you say that is possible?

Of course.  From a previous post:

     my $s = join '',@set;
     my $two = $s . $s;
     next if ($two =~ /gg/);
     my ($canon) = sort map {substr $two,$_,length $s} 0..length($s) -1;

That last line canonicalizes by the simple method of computing all 
rotations and taking the alphabetically least of them (you could use 
List::Util::minstr instead of sort).  You could use other 
canonicalization rules if they made other optimizations possible.  For 
example, it might be a good idea to define the canonical representation 
as the one the alphabetically first *among those that start with the 
rarest element*.  In your example, "a" was both the rarest and the 
alphabetically first, but that wouldn't hold in general.  By doing this, 
you get the double advantage of fixing the first position and so not 
needing to permute it, plus you don't have to compute all rotations but 
only the few ones that would put another instance of the rarest element 
first.

> I don't think so. If we have numbers instead of letters, I can't think in 
> a method that could describe the list of circular numbers 

If the numbers are single digits, then it works just the same as with 
letters.  If they can be integers of any number of digits, you just need 
a non-digit delimiter to join on to make a canonical representation:

     my @two=(@s,@s);
     my ($canon) = sort map {join ";", @two[$_..$_+$#s]} 0..$#s;


 > in less space that it has.

An array packed into a string generally takes less space, in Perl, then 
the array itself.  Plus you are using one such string to represent not 
just one array, but all rotations of it.  Plus, you might find you don't
actually need to store the canonical representation in memory long-term, 
just use it to test something else on the fly.

Xho


------------------------------

Date: Fri, 16 Jan 2009 18:35:15 +0100
From: Rasmus Villemoes <burner+usenet@imf.au.dk>
Subject: Re: Circular lists
Message-Id: <u0lk58vdui4.fsf@orc02.imf.au.dk>

sln@netherlands.com writes:

> how many people in a room does it take to statistically almost
> guarantee 2 people will have the same birth date (day-month) out of
> 365 days/year?
>
> Answer: 26

That's the number of people making the probability of at least two
people sharing a birthday > 0.59. That is certainly not the same as
"statistically almost guarantee", whatever that means. 23 people make
the probability > 0.5.

> So funny!

No, just math (not that math can't be funny, but this is just too
trivial). And 26 just happens to be the smallest integer making the
quantity (365/365)*(364/365)* ... * ( (365-n+1)/365) smaller than
0.41, which is the probability that no pair out of n people share a
birthday (ignoring subtleties such as leap years and facts about
birthdays not actually being distributed uniformly over all 365 days).

But this is way OT. Since this is a perl newsgroup, here's a bit of
perl code:

my $n;
my $p = 1;
for $n (1..30) {
    $p *= (366-$n)/365;
    printf "%3s: %.5f , %.5f\n", $n, $p, 1-$p;
}


-- 
Rasmus Villemoes
<http://rasmusvillemoes.dk/>


------------------------------

Date: Fri, 16 Jan 2009 12:32:04 -0600
From: Chris Mattern <syscjm@sumire.gwu.edu>
Subject: Re: Circular lists
Message-Id: <slrngn1kl2.qu2.syscjm@sumire.gwu.edu>

On 2009-01-16, Rasmus Villemoes <burner+usenet@imf.au.dk> wrote:
> sln@netherlands.com writes:
>
>> how many people in a room does it take to statistically almost
>> guarantee 2 people will have the same birth date (day-month) out of
>> 365 days/year?
>>
>> Answer: 26
>
> That's the number of people making the probability of at least two
> people sharing a birthday > 0.59. That is certainly not the same as
> "statistically almost guarantee", whatever that means. 23 people make
> the probability > 0.5.
>
Most statiticians set a lower bound of 0.95 for general "reasonably
certain" purposes.  Anything lower than that is usually accounted as
insufficiently reliable for almost any purposes where you don't want to
gamble on being wrong.  Many purposes require greater certainty, of course.
To get probablility > 0.95, you need 47 people.  For p > 0.99, you need
57.  p > 0.999, 70.

-- 
             Christopher Mattern

NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities


------------------------------

Date: Fri, 16 Jan 2009 16:01:22 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Cygwin or Windows: file permission functions are broken
Message-Id: <gkqb0i$18j$1@reader1.panix.com>

In article <gkpa8m$32j$1@nntp.motzarella.org>,
Thrill5 <nospam@somewhere.com> wrote:
>I'm running ActiveState 5.8.8 and my Perl doesn't act like your version.
>C:\Documents and Settings\Administrator>perl -e "print (-w '.' ? 'yes' : 
>'no')"
>yes

&c.

Thanks for the datum.  I'll consider installing ActiveState, though I
don't like the idea of two Perls.

>I have also never seen any paths "transmogrified" by Perl.

It's Cygwin's perl port doing it: when it starts the program, it
converts TMP, TEMP, TMPDIR, PATH, and probably certain other
environment variables to Cygwin path syntax (UNIXy).  It's not every
variable: I set FROG to 'C:\home' and it remains unchanged.

>Not sure what your issue with File::Temp is,

Not so much of one.  My main beef is with -r / -w being inaccurate.

tmpdir in File::Temp (specifically, the Cygwin.pm subclass) finds the
first writable directory (as determined by -w) in

    $ENV{TMPDIR}
    /tmp
    C:/temp

As mentioned, Cygwin mutates TMPDIR into its own filename syntax.  For
example, on my system it changed c:\tmp\1 into /tmp/1.  That all works
fine, except

- when -w gives an incorrect answer, you get a different tmpdir.  In
  particular, I had write permission to /tmp/1, yet "-w '/tmp/1'"
  returned false, so it went on to /tmp.

- when you have to run programs that require Windows paths, you need
  to run the filename through "cygpath -w" to get the Windows syntax
  again, and for increasingly silly-looking reasons I'm reluctant to
  do that.

-- 
Tim McDaniel, tmcd@panix.com


------------------------------

Date: 16 Jan 2009 18:26:15 GMT
From: xhoster@gmail.com
Subject: Re: fastest way to allocate memory ?
Message-Id: <20090116132855.776$UI@newsreader.com>

"georg.heiss@gmx.de" <georg.heiss@gmx.de> wrote:
> Hi, i try to allocate 10GB of memory on my box and it takes about 27
> seconds.

You are actually allocating 20GB of memory, as first it builds a temporary
string and then it copies it.  And it isn't the allocation, but the
initialization and copying that takes the time.  (And then it copies it
again, but presumable it either reuses the memory used for the first
temporary variable, or optimizes that copy away.)

> Is there a faster way to do this?

Do what?  Based on the code you show, we could simply reduce your
entire program to 'print "found needle\n"', as that what the end result
is.  Which parts of the code you show are window dressing and which parts
are the core?

> my $gras = "A" x (1024 * 1024 * 10000);
> my $needle = "B";
> print "\nAllocated " . length($gras) . " byte buffer\n";
> $gras = $gras.$needle;
> print "Allocated " . length($gras) . " byte buffer\n";
> if ($gras ~~ /$needle/) {print "found needle\n"; }

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: Fri, 16 Jan 2009 13:43:56 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Integration Watch: The end for Perl? (SD Times)
Message-Id: <868wpb2is3.fsf@mithril.chromatico.net>

>>>>> "a" == admin  <admin@ng2000.com> writes:

    a> http://www.ng2000.com/fw.php?tp=perl 

I recommend reading the comments on the article, which are much closer
to the truth than the article itself.

Charlton


--
Charlton Wilbur
cwilbur@chromatico.net


------------------------------

Date: Fri, 16 Jan 2009 06:32:54 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: opening a file
Message-Id: <64bacd9a-8e16-40b5-99e3-96ec6314d860@i20g2000prf.googlegroups.com>

On Jan 16, 8:49=A0am, Chris Mattern <sys...@sumire.gwu.edu> wrote:

> > Absolutely! But the 'quality' relates to the output, not the code. I'm
>
> Wrong. =A0So, so, so wrong.

This is like the old debate on art for art's sake. Which is more
important? The product or the tool used to produce the product?

> Nobody who drives across a bridge gives a rat's ass about the details of
> its structural integrity--until the day the bridge collapses. =A0Maybe th=
e
> critical failure of your code won't cost lives, but it's still your
> professional responsibility.

The bridge /IS/ the product. If you can produce /EXACTLY/ the same
product with (1) X dollars in Y days, or with (2) X * 10 dollars in Y
* 10 days, what do you choose? If you can by a BMW for $5,000 or the /
IDENTICAL/ BMW for $50,000, which one would you buy. If you produce
the /SAME/ output with less effort in less time, or with more effort
in more time, what do you do?

The issue is NOT the quality of the end product, because the end
product is identical. The issue is the effort used to produce the
product, and generally we like to minimize the effort. After all, the
cardinal virtues of Perl hackers are (1) laziness, (2) hubris, and (3)
impatience. Seems to me that I'm advocating all three.

CC


------------------------------

Date: Fri, 16 Jan 2009 08:00:30 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: opening a file
Message-Id: <m4b1n4llueicb279s7758tu14ptv6dlmn7@4ax.com>

cartercc <cartercc@gmail.com> wrote:
>On Jan 16, 8:49 am, Chris Mattern <sys...@sumire.gwu.edu> wrote:
>
>> > Absolutely! But the 'quality' relates to the output, not the code. I'm
>>
>> Wrong.  So, so, so wrong.
>
>This is like the old debate on art for art's sake. Which is more
>important? The product or the tool used to produce the product?
>
>> Nobody who drives across a bridge gives a rat's ass about the details of
>> its structural integrity--until the day the bridge collapses.  Maybe the
>> critical failure of your code won't cost lives, but it's still your
>> professional responsibility.
>
>The bridge /IS/ the product. If you can produce /EXACTLY/ the same
>product with (1) X dollars in Y days, or with (2) X * 10 dollars in Y
>* 10 days, what do you choose? If you can by a BMW for $5,000 or the /
>IDENTICAL/ BMW for $50,000, which one would you buy. If you produce
>the /SAME/ output with less effort in less time, or with more effort
>in more time, what do you do?

Poor comparison. If you write the same program a second time hopefully
you won't need the same amount of time again. At least I wouldn't hire
any programmer, who wouldn't take advantage of analysises already done,
lessons learned, and code already written the first time.

As a programmer you do not produce a physical product, you produce an
intellectual product. That is more like an architect producing the plans
for that bridge but not the bridge itself or even better an author
producing the manuscript for a book, but not the physical book. Those
intellectual products can be duplicated with much less effort the second
time.

jue


------------------------------

Date: Fri, 16 Jan 2009 08:57:11 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: opening a file
Message-Id: <7555aa41-6d05-43e3-aed7-b7c9d88c9c27@f24g2000vbf.googlegroups.com>

On Jan 16, 11:00=A0am, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> Poor comparison. If you write the same program a second time hopefully
> you won't need the same amount of time again. At least I wouldn't hire
> any programmer, who wouldn't take advantage of analysises already done,
> lessons learned, and code already written the first time.

I might be in a little different environment than most people. Much of
what I do involves querying a big institutional database over which I
have no control, and which is characterized by constant change. Two
quick examples: (1) Grades were identified by characters (A, B, C)
until one day my queries failed completed. I discovered that the
powers that be decided that henceforth grades would be identified by
digits (6, 7, 8), with no sort of notice to me or anyone else. (2)
This week, I discovered that two columns had been transposed, so that
the expected thousands of students were only 76. I couldn't just un-
transpose the columns, because of the 76 'right' students, so I had to
select and merge two columns. Obviously, the script that I wrote in
December had to be rewritten again this week to account for the
change.

My scripts frequently fail for this reason, so I can't rely on static
scripts that never change. Yes, the techniques are valuable, and
revisions take much less time than the original script. Still, I have
learned to take shortcuts that save time with no diminution in
quality, and I can't understand why that seems to bother some folks so
much.

> As a programmer you do not produce a physical product, you produce an
> intellectual product. That is more like an architect producing the plans
> for that bridge but not the bridge itself or even better an author
> producing the manuscript for a book, but not the physical book. Those
> intellectual products can be duplicated with much less effort the second
> time.

Then I must not be a programmer, because most of what I do gets
printed with a physical printer on real paper. My point is (and I'm
being redundant here) is that in doing a job you minimize costs while
maximizing benefits.

I /DO/ understand the rationale for 'best practices.' Using warnings,
using strict, checking the return value of open(), documenting scripts
and functions, etc., have the purpose of decreasing the cost of
failure, and as such are recommended. However, there are some tasks so
trivial that even the minimal effort of following these practices
seems costly in comparison with the benefit to be gained WITH RESPECT
TO THESE TRIVIAL SCRIPTS.

Again, I'm not advocating not checking the return value of a call to
open, or not following all the other best practices. What I said was
that in the daily grind I frequently omit some niceties. I'm an adult
and am perfectly capable of dealing with it.

CC


------------------------------

Date: Fri, 16 Jan 2009 09:38:44 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: opening a file
Message-Id: <EC3cl.19301$qi.9979@newsfe09.iad>

cartercc wrote:

> The bridge /IS/ the product. If you can produce /EXACTLY/ the same
> product with (1) X dollars in Y days, or with (2) X * 10 dollars in Y
> * 10 days, what do you choose? If you can by a BMW for $5,000 or the /
> IDENTICAL/ BMW for $50,000, which one would you buy. If you produce
> the /SAME/ output with less effort in less time, or with more effort
> in more time, what do you do?

Even if you build the bridge the same way, one has fail safe's and
checking to allow the inspectors or even the people driving and walking
across the bridge some warnings about an existing problem that may lead
to a disaster, allowing workers to remedy the problem or close down the
bridge until the problem is resolved.  Unlike the other bridge that
people happily driver over, and there's no indication of a problem,
until it's too late.  That is a better example of the differences. 
It's not always about checking returns of calls, but verifying that the
script is doing what it's intended to, and not risking it silently
creating a problem.  Granted, not all such problems transpire from lack
of checking the return value alone, but some problems can happen.  Of
course, you said that you'd never do that for a client, so you might be
okay, but why do that to yourself either.  There's no more or less
effort in doing things the right way or the best way (there's no "best
way" or "same way" of doing the same quality coding -- but again,
you've said you don't cut corners for clients anyway, right?
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


------------------------------

Date: Fri, 16 Jan 2009 11:58:58 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: opening a file
Message-Id: <4970cae2$0$89866$815e3792@news.qwest.net>

Tim Greer wrote:
[...]
> Even if you build the bridge the same way, one has fail safe's and
> checking to allow the inspectors or even the people driving and walking
> across the bridge some warnings about an existing problem that may lead
> to a disaster, allowing workers to remedy the problem or close down the
> bridge until the problem is resolved.  [...]


Unless, of course, you live in Minneapolis.


------------------------------

Date: Fri, 16 Jan 2009 10:43:15 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: opening a file
Message-Id: <7z4cl.23704$Nq5.2196@newsfe24.iad>

J. Gleixner wrote:

> Tim Greer wrote:
> [...]
>> Even if you build the bridge the same way, one has fail safe's and
>> checking to allow the inspectors or even the people driving and
>> walking across the bridge some warnings about an existing problem
>> that may lead to a disaster, allowing workers to remedy the problem
>> or close down the
>> bridge until the problem is resolved.  [...]
> 
> 
> Unless, of course, you live in Minneapolis.

Oh, SNAP.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


------------------------------

Date: Fri, 16 Jan 2009 10:45:15 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: opening a file
Message-Id: <ijj1n4tue1tqj10ja4g7b2l806hn987rjd@4ax.com>

cartercc <cartercc@gmail.com> wrote:
>On Jan 16, 11:00 am, Jürgen Exner <jurge...@hotmail.com> wrote:
>> Poor comparison. If you write the same program a second time hopefully
>> you won't need the same amount of time again. At least I wouldn't hire
>> any programmer, who wouldn't take advantage of analysises already done,
>> lessons learned, and code already written the first time.
>
>I might be in a little different environment than most people. Much of
>what I do involves querying a big institutional database over which I
>have no control, and which is characterized by constant change. Two
>quick examples: (1) Grades were identified by characters (A, B, C)
>until one day my queries failed completed. I discovered that the
>powers that be decided that henceforth grades would be identified by
>digits (6, 7, 8), with no sort of notice to me or anyone else. 

What did you do about that? Did you talk to those guys? Did you talk to
your boss about it? What did he do about it? If an agreed upon interface
is not respected and modified without discussion and even without notice
then something is seriously, I mean SERIOUSLY, wrong. If it happenens
more than once this is bad enough to raise hell at least two levels up
the hierachie. 

And afterwards, what happened to prevent further incidentcs like this?
Did those guys update the spec for the database format? Did they at the
very least appologize? Did _YOU_ or your boss establish a better line of
communication with those guys? 

>(2)
>This week, I discovered that two columns had been transposed, so that
>the expected thousands of students were only 76. I couldn't just un-
>transpose the columns, because of the 76 'right' students, so I had to
>select and merge two columns. Obviously, the script that I wrote in
>December had to be rewritten again this week to account for the
>change.

So -theoretically speaking- you boss doesn't care how you create
whatever results you create. As far as he is concerned you could use
pencil and paper, right? Then you are not a programmer but a data
analyst or data processor who happens to be using some scripts for his
own pleasure.

>My scripts frequently fail for this reason, so I can't rely on static
>scripts that never change. 

Excellent case in point. In a stable environment you can get away
without much error checking, because errors are infrequent. 

It is in an ever changing environment where error checking becomes a
mandatory survival strategy and where you need to do every error
checking imaginable, so that your scripts will alert you about those
changes right away and pinpoint the cause as detailed as possible. 

In your first example you were assuming, the grades would be letters.
Had you verified this assumptions by a test in your program then your
program would have told you right away and you wouldn't have to start an
expedition to <quote>discover</quote> the cause.


>Then I must not be a programmer, because most of what I do gets
>printed with a physical printer on real paper. My point is (and I'm
>being redundant here) is that in doing a job you minimize costs while
>maximizing benefits.

Yeah, right. And then you are posting about "Perl crisis". Right.

>Again, I'm not advocating not checking the return value of a call to
>open, or not following all the other best practices. What I said was
>that in the daily grind I frequently omit some niceties. I'm an adult
>and am perfectly capable of dealing with it.

Do it right or suffer the consequences. Sorry, but your arguments are
very short sighted and your problems at your job are very much caused by
yourself: you keep patching the symptoms instead of addressing the
cause. Well, keep patching. It will keep you busy, but it will never
improve the situation.

And if you can't do it, then it's your bosses job to recognize your
problem and assign someone else to fix the reason or to do it himself.
If he doesn't then he is incompetent.

jue


------------------------------

Date: Fri, 16 Jan 2009 09:41:18 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: processing text
Message-Id: <2F3cl.19302$qi.15826@newsfe09.iad>

RedGrittyBrick wrote:

>>open my $gh, '>', $outfile or die "cannot open $filename: $!";
> 
> ^^^^^^^^                     ^^^^^^^^^^

Wow, I didn't even see that when I looked at his code.  Good eye!

PS: To the OP, in case you didn't notice, you're reporting $filename
fails to open, when you're trying to open $outfile.
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


------------------------------

Date: Fri, 16 Jan 2009 10:45:13 -0800
From: Brian Helterline <brian.helterline@hp.com>
Subject: Re: processing text
Message-Id: <gkqkjp$4u8$1@usenet01.boi.hp.com>

George wrote:
> On Thu, 15 Jan 2009 11:41:49 -0800, Tim Greer wrote:
> 
>> George wrote:
>>
>    open my $gh, '>', $outfile or die "cannot open $filename: $!";

if this line fails, you can't open $outfile, not $filename.


------------------------------

Date: Fri, 16 Jan 2009 10:57:37 -0800 (PST)
From: Blue <mrlawrencelam@gmail.com>
Subject: String replacement involving special characters.
Message-Id: <67d58bc8-d9fe-45fd-a45b-949fa8f3cf1d@a29g2000pra.googlegroups.com>

$string = "aaa ' ccc ";
$string =~ s/'/bbb/eg;

The above replaces the single-quotation mark with bbb. The result will
be:
aaa bbb ccc

How do I modify it so that the single-quotation mark is replaced with
\' (a backslash and a single-quotation mark) resulting in:
aaa \' ccc


------------------------------

Date: Fri, 16 Jan 2009 09:58:12 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: What do you need to have to be considered a Master at Perl?
Message-Id: <86k58vw2tn.fsf@blue.stonehenge.com>

>>>>> "sln" == sln  <sln@netherlands.com> writes:

sln> I'm just going to jumstart the topic with these:
sln> - Technically expert at Regular Expressions
sln> - Analytically and Creative at Regular Expressions
sln> - Thoroughly adept at map/split/grep, know limitations
sln> - Arrays and Hashes, including slices and references

Someone who doesn't say:

"Post all your souce code to.. trashbin.com "

perhaps.  Or

"There is no such thing as a C++ program. There are only programs 
written in C++ (or other languages). "

Or even ask the question:

"I need to permute the 26,25,24,... letters of the alphabet. "

:-)

-- 
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: Fri, 16 Jan 2009 14:37:05 GMT
From: hymie@lactose.homelinux.net (hymie!)
Subject: Re: XML::Parser help
Message-Id: <lY0cl.12078$1k1.6350@newsfe14.iad>

In our last episode, the evil Dr. Lacto had captured our hero,
  hymie@lactose.homelinux.net (hymie!), who said:

>I need to ensure that I am looking at either
>/NewsML/NewsItem/NewsComponent/NewsLines
>or
>/NewsML/NewsItem/NewsComponent/NewsComponent/NewsLines
>but **never**
>/NewsML/NewsItem/NewsComponent/NewsComponent/NewsComponent/NewsLines

Somebody else found me the answer that I need.

sub endElement {
    my ($expat, $el) = @_;
   print "->$el<-\n";
   print "NewsComponent->",$expat->within_element("NewsComponent"),"<-\n";
   [...]
}

from the XML::Parser::Expat man page:

       within_element(NAME)
           Returns the number of times the given name appears in
           the context list.

So for my needs, I'm happy as long as
$expat->within_element("NewsComponent") < 3

Thanks for all the advice.

--hymie!    http://lactose.homelinux.net/~hymie    hymie@lactose.homelinux.net
------------------------ Without caffeine for 808 days ------------------------


------------------------------

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 2134
***************************************


home help back first fref pref prev next nref lref last post