[29887] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1130 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 18 18:09:41 2007

Date: Tue, 18 Dec 2007 15:09:07 -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, 18 Dec 2007     Volume: 11 Number: 1130

Today's topics:
        ANNOUNCE: Tk 804.028 <slaven@rezic.de>
    Re: CGI::Minimal and Cookies xhoster@gmail.com
    Re: CGI::Minimal and Cookies <john@castleamber.com>
    Re: CGI::Minimal and Cookies <ben@morrow.me.uk>
    Re: CGI::Minimal and Cookies <john@castleamber.com>
        Differentiating between x64 and x86 Windows XP. <vtbose@gmail.com>
    Re: Differentiating between x64 and x86 Windows XP. <smallpond@juno.com>
    Re: Differentiating between x64 and x86 Windows XP. <ben@morrow.me.uk>
    Re: FAQ 4.3 Why isn't my octal data interpreted correct <hjp-usenet2@hjp.at>
        Need help with leaks <grg2@comcast.net>
    Re: Need help with leaks <joost@zeekat.nl>
    Re: Need help with leaks <krahnj@telus.net>
    Re: Problem with GDGraph.com website? <mgjv@tradingpost.com.au>
    Re: Problem with Perl system() <smallpond@juno.com>
        regex expression help Tom.E.Ward@gmail.com
    Re: regex expression help <m@rtij.nl.invlalid>
    Re: regex expression help <noreply@gunnar.cc>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 18 Dec 2007 22:26:24 GMT
From: Slaven Rezic <slaven@rezic.de>
Subject: ANNOUNCE: Tk 804.028
Message-Id: <Jt9oE3.1HFy@zorch.sf-bay.org>

perl 5.10.0 is out, so there's the promised release of a stable
Perl/Tk:

| The uploaded file
| 
|     Tk-804.028.tar.gz
| 
| has entered CPAN as
| 
|   file: $CPAN/authors/id/S/SR/SREZIC/Tk-804.028.tar.gz
|   size: 6927637 bytes
|    md5: 7153c1c411b0dd005a0660179e5c5900
| 
| No action is required on your part
| Request entered by: SREZIC (Slaven Rezi,Bf(B)
| Request entered on: Tue, 18 Dec 2007 22:01:24 GMT
| Request completed:  Tue, 18 Dec 2007 22:01:42 GMT

There are no significant changes since the last development release
Tk-804.027_502, just some test fixes.

Tk should build on common operating systems like Linux, FreeBSD,
Solaris 10, Windows (at least using Strawberry Perl), and Mac OS X
(using the X server). Unfortunately cygwin is known to not built, but
I think this is the same situation as with Tk 804.027. Test failures
are possible, especially window manager and font related ones, but
should be rare. Don't hesitate to report them, either by mail or via
CPAN testers.

To install the tarball you can use the CPAN shell:

    cpan Tk

Perl/Tk development may be tracked in the subversion repository

    http://svn.perl.org/modules/Tk

Regards,
    Slaven

-- 
Slaven Rezic - slaven <at> rezic <dot> de

    Berlin Perl Mongers - http://berlin.pm.org




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

Date: 18 Dec 2007 16:51:48 GMT
From: xhoster@gmail.com
Subject: Re: CGI::Minimal and Cookies
Message-Id: <20071218115149.683$xc@newsreader.com>

Ben Morrow <ben@morrow.me.uk> wrote:
> Quoth xhoster@gmail.com:
> > Ben Morrow <ben@morrow.me.uk> wrote:
> > > Quoth John Bokma <john@castleamber.com>:
> > > > From the documentation of CGI::Minimal: "See 'CGI::Cookie' for
> > > > cookie generation". Which sounds like a lot of fun, except that
> > > > CGI::Cookie does:
> > > >
> > > > use CGI;
> > > >
> > > > Which probably makes use CGI::Minimal pointless. Or am I wrong?
> > >
> > > Which version? I have 1.26 here, and it doesn't use CGI. It does use
> > > CGI::Util, which contains a group of routines for doing URI-escaping
> > > and such; maybe older versions just used CGI instead, and the code's
> > > been refactored?
> >
> > I see it there, in the next line after the use CGI::Util.  Maybe you
> > deleted use CGI in your local copy?
>
> No, certainly not... :)
> Further investigation reveals that line was added in CGI::Cookie 1.27,
> in CGI.pm-3.17.

