[24562] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6740 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 28 14:05:41 2004

Date: Mon, 28 Jun 2004 11:05:08 -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           Mon, 28 Jun 2004     Volume: 10 Number: 6740

Today's topics:
    Re: "Can't locate loadable object for module GMP" - any (Jasper)
        Does Perl combine multiple REs into a single automaton? <clint@0lsen.net>
        get variables? (Stefano Russo)
    Re: grabbing array vlaues in a loop where array is rede <wunkalunka@elvis.com>
        how to NOT quote constants in hash keys (Martin Adler)
    Re: how to NOT quote constants in hash keys <tore@aursand.no>
    Re: how to NOT quote constants in hash keys <mritty@gmail.com>
    Re: how to NOT quote constants in hash keys <mritty@gmail.com>
    Re: HTTP::TokeParser for a web page? <bjg@network-theory.co.uk>
    Re: HTTP::TokeParser for a web page? <iss025@bangor.ac.uk>
        limitations of forking on windows (Corey_G)
    Re: Non-unique columns via ODBC driver ctcgag@hotmail.com
        Problem with Gtk2 and POE <iron@ironiq.hu>
    Re: Problem with Gtk2 and POE <troc@pobox.com>
    Re: Strange Behaviour with Hash??? (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 28 Jun 2004 08:09:38 -0700
From: jasper_marzin@yahoo.com (Jasper)
Subject: Re: "Can't locate loadable object for module GMP" - any ideas
Message-Id: <89b27d52.0406280709.313ee479@posting.google.com>

Sisyphus <kalinaubears@iinet.net.au> wrote in message news:<40dfd0e0$0$24744$5a62ac22@per-qv1-newsreader-01.iinet.net.au>...
> Jasper wrote:
> > Hi there, I installed GNU GMP for windows and placed GMP.pm in the
> > directories indicated below, any ideas why perl spits this error back
> > at me ??  Is there something specific I need to do ?
> > Thanks for any assistance..
> > 
> > Can't locate loadable object for module GMP in @INC (@INC contains:
> > c:/Perl/lib c:/Perl/s
> > ite/lib .) at test.pl line 46
> > Compilation failed in require at test.pl line 46.
> > BEGIN failed--compilation aborted at test.pl line 46.
> 
> I presume you obtained 'GMP.pm' from the Demos/Perl folder. That's not 
> the right way to go about it. You need to cd to the Demos/Perl folder 
> and run in turn:
> perl Makefile.PL
> make test
> make install
> 
> (You should replace 'make' with whatever 'perl -V:make' reports - 
> probably 'nmake' I'm guessing.)
> That way you'll end up building and installing the *entire* module - 
> including the 'loadable object' which isn't being found :-)
> 
> But then .... gee .... it's hard to give good advice when I have to 
> guess about so much .... let's just say that if you're running 
> ActiveState perl you can get all of the GMP stuff you need (including 
> the GMP dll, the GMP module, the Math::GMP module, the Math::BigInt::GMP 
> module, and more) from
> http://www.kalinabears.com.au/w32perl/math_gmp.html .
> You shouldn't have to build anything - just download and install as per 
> the instructions.
> If you strike trouble with any of it, please let me know. (The 
> "instructions" make perfect sense to me, but I've been around long 
> enough to know that doesn't necessarily mean they're sensible :-)
> 
> If you're not using ActiveState perl (or even if you are but would 
> prefer to build things yourself) could you tell us what 'perl -V' reports.
> 
> Cheers,
> Rob


Yes running Activestate...I will try and install all the other GMP
software and try again...


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

Date: Mon, 28 Jun 2004 17:04:23 GMT
From: Clint Olsen <clint@0lsen.net>
Subject: Does Perl combine multiple REs into a single automaton?
Message-Id: <slrnce0jsn.1vg.clint@poly.0lsen.net>

Hi:

