[26871] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8876 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 22 14:05:32 2006

Date: Sun, 22 Jan 2006 11:05:05 -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           Sun, 22 Jan 2006     Volume: 10 Number: 8876

Today's topics:
    Re: FAQ 7.13 What is variable suicide and how can I pre axel@white-eagle.invalid.uk
    Re: How to determine memory usage? xhoster@gmail.com
    Re: Matching subsets of two strings <jurgenex@hotmail.com>
    Re: Matching subsets of two strings <tadmc@augustmail.com>
    Re: Scanning file version 2.0 (Raghuramaiah Gompa)
        Trim Double Byte Charaters in Text. <speediercoREMOVE_THIS@yahoo.com>
    Re: Trim Double Byte Charaters in Text. <luoyong_zh@hotmail.com>
    Re: When does a bug turn into a design feature? Or, wha <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: When does a bug turn into a design feature? Or, wha <dcutterREMOVETHECAPS@gmx.de>
    Re: When does a bug turn into a design feature? Or, wha <tadmc@augustmail.com>
    Re: When does a bug turn into a design feature? Or, wha <jwkenne@attglobal.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 22 Jan 2006 13:43:13 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: FAQ 7.13 What is variable suicide and how can I prevent it?
Message-Id: <RZLAf.5682$wl.303@text.news.blueyonder.co.uk>

PerlFAQ Server <comdog@pair.com> wrote:
> This is an excerpt from the latest version perlfaq7.pod, which
> comes with the standard Perl distribution. These postings aim to 
> reduce the number of repeated questions as well as allow the community
> to review and update the answers. The latest version of the complete
> perlfaq is at http://faq.perl.org .
> 
> --------------------------------------------------------------------
> 
> 7.13: What is variable suicide and how can I prevent it?
> 
>    This problem was fixed in perl 5.004_05, so preventing it means
>    upgrading your version of perl. ;)
> 
>    Variable suicide is when you (temporarily or permanently) lose the value
>    of a variable. It is caused by scoping through my() and local()
>    interacting with either closures or aliased foreach() iterator variables
>    and subroutine arguments. It used to be easy to inadvertently lose a
>    variable's value this way, but now it's much harder. Take this code:
> 
>        my $f = 'foo';
>        sub T {
>          while ($i++ < 3) { my $f = $f; $f .= $i; print $f, "\n" }
                                                ^
						|
Minor point. This should be 'bar' or the output examples should be a changed.

>        }
>        T;
>        print "Finally $f\n";
> 
>    If you are experiencing variable suicide, that "my $f" in the subroutine
>    doesn't pick up a fresh copy of the $f whose value is <foo>. The output
>    shows that inside the subroutine the value of $f leaks through when it
>    shouldn't, as in this output:
> 
>            foobar
>            foobarbar
>            foobarbarbar
>            Finally foo
> 
>    The $f that has "bar" added to it three times should be a new $f "my $f"
>    should create a new lexical variable each time through the loop. The
>    expected output is:
> 
>            foobar
>            foobar
>            foobar
>            Finally foo

Axel


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

Date: 22 Jan 2006 04:16:53 GMT
From: xhoster@gmail.com
Subject: Re: How to determine memory usage?
Message-Id: <20060121231653.050$is@newsreader.com>

kj <socyl@987jk.com.invalid> wrote:
> I want to determine how much memory my Perl program is using.  If
> possible, I'd like to measure the memory "high water mark", i.e.
> the most memory used by the program at any point during its run.
> If this is not possible, I'd settle for some instant memory read
> that I can call periodically from within the program.
>
> How should I do this?

On Linux I do this:

my $mem = (`ps -p $$ -o rss `)[1];

Gives size in kb.  It is the resident size, so if you are worried being
partially swapped out, read the man page for ps and change rss to whatever
it should be.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Sun, 22 Jan 2006 04:55:03 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Matching subsets of two strings
Message-Id: <HeEAf.11654$jd5.4998@trnddc02>