It looks like they added it in CGI-3.16, but forgot to update the version
in Cookie, so it still says it is 1.26.  Or maybe I don't understand how
these bundle things work.

> I wonder why...

It looks like when they added the "bake" method, they made it use a method
from CGI, so added it.

Unfortunately you can't prevent a "use" from happening via subclassing.



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: 18 Dec 2007 17:57:22 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: CGI::Minimal and Cookies
Message-Id: <Xns9A0A79A106E75castleamber@130.133.1.4>

xhoster@gmail.com wrote:
 
> Unfortunately you can't prevent a "use" from happening via
> subclassing. 

I've already considered creating a nearly empty CGI.pm, and making sure 
it's loaded first >:->. 

Anyway, I contacted the author, and hopefully it's fixed in the near 
future. It's not that urgent (to me).



-- 
John

Arachnids near Coyolillo - part 1
http://johnbokma.com/mexit/2006/05/04/arachnids-coyolillo-1.html


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

Date: Tue, 18 Dec 2007 18:58:12 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: CGI::Minimal and Cookies
Message-Id: <4rhl35-311.ln1@osiris.mauzo.dyndns.org>


Quoth xhoster@gmail.com:
> Ben Morrow <ben@morrow.me.uk> wrote:
<snip: CGI::Cookie uses CGI.pm>
> 
> It looks like they added it in CGI-3.16, but forgot to update the version
> in Cookie, so it still says it is 1.26.  Or maybe I don't understand how
> these bundle things work.

Yes, it does. Bad Lincoln, no cookie. (SCNR)

It's annoying, especially since $cookie->bake is AFAICS equivalent
to $CGI->header(-cookie => $cookie), and the docs for CGI::Cookie state
it can be used independantly.

> > I wonder why...
> 
> It looks like when they added the "bake" method, they made it use a method
> from CGI, so added it.
> 
> Unfortunately you can't prevent a "use" from happening via subclassing.

    {
        local $INC{'CGI.pm'} = $0;
        use CGI::Cookie;
    }

perhaps with a

    {
        package CGI;
        use autouse CGI => 'header';
    }

as well. Of course, it will break if you call the ->bake method, so
don't do that.

Ben



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

Date: 18 Dec 2007 19:20:40 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: CGI::Minimal and Cookies
Message-Id: <Xns9A0A87C01E92Fcastleamber@130.133.1.4>

Ben Morrow <ben@morrow.me.uk> wrote:

> Quoth xhoster@gmail.com:
>> Ben Morrow <ben@morrow.me.uk> wrote:
> <snip: CGI::Cookie uses CGI.pm>
 
>> Unfortunately you can't prevent a "use" from happening via
>> subclassing. 
> 
>     {
>         local $INC{'CGI.pm'} = $0;
>         use CGI::Cookie;
>     }
> 
> perhaps with a
> 
>     {
>         package CGI;
>         use autouse CGI => 'header';
>     }
> 
> as well. Of course, it will break if you call the ->bake method, so
> don't do that.

Heh, since I bake my cookies via Template::Toolkit (Set-Cookie: ... in (my 
own) http_headers.tt), I don't care about that. Thanks for the work-around 
suggestions.

-- 
John

Arachnids near Coyolillo - part 1
http://johnbokma.com/mexit/2006/05/04/arachnids-coyolillo-1.html


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

Date: Tue, 18 Dec 2007 12:42:52 -0800 (PST)
From: cybose <vtbose@gmail.com>
Subject: Differentiating between x64 and x86 Windows XP.
Message-Id: <e53015d7-c78d-46cc-9ef6-3bccb5adcae8@e23g2000prf.googlegroups.com>

my @os_arch = config_re(qw(archname)) returns the x64 or x86 based on
whatever platform Perl was built on.

How can I determine if my os is Windows XP x86 or Windows XP x64 ?


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

Date: Tue, 18 Dec 2007 13:44:43 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: Differentiating between x64 and x86 Windows XP.
Message-Id: <23b39afc-7cba-4c65-9e1d-b370a571986d@p1g2000hsb.googlegroups.com>

On Dec 18, 3:42 pm, cybose <vtb...@gmail.com> wrote:
> my @os_arch = config_re(qw(archname)) returns the x64 or x86 based on
> whatever platform Perl was built on.
>
> How can I determine if my os is Windows XP x86 or Windows XP x64 ?

Try Win32::GetOSName


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