I posted earlier about how to speed up writing lexical analyzers in Perl.
With that effort in mind, I was curious to know if Perl combines multiple
patterns like:

if (/pat/) {
} elsif (/pat1/) {
 ...
} elsif (/pat2/) {
 ...
 ...
 ...
} else {
}

so that pat[\d]+ are in a sense combined via alternation with each branch
working like embedded action code?

The reason why I ask is that someone suggested I try to do this manually in
order to help speed up the pattern matching process (presumably using the
"(?{ code })" feature documented in perlre.  Is it really faster to do it
this way?

When I'm in the debugger in Perl, I've noticed that the execution path gets
sort of muddied.  I don't see Perl executing each match as a separate
statement.  It's as if it jumps right to the code for the pattern match.
If that's the case, then there's not much of a compelling argument to embed
action code and cobmine REs.

Thanks,

-Clint


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

Date: Mon, 28 Jun 2004 17:56:52 GMT
From: "Ste (Stefano Russo)" <ste9986@tin.nospam.it>
Subject: get variables?
Message-Id: <EZYDc.390155$hc5.16842498@news3.tin.it>

Hi, i would like to know if is possible to recall a variable passed via 
get trought a url.

example:

www.terra32.net/perl/ping.pl?url=www.google.it

How can i recall the variable "url" in the script?

Thanks a lot, excuseme for my bad english..

-- 
                   |||
                  (0.0)
|-------------o00----00o-----------------------------|
|Stefano Alberto Russo - Liceo Oberdan - Trieste     |
|www.terra32.net - webmaster @ www.acquariofilia.biz |
|----------------------------------------------------|



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

Date: Mon, 28 Jun 2004 16:48:34 GMT
From: Derf <wunkalunka@elvis.com>
Subject: Re: grabbing array vlaues in a loop where array is redefined
Message-Id: <Xns95167B0FA3C3Bwunkalunkaelviscom@24.93.43.121>

Jaap Karssenberg <j.g.karssenberg@student.utwente.nl> wrote in 
news:20040628111445.0c2d6bee@Captain:

> 
> Try:
>   $corrects{$quest}=[@corrects];
> 
> instead of:
>   $corrects{$quest}=\@correct;
> 

Yes, this is the answer. Thanks so much.

Derf


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

Date: 28 Jun 2004 09:59:53 -0700
From: orzacha@yahoo.de (Martin Adler)
Subject: how to NOT quote constants in hash keys
Message-Id: <c949495d.0406280859.3fed7af3@posting.google.com>

What can I "use" to make the following program work as I want it to? 

#!/usr/bin/perl -w
use strict;
use constant N => 17 ;
my %x ;
$x{N} = 25 ;    #  who wants to write $x{(N)} = 25   all the time? 
print   keys %x ; 

The output is "N", so Perl apparently interprets  $x{N} as $x{"N"}.  
But how can I tell it to interpret constants as their (constant)
value?
I want Perl to interpret $x{N} as $x{17}. 

One of the goals of perl is "to make easy tasks easy and difficult
tasks possible".   It seems to me that it is POSSIBLE to use constants
as hash keys (e.g.:  $x{ (N) }), but it does not look EASY. 

Or what else should I do?


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

Date: Mon, 28 Jun 2004 19:10:24 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: how to NOT quote constants in hash keys
Message-Id: <pan.2004.06.28.17.09.30.509694@aursand.no>

On Mon, 28 Jun 2004 09:59:53 -0700, Martin Adler wrote:
> #!/usr/bin/perl -w
> use strict;
> use constant N => 17 ;
> my %x ;
> $x{N} = 25 ;    #  who wants to write $x{(N)} = 25   all the time? 
> print   keys %x ; 
> 
> The output is "N", so Perl apparently interprets  $x{N} as $x{"N"}.  
> But how can I tell it to interpret constants as their (constant)
> value?
> I want Perl to interpret $x{N} as $x{17}. 

Why didn't you read the documentation before posting?  It would have saved
you a lot of time;

  perldoc constant


-- 
Tore Aursand <tore@aursand.no>
"Measuring programming progress by lines of code is like measuring
 aircraft building progress by weight." (Bill Gates)


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

Date: Mon, 28 Jun 2004 13:34:19 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: how to NOT quote constants in hash keys
Message-Id: <20040628132926.X2559@dishwasher.cs.rpi.edu>

On Mon, 28 Jun 2004, Martin Adler wrote:

> What can I "use" to make the following program work as I want it to?
>
> #!/usr/bin/perl -w
> use strict;
> use constant N => 17 ;
> my %x ;
> $x{N} = 25 ;    #  who wants to write $x{(N)} = 25   all the time?
> print   keys %x ;
>
> The output is "N", so Perl apparently interprets  $x{N} as $x{"N"}.
> But how can I tell it to interpret constants as their (constant)
> value?
> I want Perl to interpret $x{N} as $x{17}.
>
> One of the goals of perl is "to make easy tasks easy and difficult
> tasks possible".   It seems to me that it is POSSIBLE to use constants
> as hash keys (e.g.:  $x{ (N) }), but it does not look EASY.
>
> Or what else should I do?

Perl is trying to make something easy.  It's just not what you want to be
easy in this case.  Perl's auto-quoting is taking over here, which makes
it easy for the vast majority of cases, when we want $x{N} to mean
$x{'N'}, instead of the remarkably few cases when we want $x{N} to mean
$x{(WhateverValueConstantNRepresents)}.

You have three basic options:
write $x{N()} instead of $x{N}
write $x{+N} instead of $x{N}
use the ReadOnly module from CPAN instead of the constant pragma.  This
defines constants that look like Perl variables instead of C Macros:

use ReadOnly $N => 17;
$x{$N} = 25;


Paul Lalli


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

Date: Mon, 28 Jun 2004 13:41:16 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: how to NOT quote constants in hash keys
Message-Id: <20040628133920.W2559@dishwasher.cs.rpi.edu>

On Mon, 28 Jun 2004, Paul Lalli wrote:
> use the ReadOnly module from CPAN instead of the constant pragma.  This
> defines constants that look like Perl variables instead of C Macros:
>
> use ReadOnly $N => 17;
> $x{$N} = 25;

I should clarify two things:
1) the above is not actually correct syntax.
Read the Readonly documentation for the correct syntax.