Jim Weeb wrote:
[...]
> processes the email)! I wasn't quite sure where the error
> message would be, never mind what it says, but I have gone on a
> hunting spree and here it is (in Exim4's main log, as the script
> is called as an Exim4 transport):
>
> R=mail2news_router T=mail2news_transport: Child process of
> mail2news_transport transport returned 255 (could mean shell
> command ended by signal 127 (Unknown signal 127)) from command:
> /usr/local/bin/mail2news.pl

Well, this is certainly not a Perl error message.

jue





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

Date: Sun, 22 Jan 2006 08:50:34 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Matching subsets of two strings
Message-Id: <slrndt76tq.ve7.tadmc@magna.augustmail.com>

robic0 <> wrote:
> On 22 Jan 2006 00:31:30 -0000, Jim Weeb <jweeb2342@hotmail.com> wrote:


>>runs on a debian box 

> Jesus Christ, 


I am pretty sure that he is not subscribed to this newsgroup.


> whats a nubian box? 


I don't know.

Since you are the first to mention it, why don't *you* tell us
what you mean by it?


> if it is I can programm that baby in 1 minute......


Right.

Do you have any bridges for sale?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 22 Jan 2006 15:40:11 +0000 (UTC)
From: rgompa@steel.ucs.indiana.edu (Raghuramaiah Gompa)
Subject: Re: Scanning file version 2.0
Message-Id: <dr090r$4kn$1@rainier.uits.indiana.edu>

In article <GYednQNUg8-_ElPeRVn-hg@rcn.net>,
thundergnat  <thundergnat@hotmail.com> wrote:
>Anton van der Steen wrote:
>> Hey guys,
>> 
>> Here is version 2.0 for scanning files.
>> I have added scrollbars to the text area and a function
>> to print OUT the result to a other file.
>> Below you will find the script.
>> 
>> I have tested it with Perl 5.8.6 from ActiveState.com,
>> bear this in mind.
>> 
>> Have fun.
>
>So... what was your perl question?
>
>Or were you looking for commentary on this script?
>
>Several things:
K>
>No use warnings
>No use strict
>Poor (non-descriptive) variable names
>Poor (non-descriptive) sub routine names
>Poor indenting
>Lots of (duplicate) hard coded values
>Lots of cut and paste coding
>Use of special variables for other than their intended
>reason (@ARGV)
>Repeated loading of modules (doesn't hurt, but doesn't
>help either)
>No error checking or trapping
>Two argument opens with global file handles rather than
>3 argument 
>  opens with lexical file handles
>Usless use of double quotes when not interpolating
>
>All of those are problems with style. None of them will
>cause the
>script to work incorrectly, they will just make it
>harder to maintain
>and debug, and make it harder for other people to help you.
>
>The bigger problem is that your script doesn't work.
>It will only find a single occurance of the phrase no
>matter how many
>times (> 1) it appears on a line.
>
>Test it. Make a text file that contains:
>
>the best the best the best the best the
>worst the best the best the best the best
>
>then search for the phrase 'the best'. It will report
>2, (one per line)
>rather than 8.
>
>Also, it won't find phrases that are broken across lines.
>Search the above sample file for 'the\sworst' (since
>your aren't escaping
>meta characters you can feed it a regex assertion to
>search.) It won't
>find any.
>
>
>Here's a quick rewrite of your script to correct all of
>the above problems,
>with some other minor enhancements.
>
snip  --- snip ----
>    $error->Show;
>}

I wonder whether this code can be modifed to "highlight 
all instances of text between quotes".  For example, if 
the previous 
sentence is in a file, the code should show the line with 
red color for "highlight all instances of text between 
quotes".  Is it possible? ..  Raghu 



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

Date: Sun, 22 Jan 2006 01:56:05 -0500
From: "OttawaTrade" <speediercoREMOVE_THIS@yahoo.com>
Subject: Trim Double Byte Charaters in Text.
Message-Id: <r0GAf.30124$kz6.11@fe15.lga>

I wonder if there is an easier way to delete double byte charators from
text. The main reason for me to do this is to save space in mysql, because I
want to use TEXT instead of MEDIUMTEXT.




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

Date: Sun, 22 Jan 2006 19:33:07 +0800
From: yong <luoyong_zh@hotmail.com>
Subject: Re: Trim Double Byte Charaters in Text.
Message-Id: <dqvqg8$75t$1@news.yaako.com>

