[30003] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1246 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 31 18:09:46 2008

Date: Thu, 31 Jan 2008 15:09: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, 31 Jan 2008     Volume: 11 Number: 1246

Today's topics:
    Re: "negative" regexp <uri@stemsystems.com>
    Re: "negative" regexp <uri@stemsystems.com>
    Re: "negative" regexp <bik.mido@tiscalinet.it>
    Re: how to remove blocks between nested brackets <abigail@abigail.be>
    Re: How would I create a Regular Expression to check <tzz@lifelogs.com>
        LaTeX rendering <bm3719@gmail.com>
    Re: LaTeX rendering <smallpond@juno.com>
    Re: LaTeX rendering <bik.mido@tiscalinet.it>
    Re: Magic for object constructor wanted <bik.mido@tiscalinet.it>
    Re: Magic for object constructor wanted <koszalekopalek@interia.pl>
    Re: Magic for object constructor wanted <m@rtij.nl.invlalid>
    Re: Obscure baffling "module not exported" error: can s <attn.steven.kuo@gmail.com>
        Obscure baffling "module not exported" error: can someo <news@lawshouse.org>
    Re: Obscure baffling "module not exported" error: can s <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: Obscure baffling "module not exported" error: can s <news@lawshouse.org>
    Re: ssh into remote nodes, do mulitple commands <glex_no-spam@qwest-spam-no.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 31 Jan 2008 16:11:33 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: "negative" regexp
Message-Id: <x7prvi3rgq.fsf@mail.sysarch.com>

>>>>> "PV" == Petr Vileta <stoupa@practisoft.cz> writes:

  PV> No, I mean not ideal for using universally. I have concrete goal and I
  PV> use as minimal  resource as possible. For example if I want to extract
  PV> clicable email addresses from html source I need to extract all
  PV>     /href=['"]*mailto:\s*(.+?)['"\s>/
  PV>  only.

besides the typo (no close ] on the right), that wouldn't always
work. it allows for an open ' and a closing " which is wrong. it doesn't
handle html comments which shouldn't be parsed for email
addresses. there are other problems with it that i can't get into. so
even a 'simple' thing like that is much harder to extract with a regex
than you think. use a module designed and tested to parse html and email
addresses. it is actually simpler coding from your point of view and
correct as well! and correct beats efficient every day.

uri

  PV> HTML:Parser and WWW:Mechanize are good modules but in many case these
  PV> are "too big gun" :-)

better a big accurate gun than a tiny pistol with no accuracy. you might
even shoot your eye out!

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Architecture, Development, Training, Support, Code Review  ------
-----------  Search or Offer Perl Jobs  ----- http://jobs.perl.org  ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Thu, 31 Jan 2008 16:13:14 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: "negative" regexp
Message-Id: <x7lk663rdx.fsf@mail.sysarch.com>

>>>>> "PV" == Petr Vileta <stoupa@practisoft.cz> writes:

  PV> Tad J McClellan wrote:
  >> Petr Vileta <stoupa@practisoft.cz> wrote:
  >> 
  >> 
  >>> $html=~s/<\!\-\-.+?\-\->//sig;
  >> 
  >> 
  >> Unnecessary backslashes make your code much harder to read
  >> and understand. You should backslash only when you actually
  >> need to.
  >> 
  >> There is not much point in ignoring case when your pattern
  >> does not contain any letters...
  >> 
  >> 
  >> $html =~ s/<!--.+?-->//sg;
  PV> Yes, you are right, but O'Reilly book "Programin Perl" say "... any
  PV> other escaped character is character itself". Maybe this is not
  PV> correct cite, I have Czech version. In other word the character - is
  PV> sometime "range operator" say in case [a-z] and character ! sometime
  PV> mean "not". So for to be sure a character is a character but not
  PV> operator I'm used to escape all possible ambiguous characters ;-)