2) Readonly.pm comes with a significant performance hit over constant.pm.
Read teh Readonly documentation for details.

Paul Lalli


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

Date: 28 Jun 2004 14:28:25 +0100
From: Brian Gough <bjg@network-theory.co.uk>
Subject: Re: HTTP::TokeParser for a web page?
Message-Id: <87n02nolqe.fsf@network-theory.co.uk>

"P.R.Brady" <iss025@bangor.ac.uk> writes:

> TokeParser looks a really useful tool for parsing HTML but will it only 
> take input from a file?  Is it possible to get it to munge a web page 
> directly or even a scalar holding the page content (eg previously 
> grabbed with get)?

According to the documentation (perldoc HTML::TokeParser.pm) it
accepts either a filename, file handle, or string containing the
document (as a reference).

-- 
Brian Gough

Network Theory Ltd,
Publishing Free Software Manuals --- http://www.network-theory.co.uk/


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

Date: Mon, 28 Jun 2004 15:06:50 +0100
From: "P.R.Brady" <iss025@bangor.ac.uk>
Subject: Re: HTTP::TokeParser for a web page?
Message-Id: <40E025FA.5040809@bangor.ac.uk>

Paul Lalli wrote:
> On Mon, 28 Jun 2004, P.R.Brady wrote:
> 
> 
>>TokeParser looks a really useful tool for parsing HTML but will it only
>>take input from a file?  Is it possible to get it to munge a web page
>>directly or even a scalar holding the page content (eg previously
>>grabbed with get)?
> 
> 
> From the documentation (perldoc HTML::TokeParser):
> 
> 
>   $p = HTML::TokeParser->new( \$document );
>      If the argument is a reference to a plain scalar, then this scalar is
>      taken to be the literal document to parse. The value of this scalar
>      should not be changed before all tokens have been extracted.
> 
> 
> So in a word, yes.
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> use LWP::Simple;
> use HTML::TokeParser;
> 
> my $doc = get("http://www.yahoo.com");
> my $parser = HTML::TokeParser->new(\$doc);
> 
> if ($parser->get_tag("title")) {
>    my $title = $parser->get_trimmed_text;
>    print "Title: $title\n";
> }
> __END__
> Title: Yahoo!
> 
> Paul Lalli