OttawaTrade wrote:
> I wonder if there is an easier way to delete double byte charators from
> text. The main reason for me to do this is to save space in mysql, because I
> want to use TEXT instead of MEDIUMTEXT.
> 
> 

try \X .

It's represents a unicode char in Regular Express.


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

Date: Sun, 22 Jan 2006 09:57:26 +0100
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: When does a bug turn into a design feature? Or, what is a "bug"?
Message-Id: <43d348f8$0$19677$8fcfb975@news.wanadoo.fr>

robic0 wrote:

> I've suggested a problem and a possible solution. You should take 
> or smoke some halucinigens and re-read the post. Maybe your, er ahh,
> "mind" will be able to think "outside the box"... 

No: from what I can follow of your tortuous (and by this I mean 
"rubbish", not "too complex for me to understand") you have posted a set 
of sentences without a cohesive argument, then you have concluded that 
binary systems are not adequate and that something else is required.

I'm going to regret this, but what is your point?


> To engineers, f=ma, and e=mc**2 (means the same thing, with a unit conversion) cannot be eclipsed!
I'm going to regret this, but what are you on about?

What does any of this have to do with Perl?

Mark


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

Date: Sun, 22 Jan 2006 12:47:33 +0100
From: Daniel Cutter <dcutterREMOVETHECAPS@gmx.de>
Subject: Re: When does a bug turn into a design feature? Or, what is a "bug"?
Message-Id: <dqvrcn$c50$1@online.de>


>> To engineers, f=ma, and e=mc**2 (means the same thing, with a unit 
>> conversion) cannot be eclipsed!
> I'm going to regret this, but what are you on about?
> 
> What does any of this have to do with Perl?


I think he's on about that the symbol '=' in mathematics has a 
completely different meaning to the symbol '=' in Perl.

It's all based on the history of computing. The symbol '=' was 
introduced for transfering the result of an equation because it was 
short. Remember that computers at one time were slow. Ever since 
computer language designers have seen this as a flaw and therefore tried 
to remove the ambiguity by useing '=' and '=='. Or as in Pascal ':=' and 
'='.

But even you have taught me something today. I didn't know that the 
French term 'faux pas' is also used in English. I've only ever seen it 
in German.

Daniel Cutter

print chr--$g+ord for'KWVX%GUW]RP^-^Tb]2[UXa\j#'=~m$.$g;


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

Date: Sun, 22 Jan 2006 08:41:18 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: When does a bug turn into a design feature? Or, what is a "bug"?
Message-Id: <slrndt76ce.ve7.tadmc@magna.augustmail.com>

robic0 <> wrote:

> I don't read Xah.


How then, do you know that you are not to be outdone by Xah's rant
as you claimed in the OP?

You can't evaluate if his is better than yours if you have
never read his. Where's that "logic" you possess in such
copious quantitites?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 22 Jan 2006 12:31:58 -0500
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: When does a bug turn into a design feature? Or, what is a "bug"?
Message-Id: <lkPAf.78$Og.54@fe12.lga>

Daniel Cutter wrote:
> 
>>> To engineers, f=ma, and e=mc**2 (means the same thing, with a unit 
>>> conversion) cannot be eclipsed!
>> I'm going to regret this, but what are you on about?
>>
>> What does any of this have to do with Perl?
> 
> 
> I think he's on about that the symbol '=' in mathematics has a 
> completely different meaning to the symbol '=' in Perl.
> 
> It's all based on the history of computing. The symbol '=' was 
> introduced for transfering the result of an equation because it was 
> short. Remember that computers at one time were slow. Ever since 
> computer language designers have seen this as a flaw and therefore tried 
> to remove the ambiguity by useing '=' and '=='. Or as in Pascal ':=' and 
> '='.

Actually, ":=" dates back to ALGOL 58, at the dawn of programming 
languages as we know them.

> But even you have taught me something today. I didn't know that the 
> French term 'faux pas' is also used in English. I've only ever seen it 
> in German.

Yes, it's quite common in English.

-- 
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
   -- Charles Williams.  "Judgement at Chelmsford"


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

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


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