that is chicken programming. it leads to noise and potentially buggy
programs. i wouldn't accept it for any production code or code that i
review.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Architecture, Development, Training, Support, Code Review  ------
-----------  Search or Offer Perl Jobs  ----- http://jobs.perl.org  ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Thu, 31 Jan 2008 21:59:36 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: "negative" regexp
Message-Id: <lad4q3pj01mi1ug66p7rorhbuapho11st8@4ax.com>

On Thu, 31 Jan 2008 15:05:35 +0100, "Petr Vileta"
<stoupa@practisoft.cz> wrote:

>No, I mean not ideal for using universally. I have concrete goal and I use as 
>minimal  resource as possible. For example if I want to extract clicable email 
>addresses from html source I need to extract all

Do not misunderstand me: I also use custom rolled regexen to *extract*
some info from specific pages. Since the kind of data I need depends
on the actual structure of the pages, using a real parser would still
make the program fail if the structure were to change, for example.
OTOH if I need to extract links -a classic task- from heterogeneous
pages, then a parser is best suited. Do not make confusion between
*extracting* needs, and *parsing* needs, although there can be
superimpositions.

I was *just* commenting on you claim that HTML parsing modules "build
large hashes" which IMHO is not (necessarily) the case. And I'm still
asking you for some evidence.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 31 Jan 2008 16:20:16 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: how to remove blocks between nested brackets
Message-Id: <slrnfq3ta0.asf.abigail@alexandra.abigail.be>

                                           _
Si (silicium_at_h@rmony-p.ath.cx) wrote on VCCLXVI September MCMXCIII in
<URL:news:47a1c3a1$0$902$ba4acef3@news.orange.fr>:
:)  Beeing new to perl and not wanting to learn using it like assembler, I 
:)  need to delete parts of a single line (possibly long) that are enclosed 
:)  between nested brackets:
:)  
:)  abcd efgh [ij: 123-[456]-klm; nop-789]; qrst; uvw [xyz: 98-76-[ef]; gh; 
:)  ijkl] (mnop)
:)  
:)  The comments between [] must be discarded to split with ';' delimiter.
:)  The expected result is:
:)  array[0] == "abcd efgh"
:)  array[1] == "qrst"
:)  array[2] == "uvw (mnop)"
:)  
:)  Thanks for a magic formula.

The magic formula is:  \s*(\[[^][]*+(?:(?1)[^][]*+)*\])


    my $_ = "abcd efgh [ij: 123-[456]-klm; nop-789]; qrst; uvw " .
            "[xyz: 98-76-[ef]; gh;ijkl] (mnop)";

    s {\s*(\[[^][]*+(?:(?1)[^][]*+)*\])} {}g;

    my @array = split /;\s*/;

    say qq {array[$_] == "}, $array [$_], qq {"} for 0 .. $#array;

    __END__
    array[0] == "abcd efgh"
    array[1] == "qrst"
    array[2] == "uvw (mnop)"



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: Thu, 31 Jan 2008 15:47:17 -0600
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How would I create a Regular Expression to check
Message-Id: <868x25zmze.fsf@lifelogs.com>

On Thu, 31 Jan 2008 13:46:10 +0000 (UTC) dkcombs@panix.com (David Combs) wrote: 

DC> In article <86lk76vily.fsf@lifelogs.com>,
DC> Ted Zlatanov  <tzz@lifelogs.com> wrote:
>> On Thu, 03 Jan 2008 17:22:00 +0100 Christian Winter <thepoet_nospam@arcor.de> wrote: 
>> 
CW> Nathan wrote:
>>>> How would I create a Regular Expression to check Street address for
>>>> any of the below items:
>> 
CW> The short answer: you can't. At least not one single, reasonably
CW> short regex that can cover it in one go. I'd simply iterate
CW> over all the possibilities and compare each one to the street address,
CW> like:
>> 
>> An alternate approach is to use Parse::RecDescent.  It's really good in
>> my experience for parsing this kind of disparate input, and will
>> organize it for you (so you can tell that the street adress was in
>> Spanish, for example).
>> 
>> Ted