Great!   Thanks Paul.
Phil



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

Date: 28 Jun 2004 07:36:44 -0700
From: corey-nospam@test-tools.net (Corey_G)
Subject: limitations of forking on windows
Message-Id: <7ef3e932.0406280636.6b3f2c7d@posting.google.com>

I wrote some simple code that forks processes and sends http requests
from the children.  I have read the perlfork documentation and
understand that Windows uses "fork umulation" (with threads) rather
than actually forking processes (like you can in *nix).  I am
wondering if anyone has any experience of the limitations of how many
processes can be forked?  I get memory errors at 10 processes (in
comparison, I can fork several hundred on linux with no problems).

in the perlfork doc: "In the eyes of the operating system,
pseudo-processes created via the fork() emulation are simply threads
in the same process. This means that any process-level limits imposed
by the operating system apply to all pseudo-processes taken together.
This includes any limits imposed by the operating system on the number
of open file, directory and socket handles, limits on disk space
usage, limits on memory size, limits on CPU utilization etc."

I don't see how I could be hitting any limits at such a small number
of processes.

[using ActiveState Perl 5.8 on Win2k)


-Corey Goldberg


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

Date: 28 Jun 2004 16:15:41 GMT
From: ctcgag@hotmail.com
Subject: Re: Non-unique columns via ODBC driver
Message-Id: <20040628121541.441$uT@newsreader.com>

I & L Fogg <il.fogg@bigpond.net.au> wrote:
> I am trying to copy data from a proprietary ("semi"-relational) database
> to MySQL. Fortunately, the db vendor provides an ODBC driver, so getting
> the db schema and data is fairly straighforward using DBI and DBD::ODBC.
>
> I am encountering one problem that someone may be able to help me with.
>
> One of the tables in the db has several non-unique columns that are not
> actually used (there are 10-15 columns named "Unused").
>
> When I pull the table def using column_info, I can easily filter these
> out before creating an appropriate table definition in MySQL.
>
> The problem is that when I try to extract the data, the DBD::ODBC driver
>   barfs complaining about the non-unique columns (Unused). This happens
> even when I specifically exclude Unused from the SELECT clause. IWO, I
> use SELECT col_a, col_b FROM table; - not SELECT * FROM table;.

What is the exact error that you get?

Xho

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


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

Date: Mon, 28 Jun 2004 19:12:12 +0200
From: Krisztian VASAS <iron@ironiq.hu>
Subject: Problem with Gtk2 and POE
Message-Id: <2kb1ljF7picU1@uni-berlin.de>


Hello all...


