[27059] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8963 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 16 18:06:08 2006

Date: Thu, 16 Feb 2006 15:05:06 -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           Thu, 16 Feb 2006     Volume: 10 Number: 8963

Today's topics:
    Re: Best way for -h option for script to run perldoc on <tadmc@augustmail.com>
    Re: Merging sparse arrays <tadmc@augustmail.com>
    Re: Overriding a hard coded ISA module <christoph.lamprecht.no.spam@web.de>
    Re: The inverse problem: generate all instances of a re (See Website For Email)
        Trouble with GD in Perl 5.8.6 <cmarvel@nethere.com>
    Re: Trouble with GD in Perl 5.8.6 <rvtol+news@isolution.nl>
    Re: XML namespaces in (pure) perl parsers? <keshlam-nospam@comcast.net>
    Re: XS - Variable creation <nospam-abuse@ilyaz.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 16 Feb 2006 16:27:49 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Best way for -h option for script to run perldoc on itself?
Message-Id: <slrndv9v35.av1.tadmc@magna.augustmail.com>

Ed Hennig <edh@example.com> wrote:
> Uri Guttman <uri@stemsystems.com> wrote:
>> >>>>> "EH" == Ed Hennig <edh@example.com> writes:
>> 
>>   EH> What's the best or correct way to get a Perl program to handle the -h
>>   EH> option (through getopts) by outputting its own perldoc documentation
>>   EH> to the terminal?
>> 
>>   EH> exec("perldoc " . $0) if ( $option{h} );
>> 
>> there are modules that can do that for you. search cpan for pod stuff.
> 
> If
> 
>   exec("perldoc", $0) if ($option{h});
> 
> works fine, 


Because you have a program named "perldoc" in your path.


> why make things more complicated than necessary? 


So they will work when there is no program named "perldoc" in the path.


> What are the advantages of using the CPAN POD modules when all I want
> is to show something that looks like a man page?


No dependencies on external programs.

Works when the path gets changed.


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


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

Date: Thu, 16 Feb 2006 16:31:51 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Merging sparse arrays
Message-Id: <slrndv9van.av1.tadmc@magna.augustmail.com>