DC> A late response/request.  *If* you find doing that pretty easy and 
DC> quick to do, *please* show us how you'd do it.

DC> I've read the doc on it, and come away with neither facility nor understanding
DC> for actually being able to use it in a real problem.

I wrote a tutorial on P::RD a while ago, and it should still be valid.
IBM dW seems to be down right this moment, use the Google cache if you
have to.  I don't mention auto_tree, which is really handy if you want
to process the data yourself.

http://www.ibm.com/developerworks/library/l-perl-speak.html

Here's another good one (and many others will come up in a web search):

http://www.perl.com/pub/a/2001/06/13/recdecent.html

Are you asking specifically for the mailing address example originally
posted to be implemented in P::RD, or do you need more information on
how to use P::RD for your own applications?  I can certainly give a
P::RD grammar for the full list of address rules, but it's tedious work
to implement every rule the OP wanted and I don't want to spend hours of
my time doing it just to prove it's easy.

Thanks
Ted


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

Date: Thu, 31 Jan 2008 08:14:57 -0800 (PST)
From: "Bruce C. Miller" <bm3719@gmail.com>
Subject: LaTeX rendering
Message-Id: <a10cc85e-3417-4ad2-87db-d411e43c1ecc@d21g2000prf.googlegroups.com>

Can anyone recommend a Perl/CGI script that will generate images
dynamically based upon and input LaTeX string? I would prefer one that
doesn't have a lot of dependencies, if possible. My only requirements
is that it supports foreground/background coloring and communative
diagrams.


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

Date: Thu, 31 Jan 2008 11:19:17 -0800 (PST)
From: smallpond <smallpond@juno.com>
Subject: Re: LaTeX rendering
Message-Id: <95cd6ca8-6e22-4712-b787-1536ee321260@i29g2000prf.googlegroups.com>

On Jan 31, 11:14 am, "Bruce C. Miller" <bm3...@gmail.com> wrote:
> Can anyone recommend a Perl/CGI script that will generate images
> dynamically based upon and input LaTeX string? I would prefer one that
> doesn't have a lot of dependencies, if possible. My only requirements
> is that it supports foreground/background coloring and communative
> diagrams.


Can it call tex?


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

Date: Thu, 31 Jan 2008 22:12:46 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: LaTeX rendering
Message-Id: <c4e4q3haja6mc6b5g04qb2h0rghk686t45@4ax.com>

On Thu, 31 Jan 2008 08:14:57 -0800 (PST), "Bruce C. Miller"
<bm3719@gmail.com> wrote:

>Can anyone recommend a Perl/CGI script that will generate images
>dynamically based upon and input LaTeX string? I would prefer one that
>doesn't have a lot of dependencies, if possible. My only requirements
>is that it supports foreground/background coloring and communative
>diagrams.

Commutative diagrams are not that easy. Just consider that there are
quite some packages to draw them (I like Paul Taylor's for the UI, but
I blame its policy) and they generally require some work from a
graphics driver or an especially designed set of fonts. Anyway you may
check

http://tex.mendelu.cz/
http://www.tlhiv.org/cgi-bin/LaTeXpreviewer/index.cgi

And see how they did it.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 31 Jan 2008 17:56:33 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Magic for object constructor wanted
Message-Id: <jan3q3t01dqemul4gpirk8din4hm1c5t8l@4ax.com>

On Wed, 30 Jan 2008 22:05:45 -0800 (PST), Koszalek Opalek
<koszalekopalek@interia.pl> wrote:

>My code creates new objects and then populates them with
>data, like this:
>
>my $joe = Dude->new();
>my $tom = Dude->new();
>my $ann = Dude->new();
>my $jane = Dude->new();
>
>$joe->fill(
>	name => "joe",
>	friends => [ $ann, $tom ]
>);
>
>$jane->fill(
>	name => "jane",
>	friends => [ $ann ]
>);
>
>You will notice that the name field is always the same as
>the variable that stores the object. What kind of magic
>would I have to use in the constructor (or in the fill()
>method) so that the name of the object does not have
>to be specified explicitly? In other words, I would like to
>be able to say:
>
>$joe->fill(
>	friends => [ $ann, tom ]
>);
>
>$jane->fill(
>	friends => [ $ann ]
>);
>
>and still have the name field set. This saves typing and
>makes sure the variable name and the name field match.
>
>Is this possible?