Date: Tue, 18 Dec 2007 21:42:01 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Differentiating between x64 and x86 Windows XP.
Message-Id: <9erl35-vr1.ln1@osiris.mauzo.dyndns.org>


Quoth cybose <vtbose@gmail.com>:
> my @os_arch = config_re(qw(archname)) returns the x64 or x86 based on
> whatever platform Perl was built on.
> 
> How can I determine if my os is Windows XP x86 or Windows XP x64 ?

Win32::SystemInfo

Ben



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

Date: Tue, 18 Dec 2007 19:30:08 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: FAQ 4.3 Why isn't my octal data interpreted correctly?
Message-Id: <slrnfmg4dg.go9.hjp-usenet2@hrunkner.hjp.at>

On 2007-12-17 19:55, brian d foy <brian.d.foy@gmail.com> wrote:
> In article <slrnfmaoho.g0p.hjp-usenet2@hrunkner.hjp.at>, Peter J.
> Holzer <hjp-usenet2@hjp.at> wrote:
>
>> On 2007-12-16 16:59, brian d foy <brian.d.foy@gmail.com> wrote:
>> > In article <slrnfm8mmg.at5.hjp-usenet2@hrunkner.hjp.at>, Peter J.
>> > Holzer <hjp-usenet2@hjp.at> wrote:
>> >> On 2007-12-15 08:03, PerlFAQ Server <brian@stonehenge.com> wrote:
>> >> > 4.3: Why isn't my octal data interpreted correctly?
>> >> >
>> >> >     Perl only understands octal and hex numbers as such when
>> >> >     they occur as literals in your program. Octal literals in
>> >> >     perl must start with a leading 0 and hexadecimal literals
>> >> >     must start with a leading "0x". If they are read in from
>> >> >     somewhere and assigned, no automatic conversion takes place.
>> >> >     You must explicitly use "oct()" or "hex()" if you want the
>> >> >     values converted to decimal.
>> >>                           ^^^^^^^
>> >> Perl numbers aren't decimal,
>> 
>> It might help if you read a little more than the first half sentence.
>> All of your objections were answered in the next few lines.
>
> There's no need to be a jerk.

Sorry. You pushed a sensitive spot there.


> I read the entire message you posted and clarified the issue.

I don't see how quoting a half-sentence out of a paragraph and then
presenting issues as new which were already addressed in the same
paragraph clarifies anything. At the very least, that's a rather sloppy
discussion style.


> You said that numbers were binary. As you said in response to my
> message, that is wrong.

I hope nobody except you read my response that way, because I certainly
didn't mean that.  Perl numbers are binary, it's just rather irrelevant
for this question.


> I still say that Perl numbers are decimal unless we say otherwise.

That's easy to disprove:

% perl -l -e 'for ($i = 0; $i != 1; $i += 0.1) { print $i }' 
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2
2.1
^C

Obviously not decimal.

I could accept an argument that perl numbers aren't binary because Perl
(the language) doesn't make any guarantees and they could be anything,
so there might be platform where perl (the interpreter) really uses
decimal numbers. But since this is rather hypothetical and Perl is
defined by the implementation and not a formal standard, I find even
that argument rather tenuous.


> Perl will treat them as decimal

No. Perl treats *strings* as decimal when used in a numeric context.
That is, it will convert from the decimal representation to an internal
(binary) representation. The number will than always be treated as the
binary number it is, because anything else would just result in garbage.
When a number is used in a string context, it is converted to decimal.

> and print them as decimal unless given instructions not to. That's the
> point of the FAQ. 

The point of the FAQ is conversion from strings to numbers (and back) in
some bases. Base 10 is clearly privileged as just using a string in a
numeric context (or a number in a string context) invokes the
conversion, but claiming that perl numbers are decimal, or that hex()
and oct() "convert to decimal" is just wrong.

> I'm sure that the next time we might disagree that we can do it
> respectfully. :)

I consider properly addressing the points made by the previous poster as
an important part of disagreeing respectfully.

	hp



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

Date: Tue, 18 Dec 2007 13:45:27 -0800 (PST)
From: Abble <grg2@comcast.net>
Subject: Need help with leaks
Message-Id: <ce439df7-5e17-4a4e-9ecf-63a12d8289a8@b40g2000prf.googlegroups.com>

Okay, I have about 6,000 lines of Perl code, which generally work
GREAT, but I have a big memory leak.