Samwyse <samwyse@gmail.com> wrote:
> Abigail wrote:
>> Samwyse (samwyse@gmail.com) wrote on MMMMDLI September MCMXCIII in
>> <URL:news:oxFIf.30309$F_3.6888@newssvr29.news.prodigy.net>:
>> **  I have two arrays of equal length that contain null values.  I want one 
>> **  array with fewer nulls.
>> 
>> I'd avoid push, and do something like:
>> 
>>     my @t = map {defined $f [$_] ? $f [$_] : $g [$_]} 0 .. $#f;
>> 
>> Or if you have the defined-or operator:
>> 
>>     my @t = map {$f [$_] // $g [$_]} 0 .. $#f;
>> 
>> Note that I didn't use '$f [$_] || $g [$_]', as that will assign the
>> value of @g if the corresponding value of @f is 0, or the empty string
>> (both values are defined, but false).
> 
> In this case, the data is coming from a CSV file, so undefined values 
> are represented by empty strings, 


Then Abigail's note would apply.


> and zeros aren't a concern.  


Yes they are:

   "foo","0","bar"

Then Abigail's note would again apply for the 2nd field there.


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


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

Date: Thu, 16 Feb 2006 23:23:36 +0100
From: Ch Lamprecht <christoph.lamprecht.no.spam@web.de>
Subject: Re: Overriding a hard coded ISA module
Message-Id: <dt2u17$6n4$1@online.de>

xhoster@gmail.com wrote:

> For example, GD::Graph::lines, GD::Graph::points, and
> GD::Graph::linespoints.pm are all subclasses of GD::Graph::axestype.
> 
> I want to subclass GD::Graph::axestype and override a method in it, and
> have that override exist for the three end-use modules.  Currently the way
> I do it is to subclass each of the end-use modules individually:
> 
> package Xho::linespoints;
> use base qw(GD::Graph::linespoints);
> ## GD::Graph is very buggy if numeric X axis are used
> ## without x_min_value and x_max_value being set.
> ## So set them to the pretty choice made by _best_ends
> sub setup_x_step_size_v {
>   my $s=shift;
>   if ( defined $s->{x_tick_number}) {
>     $s->{x_min_value}=$s->{x_min} unless defined $s->{x_min_value};
>     $s->{x_max_value}=$s->{x_max} unless defined $s->{x_max_value};
>   };
>   $s->SUPER::setup_x_step_size_v;
> };

Hi,
I wrote a short example to find out how overriding of a method defined 
in a baseclass can be done using multiple inheritance.
The code works, but I'm sure my approach to replace 'SUPER' is not the 
best one ...

Any suggestions ??

Christoph


use warnings;
use strict;

package Root;
sub new{
   my $class= shift;
   my $self = {};
   return bless $self ,$class ;
}
sub hello{
   print "Root->hello\n";
}
sub say_hi{
   print "Root->say_hi \n";
}

package Root_patch;
sub hello{
   my $self = shift;
   print "Root_patch->hello\n";
   if (my $coderef = $self->find_next('hello')){
     $coderef->($self,@_)
   }
}
sub find_next{
# step through selfs @ISA and return the 1st method 'method_name'
# found after the one defined in the current package
   my ($self,$method_name)= @_;
   my $class = ref $self;
   no strict 'refs';
   my $get_this;
   for my $parent(@{$class."::ISA"}){
     if ($parent eq __PACKAGE__){$get_this = 1; next;}
     if ($get_this && (my $code = $parent->can($method_name))){
       return $code;
     }
   }
   return undef;
}
package Child;
use base qw/Root_patch Root/;

package main;
my $instance = Child->new;
$instance->hello;
$instance->say_hi;

__END__
output:
Root_patch->hello
Root->hello
Root->say_hi
-- 

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"


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

Date: Thu, 16 Feb 2006 10:45:01 -0800
From: "Andrei Alexandrescu (See Website For Email)" <SeeWebsiteForEmail@moderncppdesign.com>
Subject: Re: The inverse problem: generate all instances of a regexp
Message-Id: <IusMr1.167L@beaver.cs.washington.edu>

Randal L. Schwartz wrote:
>>>>>> "bugbear" == bugbear  <bugbear@trim_papermule.co.uk_trim> writes:
> 
> bugbear> http://www.stonehenge.com/merlyn/LinuxMag/col04.html
> 
> And be sure to check out (in the CPAN) Inline::Spew, which came
> from me writing <URL:http://www.stonehenge.com/merlyn/LinuxMag/col57.html>.
> 
> That way, you don't have to copy the code from LM-col04 carefully into your
> program, and you can optimize the compilation from Spew to data structures.

The Spew module is painfully close to what I'd need. May I suggest 
adding a function that generates (perhaps in an iterative manner) *all* 
of the sentences that could be generated by the grammar?


Andrei


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

Date: Thu, 16 Feb 2006 09:23:32 -0800
From: Keith Lee <cmarvel@nethere.com>
Subject: Trouble with GD in Perl 5.8.6
Message-Id: <pan.2006.02.16.17.23.29.714911@nethere.com>

All:
 I have installed the proper GD library and GD.pm for Perl/CGI and still
 am coming up with problems.  I get the following error messages when I
 type in "perl shapes.pl | display -"  in the GD/demos directory.  The
 funny thing is, even though I get these compilation errors, the shapes
 program still runs.  Any ideas about how to stop said errors?

Can't locate GD/Image.pm in @INC 
Can't locate loadable object for module GD in @INC


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

Date: Thu, 16 Feb 2006 20:30:49 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Trouble with GD in Perl 5.8.6
Message-Id: <dt2nli.1gs.1@news.isolution.nl>

Keith Lee schreef:

>  I have installed the proper GD library and GD.pm for Perl/CGI and
>  still am coming up with problems.

How did you install them? 

  http://www.cpan.org/misc/cpan-faq.html#How_install_Perl_modules 

  perl -MCPAN -e 'install GD'


-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Thu, 16 Feb 2006 11:22:15 -0500
From: Joseph Kesselman <keshlam-nospam@comcast.net>
Subject: Re: XML namespaces in (pure) perl parsers?
Message-Id: <43f4a704$1@kcnews01>

bugbear wrote:
> You're right, and yet wrong. Many modern perl parsers don't.

OK, we can quibble about whether they can claim to be "modern" in that 
case as opposed to just "obsolete but still in use" (<sigh/>)...

Unfortuately I don't know the perl toolspace, so I can't offer opinions 
on which ones you should be switching to; I'd have to start with a 
websearch, and you can do that just about as effectively yourself.

Hopefully someone else can point you in the right direction.

-- 
Joe Kesselman / Beware the fury of a patient man. -- John Dryden


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

Date: Thu, 16 Feb 2006 20:45:33 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: XS - Variable creation
Message-Id: <dt2o9d$2hkk$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Ferry Bolhar
<bol@adv.magwien.gv.at>], who wrote in article <1140081855.20121@proxy.dienste.wien.at>:
> Hi Ilya,

AFAIU, you sent Blind-CC (CC which is not marked as a copy of a
posting).  This might have lead to me needing to double-answer your
message - first by mail, then on Usenet.  Please do not do this.

> > get_sv(): TRUE argument will create.

> My situation is as follows: a routine returns a SV and I want to make
> it available from Perl, (currently) mainly for debugging purposes.

I would do it like this: return a reference from XS.  Do the
assignment in Perl code wrapper (via *name = reference).  (Not hard to
do from XS, but somebody spent some time to make it *especially
simple* from Perl code; why not use it?)

Hope this helps,
Ilya


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

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


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