It *may* be possible with some XS (or PadWalker, but I'm not sure) but
it's horrible, anyway. Actually, your problem is *similar* albeit not
exactly the same, as the variable-in-variable-name one: in that case
one is generally told that symrefs are strictly speaking the solution,
but to use a hash instead. And that seems the viable solution here
too: you have a set of duded identified by their name. Thus, you don't
want the identification bit to be a variable name, since a hash index
is more appropriate. There are tons of ways to do so, but one that
springs to mind is to make new() accept a name, which is reasonable.
Thus

  my %dude = map { $_ => Dude->new( name => $_ ) }
      qw/joe tom ann jane/;

Then

  $dude{joe}->fill( friends => [map $dude{$_}, qw/ann tom/] );
  # etc.

Of course you may factor hide all the details behind convenient helper
subs.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 31 Jan 2008 09:06:23 -0800 (PST)
From: Koszalek Opalek <koszalekopalek@interia.pl>
Subject: Re: Magic for object constructor wanted
Message-Id: <be123f45-13f6-444c-a5bf-f2f692b68740@l32g2000hse.googlegroups.com>

On Jan 31, 3:18=A0pm, bugbear <bugbear@trim_papermule.co.uk_trim> wrote:
> Koszalek Opalek wrote:
>
> my @people =3D (
> =A0 =A0 =A0Dude->new("joe"),
> =A0 =A0 =A0Dude->new("tom"),
> =A0 =A0 =A0Dude->new("ann").
> =A0 =A0 =A0Dude->new("jane")
> );
>
> Alternatively/additioanaly, you might have a "group"
> class (set of Dudes) that allow Dudes t be found by name.

No, then instead of saying
   $ann->fill( friends =3D> [ $tom, $tim] );
I'd have to say smth like
   $ann->fill( friends =3D> Friends->findByName("tom", "tim") );


> If your set of names becomes large, declaring all the
> variables implied by your original approach becomes ugly.

It will never get very large.

You might be thinking Dudes are some jerks from a database.
In fact they are tokens. The module user has two define
Dudes (tokens) and relationships between them and the
module will produce a parse tree. (Specifying Dudes
using a BNF grammar is not scheduled for this release:-)

Koszalek


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

Date: Thu, 31 Jan 2008 23:19:59 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Magic for object constructor wanted
Message-Id: <pan.2008.01.31.22.19.59@rtij.nl.invlalid>

On Thu, 31 Jan 2008 04:49:44 -0800, Koszalek Opalek wrote:

> On Jan 31, 8:39 am, Martijn Lievaart <m...@rtij.nl.invlalid> wrote:
> 
>> Sure. Just don't put the objects in separate variables, put them in a
>> hash.
>>
>> Even better, bless the hash, iow make it its own class.
>>
>> Then you get something like:
>>
>> use Friends;
> 
> I'm afraid that misses the point (or I have misunderstood you).  I do
> not want to bless my objects into Friends. I want to bless each one into
> a signle Dude so that I can do things like
> 
> 	$joe->whoami()

	$friends->{"joe"}->whoami();

I think you misunderstood me.

> 
> (And I do not want to rewrite code, that takes it for granted that $joe,
> $tim, and $ann have all been blessed into Dude's.)

That's different. That's a requirement that's hard to meet with your 
other wish.

>> What you also can do, is store the name of the Dude in the Dude object.
>> This is better design anyhow, but does not save you the extra
>> redundancy of specifying the name twice:
>>
>> my $joe = Dude->new("joe");
>> my $tom = Dude->new("tom");
>> my $ann = Dude->new("ann");
>> my $jane = Dude->new("jane");
> 
> 
> That is not different from what I originally posted except that
> (name=>"joe") has been moved from fill() to new().

It's better design, that's what different. A Dude normally does not get a 
name once he gets friends, he has a name, so the constructor should set 
the name.

M4


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

Date: Thu, 31 Jan 2008 13:28:34 -0800 (PST)
From: "attn.steven.kuo@gmail.com" <attn.steven.kuo@gmail.com>
Subject: Re: Obscure baffling "module not exported" error: can someone help me  find the cause?
Message-Id: <ba52dffc-4db4-4835-8bea-f9ab21c60d98@k2g2000hse.googlegroups.com>

On Jan 31, 12:20 pm, Henry Law <n...@lawshouse.org> wrote:


(snipped)

>
> Now for the description of the code itself, which is a bit involved,
> despite my having condensed it down to its bare essentials.  If you're
> prepared to help me make sense of this thenhttp://www.lawshouse.org/perl/Problem.jpgshows the thing
> diagrammatically, with arrows drawn on. You can just about read the code
> in the image too.
>
> There are three modules: NFBT::ServerLib, NFBT::Utilities::Common and
> NFBT::Utilities::Server. There is some requirement in them for
> subroutines out of one or more of the others.
>

(snipped)

First of all, you have a couple of modules that mutually use
each other, namely:

NFBT::ServerLib and
NFBT::Utilities::Server

this is generally a bad idea and you should consider refactoring;
see the discussion here:

http://www.perl.com/pub/a/2000/07/p5pdigest/THISWEEK-20000709.html#Mutual_use

Remember that use statements are collected into the BEGIN block (even
if
you embed them inside a subroutine) to be evaluated at compile-time
-- see 'perldoc perlmod'.

So, I'd suggest that you refactor.  A quick "work-around" would be
that
in NFBT::Utilities::Server, you change

use NFBT::ServerLib

to

require NFBT::ServerLib;
import ServerLib (qw/write_xml_twig/);

in which case:

#!/usr/bin/perl
use strict;
use warnings;
use NFBT::Utilities::Server qw ( shadow_conv );

print "This is the test routine $0\n";
shadow_conv();

ought to run as expected (because 'require', unlike 'use'
is evaluated at run-time).

--
Hope this helps,
Steven


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

Date: Thu, 31 Jan 2008 20:20:25 +0000
From: Henry Law <news@lawshouse.org>
Subject: Obscure baffling "module not exported" error: can someone help me find the cause?
Message-Id: <1201810818.199.0@iris.uk.clara.net>

I have a bizarre problem with packages and I'm hoping that someone can 
help me find out what I'm doing wrong because I'm utterly stumped.

The error is "not exported" for something that quite clearly is exported 
(details follow).  The error disappears when one of several particular 
lines is deleted or commented out, one of which refers to a different 
Perl module altogether, not used anywhere in any of the code except for 
the "use" statement.  And yet that completely unused module is specific 
to the error: simply replacing it with another, equally unused, module 
causes the error to disappear.  Again, more details below.

It's the most perplexing thing I've seen in all my years of debugging 
hardware and software systems and I'm forced to the conclusion that 
there's some corruption in the Perl installation itself, especially 
since the code compiles clean on another machine at ostensibly the same 
level (though the offending machine is newly-built). If someone can even 
point me in the direction of something to look at or try I'd be grateful.

Now for the description of the code itself, which is a bit involved, 
despite my having condensed it down to its bare essentials.  If you're 
prepared to help me make sense of this then 
http://www.lawshouse.org/perl/Problem.jpg shows the thing 
diagrammatically, with arrows drawn on. You can just about read the code 
in the image too.

There are three modules: NFBT::ServerLib, NFBT::Utilities::Common and 
NFBT::Utilities::Server. There is some requirement in them for 
subroutines out of one or more of the others.

A small test program "trynfbt.pl" includes "shadow_conv" from 
NFBT::Utilities::Server.  The shadow_conv subroutine in 
Utilities::Server imports a subroutine from ServerLib, which in turn 
imports ":all: from Utilities::Common as well as the same shadow_conv 
sub from Utilities::Server.  (I hope you're following this).  The last 
piece of the jigsaw is that Utilities::Common imports XML::Twig::XPath.

Running the test program trynfbt.pl gives (These line numbers may not be 
right because I knocked out blank lines and CR's to make the code 
smaller to post)

  "shadow_conv" is not exported by the NFBT::Utilities::Server module
  Can't continue after import errors at 
/usr/lib/perl5/site_perl/5.8.6/NFBT/ServerLib.pm line 28
  BEGIN failed--compilation aborted at 
/usr/lib/perl5/site_perl/5.8.6/NFBT/ServerLib.pm line 28.
  Compilation failed in require at 
/usr/lib/perl5/site_perl/5.8.6/NFBT/Utilities/Server.pm line 22.
  ... and three other lines that tell us no more.

But shadow_conv *is* exported, unless my brain is addled.
And removing any of the following lines makes the code run:

   The import of Utilities::Common(':all')
   The import of XML::Twig::XPath
   .. and, of course, the other "use" statements.

Replacing XML::Twig::XPath with something else - I tried XML::Simple and 
even File::Basename - also makes the code run clean; it has to be that 
XML module despite the fact that it's never used. Eh?

Lastly here is the actual code from the three modules and the test 
program.  You might find the graphic easier ...

Test Program
============
#!/usr/bin/perl

use strict;
use warnings;

use NFBT::Utilities::Server qw ( shadow_conv );

print "This is the test routine $0\n";


The three modules
=================
------------------------------------------------------
package NFBT::ServerLib;

use 5.008;
use strict;
use warnings;

require Exporter;
our @ISA = qw(Exporter);

our %EXPORT_TAGS = ( 'all' => [ qw(
	 write_xml_twig
) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'}}, qw(
	 write_xml_twig
	) );

print "This is NFBT::ServerLib\n";


sub write_xml_twig {
     # The original write_xml_twig required several subroutines from
     # Utilities::Common and also 'shadow_conv'
     # Comment either of these out, problem disappears
     use NFBT::Utilities::Common ":all";
     use NFBT::Utilities::Server qw(shadow_conv);  # "not exported" 
error here
     print "This is write_xml_twig in package NFBT::ServerLib\n";
}

1;

--------------------------------------------------
package NFBT::Utilities::Common;

use 5.008;
use strict;
use warnings;

require Exporter;
our @ISA = qw(Exporter);

our %EXPORT_TAGS = ( 'all' => [ qw(
	 find_bkfile_by_id
) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'}}, qw(
	 find_bkfile_by_id
	) );

sub find_bkfile_by_id {
   print "This is subroutine find_bkfile_by_id in package 
NFBT::Utilities::Common\n";
   use XML::Twig::XPath;   # Comment this out, problem disappears.  It 
has to be
   # XML::Twig::XPath, apparently.  XML::Simple and File::Basename cause 
the problem to
   # disappear.
}

1;

------------------------------------------------------
package NFBT::Utilities::Server;

use 5.008;
use strict;
use warnings;

require Exporter;
our @ISA = qw(Exporter);

our %EXPORT_TAGS = ( 'all' => [ qw(
	 shadow_conv
) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'}}, qw(
	 shadow_conv
	) );

sub shadow_conv {
   # The original shadow_conv used write_xml_twig
   use NFBT::ServerLib qw(write_xml_twig); # Comment this out, problem 
disappears
   print "This is subroutine shadow_conv in package 
NFBT::Utilities::Server\n";
}

1;

-- 

Henry Law            Manchester, England


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

Date: Thu, 31 Jan 2008 20:55:56 +0000
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Obscure baffling "module not exported" error: can someone help me find the cause?
Message-Id: <47a235dd$0$867$ba4acef3@news.orange.fr>

Henry Law wrote:
> I have a bizarre problem with packages and I'm hoping that someone can 
> help me find out what I'm doing wrong because I'm utterly stumped.
> 
> The error is "not exported" for something that quite clearly is exported 
> (details follow).  The error disappears when one of several particular 
<snip>

> There are three modules: NFBT::ServerLib, NFBT::Utilities::Common and 
> NFBT::Utilities::Server. There is some requirement in them for 
> subroutines out of one or more of the others.
You appear to have circular dependencies between these modules, and I'd 
guess that the mutual importing is confusing the import/export mechanism.

There is a brief discussion at

http://www.perlmonks.org/?node_id=473692

I'd try breaking the circular dependencies for a start.



> package NFBT::ServerLib;
<snip>
> sub write_xml_twig {
>     # The original write_xml_twig required several subroutines from
>     # Utilities::Common and also 'shadow_conv'
>     # Comment either of these out, problem disappears
>     use NFBT::Utilities::Common ":all";
>     use NFBT::Utilities::Server qw(shadow_conv);  # "not exported" error 
> here
>     print "This is write_xml_twig in package NFBT::ServerLib\n";
> }

This is an unrelated issue, but "use"ing happens at compile-time. 
Putting the use statement inside the subroutine does not limit its scope 
or control when it is executed. perldoc -f use has the gory details.

Mark


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

Date: Thu, 31 Jan 2008 22:48:54 +0000
From: Henry Law <news@lawshouse.org>
Subject: Re: Obscure baffling "module not exported" error: can someone help me  find the cause?
Message-Id: <1201819727.66893.0@despina.uk.clara.net>

attn.steven.kuo@gmail.com wrote:

> First of all, you have a couple of modules that mutually use
> each other, namely:
> 
> NFBT::ServerLib and
> NFBT::Utilities::Server
> 
> this is generally a bad idea and you should consider refactoring;
> see the discussion here:
> 
> http://www.perl.com/pub/a/2000/07/p5pdigest/THISWEEK-20000709.html#Mutual_use

Steven, and Mark Clements in another post, thank you very much.  Even 
the little I knew about how Perl programs actually hurl themselves into 
action should have pointed me to the fact that this kind of circular 
"use"-ing isn't a good idea.  I'll have a go at some refactoring; if 
that doesn't work (sounds like intellectual heavy lifting) then I might 
resort to using BEGIN blocks or "require".

But one more thing: can you think of a reason why this problem has 
suddenly hit?  I'm doing a test installation (having written a configure 
program to produce a Makefile) on a fresh machine, running FC6 (Perl 
5.8.8 but I don't have a perl -v handy), but the code is built on my 
development machine, FC5, also Perl 5.8.8, on which it runs perfectly, 
circular references notwithstanding.  But I'll bash on with the 
refactoring anyway.

-- 

Henry Law            Manchester, England


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

Date: Thu, 31 Jan 2008 10:12:08 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: ssh into remote nodes, do mulitple commands
Message-Id: <47a1f359$0$498$815e3792@news.qwest.net>

Nene wrote:
> Hello,
> 
> I'm trying to use Net::SSH to ssh into 3 nodes and move/copy files
> with File::Copy. For now, I scripted it  to find files of a certain
> age and move them.
> The $cmd variable is working, but when I try to move the files, it
> errors with copy failed. Please critique or suggest a better way.
[...]
> sshopen2("$user\@$host", *READER, *WRITER, "$cmd") || die "ssh: $!";
> print "Connected to $host\n";
> 
> while (<READER>) {
> 
> if  ( $_ ) {
> use File::Copy;
> 
> move("/tmp/rod","/tmp/nasty") or die "Copy failed: $!";
> 
> }

You're 'use'ing File::Copy on the machine that's running the script, not 
on the remote host.  So your 'move' is trying to move those files on the
host machine, not $host.

Probably easiest to just do "mv /tmp/rod /tmp/nasty" in another sshopen2 
or better would be to modify the find command to move the files as
part of the exec, instead of ls -lt -- which is sort of useless.


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

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


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