Yes, I had to do some sloppy coding to leak memory in Perl.  I have a
LOT of global variables.
After each pass of the program a few hundred megabytes get leaked into
various variables.
I HAVE added a sub to reset everything to '' and (), but I must be
forgetting a few variables, as on each pass the memory usage goes UP
and UP and UP, until it gets to about 1.6GB and everything crashes.

Is there some way to view ALL of the Perl symbol tables and see what
I'm forgetting to trash?

I tried several of the hints on the net, including peeking at keys
\main::, and so on, but all I see there are barewords and some sub
names, none of my variable names.


Any hints appreciated.



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

Date: Tue, 18 Dec 2007 23:03:50 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Need help with leaks
Message-Id: <87hcif1wzd.fsf@zeekat.nl>

Abble <grg2@comcast.net> writes:

> Okay, I have about 6,000 lines of Perl code, which generally work
> GREAT, but I have a big memory leak.
>
> Yes, I had to do some sloppy coding to leak memory in Perl.  I have a
> LOT of global variables.
> After each pass of the program a few hundred megabytes get leaked into
> various variables.

I always think of a memory leak as allocating memory and then losing
the references to it so you *can't* free it anymore. Forgetting to empty 
out some variable that's still accessible is not a leak. Other people
may disagree.

> I HAVE added a sub to reset everything to '' and (), but I must be
> forgetting a few variables, as on each pass the memory usage goes UP
> and UP and UP, until it gets to about 1.6GB and everything crashes.

AFAIK setting variables to '' and () doesn't necessarily reclaim any
memory to perl. undef VARIABLE may work better. But it looks like the
real problem is elsewhere.

You may have some circular structures, which will never get reclaimed 
until the perl interpreter exits.

http://search.cpan.org/~lds/Devel-Cycle-1.07/lib/Devel/Cycle.pm

> Is there some way to view ALL of the Perl symbol tables and see what
> I'm forgetting to trash?

There's stuff at http://search.cpan.org/search?query=devel+leak&mode=all
and http://search.cpan.org/search?query=devel&mode=all

This one looks interesting:

http://search.cpan.org/~cgautam/Devel-DumpSizes-0.01/lib/Devel/DumpSizes.pm

HTH,
Joost.


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

Date: Tue, 18 Dec 2007 23:07:51 GMT
From: "John W. Krahn" <krahnj@telus.net>
Subject: Re: Need help with leaks
Message-Id: <476852BA.68CCB430@telus.net>

Abble wrote:
> 
> Okay, I have about 6,000 lines of Perl code, which generally work
> GREAT, but I have a big memory leak.
> 
> Yes, I had to do some sloppy coding to leak memory in Perl.  I have a
> LOT of global variables.
> After each pass of the program a few hundred megabytes get leaked into
> various variables.
> I HAVE added a sub to reset everything to '' and (), but I must be
> forgetting a few variables, as on each pass the memory usage goes UP
> and UP and UP, until it gets to about 1.6GB and everything crashes.

perldoc -f reset


John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 19 Dec 2007 07:00:48 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Problem with GDGraph.com website?
Message-Id: <slrnfmg9ng.gdg.mgjv@martien.heliotrope.home>

On Mon, 17 Dec 2007 16:39:51 -0800 (PST),
	timbo <beagles_1881@yahoo.com.au> wrote:

[snip]

> Btw, yes I was referring to the GDGraph module from CPAN.
> The GDGraph website had some documentation but what I was really after
> was the sample code for the various graphs.
> I managed to get a few but not all.

I am not sure, because that web site doesn't seem to be around anymore,
but from what I can see from Google's cache, it seems that the samples
that were there were simply the ones that come with the GDGraph
distribution.