I have a big problem with Gtk2 and POE (or I'm too stupid to the POE)...

Between the POE examples, there is a Gtk Interface (small counter)... 
I've tried to rewrite it in Gtk2, but didn't want to work.

Neither the $kernel->yield("state_name"), nor the 
$session->postback("state_name") works...

The Gtk2 interface starts, but if I press the button, nothing happens. 
If I close the window, perl writes this:
"POE::Kernel's run() method was never called."

I can't understand this, because the first part of the script hasn't 
changed:

POE::Session->create( inline_states =>
			{
			        _start  => \&ui_start,
			   ev_count  => \&ui_count,
			   ev_clear   => \&ui_clear,
			});

But when I press the button, the signal_connect doesn't want to run the 
$session->postback("ev_clear") command...

Can anyone tell me, why?


IroNiQ
-- 
Web: http://ironiq.hu
Email: iron@ironiq.hu
LinuxCounter: #331532


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

Date: Mon, 28 Jun 2004 17:48:18 GMT
From: Rocco Caputo <troc@pobox.com>
Subject: Re: Problem with Gtk2 and POE
Message-Id: <slrnce0mvv.hdf.troc@eyrie.homenet>

On Mon, 28 Jun 2004 19:12:12 +0200, Krisztian VASAS wrote:
>
> Hello all...
>
>
> I have a big problem with Gtk2 and POE (or I'm too stupid to the POE)...
>
> Between the POE examples, there is a Gtk Interface (small counter)... 
> I've tried to rewrite it in Gtk2, but didn't want to work.
>
> Neither the $kernel->yield("state_name"), nor the 
> $session->postback("state_name") works...

Works here.  The program I tested with is nearly the same as the one on
POE's wiki.  I just changed all the "Gtk"s to "Gtk2".  Here's a copy:

#!/usr/bin/perl

use warnings;
use strict;

use Gtk2;
use POE;

POE::Session->create(
  inline_states => {
    _start => \&ui_start,
    ev_count => \&ui_count,
    ev_clear => \&ui_clear,
  }
);

$poe_kernel->run();
exit 0;

sub ui_start {
    my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ];

    $heap->{main_window} = Gtk2::Window->new("toplevel");
    $kernel->signal_ui_destroy( $heap->{main_window} );

    my $box = Gtk2::VBox->new( 0, 0 );
    $heap->{main_window}->add($box);
    $box->show();

    my $label = Gtk2::Label->new("Counter");
    $box->pack_start( $label, 1, 1, 0 );
    $label->show();

    $heap->{counter}       = 0;
    $heap->{counter_label} = Gtk2::Label->new( $heap->{counter} );
    $box->pack_start( $heap->{counter_label}, 1, 1, 0 );
    $heap->{counter_label}->show();

    my $button = Gtk2::Button->new("Clear");
    $button->signal_connect( "clicked", $session->postback("ev_clear") );
    $box->pack_start( $button, 1, 1, 0 );
    $button->show();

    $heap->{main_window}->show();

    $kernel->yield("ev_count");
}

sub ui_count {
    my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
    $heap->{counter_label}->set_text( ++$_[HEAP]->{counter} );
    $kernel->yield("ev_count");
}

sub ui_clear {
    $_[HEAP]->{counter} = 0;
}

__END__

-- 
Rocco Caputo - http://poe.perl.org/




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

Date: 28 Jun 2004 17:19:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Strange Behaviour with Hash???
Message-Id: <cbpjvc$ctq$1@mamenchi.zrz.TU-Berlin.DE>

Fergus Toolan  <fergus.toolan@ucd.ie> wrote in comp.lang.perl.misc:
> Hi all,
> Thanks to everyone who has replyed so far.
> Just to describe it a bit more.
> Both H1 and H2 are hashs of arrays. I know that when I do the 
> assignement that the references will be the same but this desired.

[...]

> We seem to be able to access keys in H1 that were there before the 
> assignment but that are not in H2.
> However judging from the responses so far our problem is not with the 
> assignment itself but it most be something buried in the logic of our 
> creation of H2.
> 
> Oh well back to the toil :-)

I suspect autovivification of hash keys during the buildup of H2.  This
is nothing but a WAG -- if there are also unwanted *values* in the
resulting hash, autovivification is not the cause.  You mention only
unwanted keys with, presumably, undefined values, which would be
consistent with autovivification.

Anno


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

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


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