[27055] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8961 Volume: 10

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

Date: Thu, 16 Feb 2006 03: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           Thu, 16 Feb 2006     Volume: 10 Number: 8961

Today's topics:
    Re: Best way for -h option for script to run perldoc on <edh@example.com>
    Re: FAQ 4.18 Does Perl have a Year 2000 problem?  Is Pe <michael@youramigo.com>
    Re: Merging sparse arrays <abigail@abigail.nl>
    Re: Need help about Build_MatchMany_Function ! <rvtol+news@isolution.nl>
        Overriding a hard coded ISA module xhoster@gmail.com
    Re: Overriding a hard coded ISA module (Anno Siegel)
        PDF:: <SteffenNetz@freenet.de>
    Re: XS - Variable creation <bol@adv.magwien.gv.at>
    Re: XS - Variable creation <sisyphus1@nomail.afraid.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 16 Feb 2006 10:29:45 GMT
From: Ed Hennig <edh@example.com>
Subject: Re: Best way for -h option for script to run perldoc on itself?
Message-Id: <FG8W4TPA38764.770787037@reece.net.au>

Uri Guttman <uri@stemsystems.com> wrote:

>   EH> What are the advantages of using the CPAN POD modules when all I want
>   EH> is to show something that looks like a man page?
> 
> a short list:
> 
> 	$0 isn't alway correct as it can be modified on some OS's
> 
> 	it forks off a process (actually execs) which is slower. but
> 	speed isn't usually an issue here.
> 
> 	perldoc may not be in your path or even installed in
> 	bin. modules are more likely to be where you put them.
> 
> 	the pod modules that do this type of thing can do more than just
> 	run perldoc.
> 
> 	some pod munging modules can even generate the arg parsing stuff
> 	for you from the pod. damian conway wrote such a module.

Interesting points. I only work on *nix-like systems where $0 works
and perldoc is in $PATH, so I've never noticed any of those issues.

> i am sure i could find other reasons. anyhow you do what you want. just
> check out cpan for them. you might be surprised and end up using one of
> them.

I'll take a look. Thanks for the response!




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

Date: Thu, 16 Feb 2006 18:18:08 +1030
From: Michael Brader <michael@youramigo.com>
Subject: Re: FAQ 4.18 Does Perl have a Year 2000 problem?  Is Perl Y2K compliant?
Message-Id: <7kwtfvvj5z.fsf@youramigo.com>

"Jürgen Exner" <jurgenex@hotmail.com> writes:

> PerlFAQ Server wrote:
> [...]
>>
>> 4.18: Does Perl have a Year 2000 problem?  Is Perl Y2K compliant?
>
> By now the new Millenium is 5 years old. Isn't it time to retire this entry?

Not for everybody...

http://ethiopia2000.com/

-- 
Michael Brader                          michael.brader@youramigo.com

Si in Googlis non est, non est


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

Date: 16 Feb 2006 07:24:37 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Merging sparse arrays
Message-Id: <slrndv8a5l.891.abigail@alexandra.abigail.nl>

Samwyse (samwyse@gmail.com) wrote on MMMMDLII September MCMXCIII in
<URL:news:0ZQIf.48417$dW3.26427@newssvr21.news.prodigy.com>:
^^  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, and zeros aren't a concern.  In fact, 
^^  I was a bit surprised to find out that Text::ParseWords returns undef's 
^^  for empty fields; it caused a bit of trouble when I later used join(',', 
^^  ...) to write the merged arrays back to a file.
^^  
^^  I was under the impression that defined-or was a Perl 6 feature.  I 
^^  guess I need to check if my current interpreter supports it.


Defined-or will be in 5.10, is currently in 5.9.3, and there's a patch
available for 5.8.x.



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-


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

Date: Thu, 16 Feb 2006 11:34:53 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Need help about Build_MatchMany_Function !
Message-Id: <dt1o6d.15o.1@news.isolution.nl>

sonet schreef:


Some initial remarks:

> #you can got notspam.lst FROM
> http://se2.program.com.tw/Portal_images/notspam.lst

> #!/usr/local/perl

That should be the first line of you script.
More standard is #!/usr/bin/perl

Missing:

  use strict;

> use warnings;

> my $i   = 0;
> my $nsi = 0;

The $nsi is not needed.

> my @test;

> open( HANDLE, 'notspam.lst' );

  my $infile = 'notspam.lst';
  open( HANDLE, '<', $infile ) or die "$infile: $!";

> while (<HANDLE>)
> {
>    $_ =~ s/\r|\n| //g;

ITYM:
     s/\s+//g;

Regexen work on $_ if not specified otherwise.


>  if ( $_ ne '' && $_ !~ m/\#/ )
>  {
>   $test[ $nsi++ ] = $_;
>  }

ITYM /^#/ and not /#/.

Change to:
   push @test, $_ unless /^$/ or /^#/;

See `perldoc -f push`.



> }
> close(HANDLE);


There is more to say about the rest of your code, but add the 'use
strict;' and apply the other changes, and see if you get any further
yourself.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: 16 Feb 2006 06:47:28 GMT
From: xhoster@gmail.com
Subject: Overriding a hard coded ISA module
Message-Id: <20060216014841.089$Du@newsreader.com>

Is there an elegant way to tell other modules which are ISA some parent
(either directly or indirectly) that they should be ISA something else
instead?

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;
};