If you download the full distribution from CPAN (http://cpan.perl.org),
and unpack it somewhere, it will have a directory called 'samples',
which contains a load of examples. Are those the ones you're after?

> But luckily Google's cache still had a copy, so never mind.
> Anyway, cheers everyone.

If the examples on that website are different to the ones in the
distrubution, then simply disregard this post.

Martien
-- 
                        | 
Martien Verbruggen      | Freudian slip: when you say one thing but
                        | mean your mother.
                        | 


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

Date: Tue, 18 Dec 2007 10:48:16 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: Problem with Perl system()
Message-Id: <67baf74b-ce45-4996-baf6-e78531151278@i3g2000hsf.googlegroups.com>

On Dec 18, 8:13 am, Julie <Ju...@nospam.com> wrote:
> I'm using Windows XP Pro and running Perl 5.8.8 under Cygwin.
>
> I have a Perl program that calls another Perl program using system().
>
> The driver program repeatedly calls the main Perl program.
>
> for ( my $i = 0 ; $i < $retries ; $i++
> {
>     for ( my $j = 0 ; $j < $num_devices ; $j++ )
>     {
>        system( "perl main.pl parm1 parm2 &" ) ;
>     }
>     sleep 60 ;  # never gets here
>
> }
>
> I put the call to system() within a loop and (almost) everything is fine.
>
> The only problem is that after the last call to system(), the outer loop
> doesn't gain control.  The process seems to be hung.
> I've put warn statements everywhere in the driver program but that
> hasn't yielded any clues.
>
> I know that main.pl is terminating because there's only one Perl process
> running after the last call to system().
>
> It doesn't matter whether I run one or a hundred calls to system().
>
> **** Here's what's very interesting:   If I run main.pl under the Perl
> debugger then press 'c' to continue (no breakpoints etc.),  then the
> program behaves perfectly; control is passed to the outer loop after the
> last system() call.
>
> I'm using strict, warning, diagnostics pragmas.  I've also tried main.pl
> without the pragmas.
>
> What can I do to resolve this problem?


system emulates fork which !-e on Windows, so there are many
issues with it.
To start a bunch of cooperating perl tasks, maybe take a
look at Win32::ProcFarm.
--S


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

Date: Tue, 18 Dec 2007 13:00:56 -0800 (PST)
From: Tom.E.Ward@gmail.com
Subject: regex expression help
Message-Id: <c9e05be5-3785-4438-b413-be8efb6a03ee@p69g2000hsa.googlegroups.com>

I need to extract serial numbers from multiple text files. I have an
expression that works fairly well, but the problem is some of the
serial numbers are enclosed within quotes (both single and double) and
I can't figure out a good way to get rid of the closing quote. The
expression of have now is:

/($matchString\s*[\:\=\-]\s*[\'\"]?)(([\w]+$)|(([\w]+)([^\w])))/

($matchString contains {"serial number", "sn", "s/n", "serial num",
etc.}

All the quotes are because I use $2 to extract the actual number. Any
help is appreciated.


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

Date: Tue, 18 Dec 2007 22:20:22 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: regex expression help
Message-Id: <pan.2007.12.18.21.20.21@rtij.nl.invlalid>

On Tue, 18 Dec 2007 13:00:56 -0800, Tom.E.Ward wrote:

> I need to extract serial numbers from multiple text files. I have an
> expression that works fairly well, but the problem is some of the serial
> numbers are enclosed within quotes (both single and double) and I can't
> figure out a good way to get rid of the closing quote. The expression of
> have now is:
> 
> /($matchString\s*[\:\=\-]\s*[\'\"]?)(([\w]+$)|(([\w]+)([^\w])))/
> 
> ($matchString contains {"serial number", "sn", "s/n", "serial num",
> etc.}
> 
> All the quotes are because I use $2 to extract the actual number. Any
> help is appreciated.

How about:

if (/($matchString\s*[\:\=\-])\s*(.*?)\s*$/) {
  my $sn = $2;
  $sn =~ s/^['"]//;
  $sn =~ s/['"]$//;
  # do stuff....
}

Not 100% the same as the opening quote is not captured in $1, but I 
cannot imagine you want that.

Otherwise, how about:

/($matchString\s*[\:\=\-]\s*['"]?)(.*?)['"]?\s*$/

HTH,
M4




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

Date: Tue, 18 Dec 2007 23:21:11 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: regex expression help
Message-Id: <5sqvilF1asdb0U1@mid.individual.net>

Tom.E.Ward@gmail.com wrote:
> I need to extract serial numbers from multiple text files. I have an
> expression that works fairly well, but the problem is some of the
> serial numbers are enclosed within quotes (both single and double) and
> I can't figure out a good way to get rid of the closing quote. The
> expression of have now is:
> 
> /($matchString\s*[\:\=\-]\s*[\'\"]?)(([\w]+$)|(([\w]+)([^\w])))/
> 
> ($matchString contains {"serial number", "sn", "s/n", "serial num",
> etc.}

A backreference might be useful.

     /$matchString\s*[:=-]\s*(['"]?)([\w]+)\1/

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

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


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