## and likewise for other end-use modules.

Doing it this way isn't too awful, but it seems like there should be a
better way.

Thanks,

Xho

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


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

Date: 16 Feb 2006 11:03:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Overriding a hard coded ISA module
Message-Id: <dt1m5b$33m$1@mamenchi.zrz.TU-Berlin.DE>

 <xhoster@gmail.com> wrote in comp.lang.perl.misc:
> Is there an elegant way to tell other modules which are ISA some parent
> (either directly or indirectly) that they should be ISA something else
> instead?

Change their @ISA?

> 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:

I'd try this (untested):

Make your own less buggy Xho::axestype:

    package Xho::axestype;
    use base 'GD::Graph::axestype';

    sub buggy_method {
        # your non-buggy override
    }

    1;

Then, before using GD::Graph, but after its @ISA is set up, do something
like this:

    for ( \ (
        GD::Graph::lines::ISA,
        GD::Graph::points::ISA,
        GD::Graph::linespoints::ISA,
    ) ) {
        $_ eq 'GD::Graph::linespoints' and $_ = 'Xho::linespoints' for @$_;
    } 

That should make the three modules use your improved version.  The
@ISA-modifying code could go in a CHECK- or INIT-block to make sure
everything is loaded when it is called.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Thu, 16 Feb 2006 11:07:37 +0100
From: Steffen Netz <SteffenNetz@freenet.de>
Subject: PDF::
Message-Id: <20060216110737.00004933@sund35>


Hallo,

ich m=F6chte Titel und Keywords aus PDF's extrahieren.
Dazu habe ich das Modul : PDF nutzen.

Ich habe folgendes Programm-ger=FCst:
use PDF::Parse;

$pdf =3D PDF::Parse->new();
$pdf->TargetFile($ARGV[0]);
$pdf->LoadPageInfo;
$info =3D $pdf->GetInfo ("Title");
print $info;

Beim direkten Aufruf kommt die Fehlermeldung:
Can't use string ("8506") as a SCALAR ref while "strict refs" in use
at /sw/opensrc/lib/perl5/site_perl/5.8.3/PDF/Core.pm line 236.

Bei n=E4herer Untersuchung im PDF::Core f=E4llt auf,
das der $offset im File nicht als Referenz an
PDF::Core::PDFGetPrimitive =FCbergeben wird.
Das scheint aber nur der Anfang der Probleme zu sein.

Hat einer das Modul am Laufen, oder sonst Ideen?
Meine Perlversion:
This is perl, v5.8.3 built for sun4-solaris
Die PDF-Version:
Version Installed              1.11      =20

Gru=DF,

Steffen Netz


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

Date: Thu, 16 Feb 2006 10:24:14 +0100
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Re: XS - Variable creation
Message-Id: <1140081855.20121@proxy.dienste.wien.at>

Hi Ilya,

> 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.

IIUC, get_sv() creates a new Perl variable with an empty SV ('undef'
in Perl). But the SV already exists (as SVPV),  I just want to make it
visible from Perl!

Again, thanks for your help, and kind greetings from Vienna,

Ferry

-- 
Ing. Ferry Bolhar
Municipality of Vienna, Department 14
A-1010 Vienna / AUSTRIA
E-mail: bol@adv.magwien.gv.at




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

Date: Thu, 16 Feb 2006 21:56:07 +1100
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: XS - Variable creation
Message-Id: <43f45ac6$0$3363$afc38c87@news.optusnet.com.au>


"Ferry Bolhar" <bol@adv.magwien.gv.at> wrote in message
news:1140081855.20121@proxy.dienste.wien.at...
> Hi Ilya,
>
> > 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.
>
> IIUC, get_sv() creates a new Perl variable with an empty SV ('undef'
> in Perl). But the SV already exists (as SVPV),  I just want to make it
> visible from Perl!
>

Perhaps this simple Inline::C demo helps:

use warnings;

use Inline C => Config =>
    CLEAN_AFTER_BUILD => 0, # see below
    BUILD_NOISY => 1; # see build output

use Inline C => <<'EOC';

SV * foo() {
     SV * ret;
     ret = newSVpv("hello world", 0);
     return ret;
}

EOC

$z = foo();
print $z, "\n";

__END__

Specifying 'CLEAN_AFTER_BUILD => 0' means that the build directory is not
deleted ... and you can then go into that directory and view the xs file
that was generated (and the other generated files too ... though it's the xs
file that you're probably most interested in).

You'll probably also want to look through 'perldoc perlapi' ... though I
guess you already know about it :-)

Cheers,
Rob




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

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


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