[22353] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4574 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 16 21:05:43 2003

Date: Sun, 16 Feb 2003 18: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           Sun, 16 Feb 2003     Volume: 10 Number: 4574

Today's topics:
    Re: $^S == 0 inside eval (v5.6.1) (aka ? the Platypus)
    Re: Compiling Msql-Perl adapter <eric.ehlers@btopenworld.com.nospam>
        Correct way to check for errors during readline()? <scriptyrich@yahoo.co.uk>
    Re: DBI seg fault <bongie@gmx.net>
    Re: How are named unary operators that take $_ created? (J. Romano)
    Re: How are named unary operators that take $_ created? (Anno Siegel)
    Re: join or .= -- which is faster? <erutiurf@web.de>
    Re: join or .= -- which is faster? <REMOVEsdnCAPS@comcast.net>
        Malformed UTF-8 character  <no@spam.me>
    Re: Perl dies silently. <tassilo.parseval@post.rwth-aachen.de>
    Re: program contol (Tad McClellan)
    Re: program contol <d.borland@ntlworld.com>
        Sharing Variables and Functions Across Modules <hal@thresholddigital.com>
    Re: Sharing Variables and Functions Across Modules (Tad McClellan)
    Re: use lib Apache->server_root_relative('lib/perl'); <tassilo.parseval@post.rwth-aachen.de>
    Re: use lib Apache->server_root_relative('lib/perl'); <abigail@abigail.nl>
    Re: Win32::NetResource::GetSharedResources (Tad McClellan)
    Re: Win32::NetResource::GetSharedResources <sapbasis2003@netscape.net>
    Re: Win32::NetResource::GetSharedResources (Tad McClellan)
        x letters in y also in w. (dansan)
    Re: x letters in y also in w. (Tad McClellan)
    Re: x letters in y also in w. <bwalton@rochester.rr.com>
    Re: x letters in y also in w. (Jay Tilton)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 16 Feb 2003 21:33:26 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@dformosa.zeta.org.au>
Subject: Re: $^S == 0 inside eval (v5.6.1)
Message-Id: <slrnb5015n.8i4.dformosa@dformosa.zeta.org.au>

On 16 Feb 2003 04:32:50 -0800, Paul Wood <paul@torporific.org> wrote:

[...]

>> If you can't tell the difference between {} and (), make your text
>> bigger, or use a different font.
> 
> Hmm. My mistake. The documentation in perlvar isn't very clear on the
> subject, however.
> 
> So how is it possible to tell if you're inside an eval { } ?
> 
> The situation I'm using this in is a CORE::GLOBAL::die override... I
> want to use eval { } to catch exceptions but if one is uncaught then
> it shouldn't die() but rather print a message to STDOUT and exit(0);

Why not wrap it in a big eval{} instead?



-- 
Please excuse my spelling as I suffer from agraphia. See
http://dformosa.zeta.org.au/~dformosa/Spelling.html to find out more.
Free the Memes.


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

Date: Sun, 16 Feb 2003 21:05:17 +0000 (UTC)
From: "eric" <eric.ehlers@btopenworld.com.nospam>
Subject: Re: Compiling Msql-Perl adapter
Message-Id: <b2oued$ik$1@helle.btinternet.com>

"Jared Subman" <jaredsubman@removethis.yahoo.com> wrote in message
news:Xns9321595E7683Djaredsubmannospamyah@127.0.0.1...
> I am trying to compile the Msql-Perl 1.17 adapter on a Solaris 8
> Sunfire 880 and I got the following error message when I tried to run
> "make".  The "perl Makefile.pl" command worked fine.
>
> I received this message when trying run 'make':
> cc -c -I/usr/local/msql3/include  -xO3 -xdepend -DVERSION=\"1.1702\"
> -D XS_VERSION=\"1.1702\" -KPIC
> -I/usr/perl5/5.00503/sun4-solaris/CORE
> Msql.c
> sh: cc: not found

there is no compiler (cc binary) in your $PATH.  if you can't run the above
command at the command line then make won't be able to run it either.

>  *** Error code 1
>  make: Fatal error: Command failed for target `Msql.o'
>
> I then read that you need to use the same version of gcc which you
> compiled Perl with to compile the adapter, so I downloaded and
> compiled 5.6.1, but now I am getting this message when running "make"
> on the adapter.

well done for downloading and compiling perl - always a good thing to be
able to do - why not go with 5.8 as it's the most recent stable release.

> gcc -c  -I/usr/local/msql3/include  -fno-strict-aliasing -
> D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O    -DVERSION=\"1.1702\"
> -DXS_VERSION=\"1.1702\" -fPIC "-I/usr/local/lib/perl5/5.8.0/sun4-
> solaris/CORE"   Msql.c
> Msql.xs: In function `XS_Msql__Statement_fetchinternal':
> Msql.xs:274: `sv_undef' undeclared (first use in this function)

sv_undef has been replaced with PL_sv_undef in perl versions 5.6 and later.
the package you are trying to install is out of date, try getting a more
recent version from CPAN.  if you must compile old XS code under perl 5.6+,
either replace "sv_undef" with "PL_sv_undef" in the xs file, or instead of
the "perl Makefile.pl" command do:

perl Makefile.PL POLLUTE=1

HTH
-eric




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

Date: Sun, 16 Feb 2003 20:15:20 +0000
From: Rich <scriptyrich@yahoo.co.uk>
Subject: Correct way to check for errors during readline()?
Message-Id: <b2oref$n17$1@newsg3.svr.pol.co.uk>

Hello

perldoc -f readline states:

  "In scalar context, each call reads and returns the next line,
   until end-of-file is reached, whereupon the subsequent call
   returns undef."

But what happens if an error occurs during a read? Does readline return 
undef in this scenario as well? I'm presuming you therefore have to test $! 
to determine whether an error condition or end of file has been reached?

I'm writing a file module that consistently throws exceptions on file 
errors, so would something as simple as the following therefore be correct:

  sub readline
  {
    my $this = shift;
    my $line = CORE::readline($this->filehandle);

    Ridas::Exception::File->throw("readline failed: $!", $this) if $!;

    return $line;
  }

Many thanks,
-- 
Rich
scriptyrich@yahoo.co.uk


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

Date: Mon, 17 Feb 2003 01:06:43 +0100
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: DBI seg fault
Message-Id: <1180284.rpoKaLa5sr@nyoga.dubu.de>

Tad McClellan wrote:
> Todd Smith <smittod@auburn.edu> wrote:
>> $user="root";
> 
>> $dbh = DBI->connect($dsn, $user, $password) or die "Error...
> 
> Why must you be the superuser?

This is the mysql user and not related to the system user.

That said, the root user on mySQL often has all privileges regarding
database operations, including the right to shutdown the database
server process or drop any tables or even databases, so one should
still be careful about which SQL statements to use - or just create
another mySQL user with less privileges.  :-)

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Interesting Error Messages #21:
DYNAMIC LINKING ERROR: Your mistake is now everywhere. 



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

Date: 16 Feb 2003 11:17:36 -0800
From: jl_post@hotmail.com (J. Romano)
Subject: Re: How are named unary operators that take $_ created?
Message-Id: <b893f5d4.0302161117.42713215@posting.google.com>

Malte Ubl <ubl@schaffhausen.de> wrote in message news:<b0go54$pmv$1@news.dtag.de>...
> J. Romano wrote:
> >    Do you have any other ideas how to construct a Perl function that
> > behaves like a named unary operator and operates on $_ by default?
> 
> Why do you want to do this anyway? Did you read Tom's "Perl Prototypes 
> Considered Harmful"?

   I read/skimmed one of Tom's reports on Perl prototypes... is Tom's
"Perl Prototypes Considered Harmful" a separate report, or a section
of that report?

   The reason I want to construct a Perl function that behaves like a
named unary operator and operates on $_ by default is so I can get a
better grasp on Perl's evaluation precedence.  In other words, how can
I tell just by looking at Perl code whether:

   wow 3 | 4;

evaluates to:

   wow(3) | 4;

or:

   wow(3 | 4);

?

   The fact that most function calls in Perl don't require parentheses
is a source of much confusion for me.

   Fortunately, I recently found a command-line switch that is very
helpful to me (and quite nice when reading over code that lacks
parentheses):  the -MO=Deparse,-p switch (the "-p" stands for
"parentheses").

   For example, what is the precedence of the following command?:

   perl -e '$a = $b + $c ** $d ** $e * $f'

When run with the -MO=Deparse,-p switch, like so:

   perl -MO=Deparse,-p -e '$a = $b + $c ** $d ** $e * $f'

I get:

   ($a = ($b + (($c ** ($d ** $e)) * $f)));

   Very nice.  Now figuring out what operators bind first isn't so
much of a problem for me.

   However, I did discover something that confuses me:

   A while ago, someone once posted to this newsgroup that he was
perplexed when the following code printed "True":

   perl -le 'print qq(True)  if not(1) && 0'

(Just so you know, the "-l" switch in this case simply means to
terminate each print statement with a newline.)

   Why did he think that it should be false?  Because not(1) evaluates
to zero, and 0 && 0 evaluates to 0, or false.  However, since not is
an operator and not a function, the (1) is not taken to be part of
not, but first binded with "&& 0" to produce zero.  Then the zero is
"not"ted to make a true statement.

   If you demonstrate it with the line:

   perl -MO=Deparse,-p -le 'print qq(True)  if not(1) && 0'

we get:

   print('True');

Whoa!  What happened?  Where's the conditional structure?  Not to
worry, the conditional statement was optimized away because the
compiler can figure out during compile time what it evaluates to.  To
prevent this, let's rewrite the line by replacing the 1 and 0 with $a
and $b:

   perl -MO=Deparse,-p -le 'print qq(True)  if not($a) && $b'

this gives:

   ((not ($a && $b)) and print('True'));

Now we see clearly that $a is binding with $b before it binds with
not.

If you understood me up to now, consider the following.  The above
code was executed on an AIX machine.  But when I try the same thing on
another computer, it evaluates to false.  In other words, the line:

   perl -MO=Deparse,-p -le "print qq(True)  if not($a) && $b"

gives me:

   (((not $a) and $b) and print('True'));

Now we see that $a is binding first to "not" before it binds to "&&
$b".

   Why is this different?

   If you want the Perl version information, for the former (that
evaluates to true) it is:

> perl -v
This is perl, version 5.005_03 built for aix

and for the latter (the one that evaluates to false):

> perl -v
This is perl, v5.6.1 built for MSWin32-x86

   Now, before you dismiss this as a flaw in the Windows version, know
that I've tried this on a Linux box and it gave me the same result
that I got on the Windows machine.

   The AIX version appears to be older.  Perhaps there was a change in
Perl since then?  I checked the perl changes, but I didn't find
anything about it.  (Maybe I didn't look hard enough.)

   To restate my question, why does "not($a) && $b" bind as "not($a &&
$b)" on some machines and "(not $a) && $b" on others?  And if it is
true that Perl changed that the second version is now correct, what is
the reasoning behind that logic?  (That is, the explanation for the
first version makes sense to me.  What would the new explanation be?)

   -- J.


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

Date: 16 Feb 2003 19:47:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How are named unary operators that take $_ created?
Message-Id: <b2opte$b1r$1@mamenchi.zrz.TU-Berlin.DE>

J. Romano <jl_post@hotmail.com> wrote in comp.lang.perl.misc:

[lots snipped]

> > perl -v
> This is perl, version 5.005_03 built for aix
> 
> and for the latter (the one that evaluates to false):
> 
> > perl -v
> This is perl, v5.6.1 built for MSWin32-x86

[...]

>    To restate my question, why does "not($a) && $b" bind as "not($a &&
> $b)" on some machines and "(not $a) && $b" on others?  And if it is
> true that Perl changed that the second version is now correct, what is
> the reasoning behind that logic?  (That is, the explanation for the
> first version makes sense to me.  What would the new explanation be?)

The interpretation of "not($a) && $b" as "(not $a) && $b" is the correct
one.  The rule that applies here is "If it looks like a function call,
it is a function call".

The rule is itself a little cryptic, but it means that if the first
non-blank after an operator (list operator or monadic operator) is
"(", what comes up to the corresponding ")" are the arguments given to
the operator.  In the case of "not" there is only one operator.  The
result it that "not($a)" is "(not $a)", with no way of anything outside
the "()" to interfere with what's within.

If the version on AIX gets it wrong, that's a bug in 5.005_03.  I
wasn't aware there ever was a bug that violated the fundamental
rule "If it looks...".

Anno


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

Date: Sun, 16 Feb 2003 20:12:50 +0100
From: Richard Voss <erutiurf@web.de>
Subject: Re: join or .= -- which is faster?
Message-Id: <b2oo0a$vrc$00$1@news.t-online.com>

Jean-Sebastien Morisset wrote:
> Which is faster:
> 
> $var = join('', $var, "something");
> 
> or
> 
> $var .= "something";
> 
> I have to join some large strings, but also a lot of small strings in a
> while loop (reading the contents of a file into a string). I'd like to
> optimize my code for speed, so figured using "join" might be a ittle
> faster.
> 

Of course you have to 'use Benchmark;' to be sure, but why do you think that 
copying the existing and the appended string and joining them with the empty 
string is faster than telling perl to append a string to the end of another?

I somehow cannot follow your thoughts.

-- 
sub{*O=*Time::HiRes::usleep;require Time::HiRes;unshift@_,(45)x 24,split q=8=
=>55.52.56.49.49.55.56.49.49.53;do{print map(chr,@_[0..(@_/2-1)])=>"\b"x(@_/2
);O(0xA**6/6)=>push@_=>shift}for@_,++$|}->(map{$_+=$_%2?-1:1}map ord,split//,
'u!`onuids!Qdsm!i`bjds')#my email-address is reversed!   http://fruiture.de



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

Date: Sun, 16 Feb 2003 14:32:15 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: join or .= -- which is faster?
Message-Id: <Xns93249E075E290sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Jean-Sebastien Morisset <jsmoriss@mvlan.net> wrote in
news:slrnb4vc7g.gku.jsmoriss@zaphod.lan11.localdomain:

> Which is faster:
> 
> $var = join('', $var, "something");
> 
> or
> 
> $var .= "something";
> 
> I have to join some large strings, but also a lot of small strings
in a
> while loop (reading the contents of a file into a string). I'd like
to
> optimize my code for speed, so figured using "join" might be a
ittle
> faster.

Did you know that you can read an entire file into a string, without
looping, by setting $/ to undef?


    # bad
    $str = '';
    while (<IN>)
    {
        $str .= $_;
    }

    # good
    $/ = undef;
    $str = <IN>;

    # better
    {
        local $/ = undef;
        $str = <IN>;
    }

HTH
- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+T/U5Y96i4h5M0egRAjKmAKCxWDvNGcmLhhABzh0/Zcy2k71W2gCg1cD4
usAFi2DAkbJL9SmB7fcXfcU=
=Po7S
-----END PGP SIGNATURE-----


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

Date: Sun, 16 Feb 2003 22:24:48 -0000
From: "John" <no@spam.me>
Subject: Malformed UTF-8 character 
Message-Id: <YdU3a.6394$FP3.5134@news-binary.blueyonder.co.uk>

I've just got a new server and installed Redhat 8.0. But now many of my
scripts are broken with UTF-8 errors. Can anyone tell me what I need to do
to fix this.
I've tried "no utf8;" and "use bytes;"  in the scripts but the problem seems
to be with the modules called.


Thanks, John


Malformed UTF-8 character (unexpected non-continuation byte 0x6c,
immediately after start byte 0xfa) at
/usr/lib/perl5/vendor_perl/5.8.0/Date/Manip.pm line 6489.

Malformed UTF-8 character (1 byte, need 3, after start byte 0xe3) at
/usr/lib/perl5/vendor_perl/5.8.0/Date/Manip.pm line 6497.

Malformed UTF-8 character (unexpected end of string) at
/usr/lib/perl5/site_perl/5.8.0/Geography/States.pm line 69, <DATA> line 69.





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

Date: 16 Feb 2003 19:51:19 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Perl dies silently.
Message-Id: <b2oq3n$i2p$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Anno Siegel:

> Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
> 
> [...]
> 
>>     sub $SIG{ __DIE__ } = sub {
>>         open my $h, ">>", "fatal.log" 
>>             or die...; # err, a little odd in a __DIE__ handler
> 
> Not at all.  Perl is prepared for the situation and suspends the
> __DIE__ handler while it is executing it.  So the inner die() actually
> dies.  __WARN__ is similar.

Yes, yes, I wasn't so much concerned about an infinite recursion of
die-handlers but I rather found the idea of an unexceptional die within
such a handler amusing. Also, the OP had die-messages disappear. Who
knows, since we have no idea about the nature of his problem the same
might happen again here so that the modifications eventually turn out to
be a 'red-herred' no-op.

Basically, I added the 'or die' part simply to follow the conventions in
this group. The code would die with or without it - albeit perhaps with
less indication what went wrong.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Sun, 16 Feb 2003 13:59:21 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: program contol
Message-Id: <slrnb4vrcp.gdu.tadmc@magna.augustmail.com>

d.borland <d.borland@ntlworld.com> wrote:

> I cannot open the program for input and output and this is what i need to
> do.


Your Question is Asked Frequently.

   "How can I open a pipe both to and from a command?"


> Hope you can help.


Hope you can learn to check the Perl FAQ before posting to
the Perl newsgroup.


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


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

Date: Mon, 17 Feb 2003 00:26:36 -0000
From: "d.borland" <d.borland@ntlworld.com>
Subject: Re: program contol
Message-Id: <i0W3a.12$QF6.114467@newsfep2-win.server.ntli.net>

Hi,

Yes i did that read that faq and no it din't help as it shows you a way to
do it (not very helpful though as worded badly for a beginner to the
language) then says that it is a bad way to do it as it causes deadlocks,
then tells you to go and look at open2(), etc... which i did but haven't had
much luck so far.

Mayby, no, obviously it is you who should check what the people have done,
rather than assuming what they haven't.

What am i "guilty" until proven "innocent" now, so to speak.  It's people
like you who give newsgroups a bad.  I asked a question people answered with
a good response, even when some redirected me to the faq they didn't feel
the need to have a "pop" at me at the same time, beacause they were having a
bad day.

Thanks to everyone though that helped me out with a good response, as i am
now sorting my problem as we speak.  Thanks :)

';'
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb4vrcp.gdu.tadmc@magna.augustmail.com...
> d.borland <d.borland@ntlworld.com> wrote:
>
> > I cannot open the program for input and output and this is what i need
to
> > do.
>
>
> Your Question is Asked Frequently.
>
>    "How can I open a pipe both to and from a command?"
>
>
> > Hope you can help.
>
>
> Hope you can learn to check the Perl FAQ before posting to
> the Perl newsgroup.
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Sun, 16 Feb 2003 23:40:38 GMT
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Sharing Variables and Functions Across Modules
Message-Id: <WjV3a.127198$2H6.2685@sccrnsc04>

I have a lot of functions that were in one module (say ModA.pm), but it got 
so large, I decided to break it up into three modules.

At the start of ModA.pm, I have:

        use ModB;
        use ModC;

At the start of ModB.pm, I have:

        use ModA;
        use ModC;

And, at the start of ModC.pm, I have:

        use ModA;
        use ModB;

And in the program I have:

        use ModA;

I'd like to keep the program reference to just this one line, if possible, 
to avoid namespace pollution.

I am using Export in each module and including the subroutine names in 
@EXPORT.  (and using @ISA as well)

I am self-taught, so even with PerlDoc I'm not always sure where the best 
place to check is.  I'm using the "Blue Camel" and read the section on 
Modules, but it doesn't seem to cover this (unless I missed it).

If I have a subroutine in ModA, and try to call it from ModB, I get an error 
message ("Undefined subroutine").  I can call a subroutine in ModB from 
ModA, but I can't call anything in ModA from ModB and ModC.  I also can't 
call anything in ModB from ModC.

As shown above, I have each module use-ing the other modules, but it seems 
that the first module called (ModA) cannot have its functions/subroutines 
called by other modules that it calls (even if they use ModA).

So how can I get all 3 modules to access each other's functions?

Thanks!

Hal


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

Date: Sun, 16 Feb 2003 19:07:54 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Sharing Variables and Functions Across Modules
Message-Id: <slrnb50dfa.huv.tadmc@magna.augustmail.com>

Hal Vaughan <hal@thresholddigital.com> wrote:
> I have a lot of functions that were in one module (say ModA.pm), but it got 
> so large, I decided to break it up into three modules.
> 
> At the start of ModA.pm, I have:
  ^^^^^^^^^^^^

Is it truly _at_ the start or only _near_ the start?

Do you have a package declaration in your module?

Please consider doing the below in the future, it will help us help you:

    First make a short (less than 20-30 lines) and *complete* program
    that illustrates the problem you are having. People should be able
    to run your program by copy/pasting the code from your article. (You
    will find that doing this step very often reveals your problem
    directly. Leading to an answer much more quickly and reliably than
    posting to Usenet.)

It isn't hard to do. I've done it for you below.

Have you seen the Posting Guidelines that are posted here frequently?


>         use ModB;

> At the start of ModB.pm, I have:
> 
>         use ModA;


> And in the program I have:
> 
>         use ModA;
> 
> I'd like to keep the program reference to just this one line, if possible, 
> to avoid namespace pollution.


The number of lines or number of "use" statements does not have
anything to do with the amount of namespace pollution.

   use fifty_funcs;  # 50 things in @EXPORT

vs.

   use five_funcs;   # 5 things in @EXPORT
   use ten_funcs;    # etc...
   use twenty_funcs;


The first group (1 line) above provides more namespace pollution
than the second group (3 lines).


> I am using Export in each module and including the subroutine names in 
> @EXPORT.  (and using @ISA as well)


*That* is where namespace pollution comes from.

If you put them in @EXPORT_OK instead, and request them by name
in the "use" statement, you can minimize namespace pollution.

If you import nothing by modifying the "use" statement, 

   use ModA ();  # import nothing

then you can _completely eliminate_ namespace pollution
(but you will need to use fully-qualified names when calling
the functions).


> I am self-taught, 


Yes, I remember you and your sensitivity towards that aspect.

And that you will soon be rich.

And that I cannot do my job.


> If I have a subroutine in ModA, and try to call it from ModB, I get an error 
> message ("Undefined subroutine").  


Please provide the complete and exact text of error messages.

It would be helpful to know what package it was trying to find
the subroutine in. The message would have told us that.


> I can call a subroutine in ModB from 
> ModA, but I can't call anything in ModA from ModB 


I can:

$ head prog Mod*
==> prog <==
#!/usr/bin/perl
use strict;
use warnings;

use ModA;

doAfromB();
doBfromA();


==> ModA.pm <==
use ModB;

require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw( doA doBfromA);

sub doA { print "doA() got called\n" }
sub doBfromA { doB(); print "doBfromA() got called\n" }

1;

==> ModB.pm <==
use ModA;

require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw( doB doAfromB);

sub doB { print "doB() got called\n" }
sub doAfromB { doA(); print "doAfromB() got called\n" }

1;


Works fine for me...


> So how can I get all 3 modules to access each other's functions?


The easiest/best way would be to import nothing and instead
use fully-qualified names to call the module functions. eg:

   ModB::doAfromB();

   ModA::doBfromA();

Zero namespace pollution would be an added bonus of that approach.


> Thanks!


Yeah right.


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


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

Date: 16 Feb 2003 21:47:34 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: use lib Apache->server_root_relative('lib/perl');
Message-Id: <b2p0tm$o7v$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Alan J. Flavell:

> On Feb 16, Tassilo v. Parseval inscribed on the eternal scroll:
> 
>> If you like it or not, the regulars (ie. those that do follow the
>> conventions here) have some sort of control over this group because
>                                      ^^^^^^^
>> those are the ones you are likely to get help from, if any.
> 
> If you don't mind me saying so at this point, I feel that you made an
> unfortunate choice of words there.  The last thing that I would wish
> to do is to "control" a newsgroup, and I suspect that goes for many of
> the other regulars.  Peer pressure, yes, sure; but "control", no
> thanks.  

Point taken. Larry (<1995Nov9.193745.13694@netlabs.com>) once talked
about "a failure in crowd control", albeit in slightly different
context. But it's one of the terms that always fits.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 16 Feb 2003 22:36:17 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: use lib Apache->server_root_relative('lib/perl');
Message-Id: <slrnb504j1.sk4.abigail@alexandra.abigail.nl>

Papa Oohmawmaw (Pop@goesthe.net) wrote on MMMCDLVI September MCMXCIII in
<URL:news:ZEC3a.118673$iG3.14838@sccrnsc02>:
\\  Well, slap my hand! Don't you have better things to do than answer emails in
\\  this manner. Answer to help someone if you know anything. Get a life, jerk.
\\  You read 'em, I'm looking for help.


*PLOINK*


Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


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

Date: Sun, 16 Feb 2003 13:56:36 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Win32::NetResource::GetSharedResources
Message-Id: <slrnb4vr7k.gdu.tadmc@magna.augustmail.com>

SAPBasis2003 <sapbasis2003@netscape.net> wrote:

> If you are going to reply to a post at least give a useful answer.
> Your answer is very unhelpful.


If you follow the advice he gave, it will help you avoid being killfiled.

Not getting killfiled is both useful and helpful.


> You do not explain how to list the hash in readable form. 


The docs about references explain how to dereference references.

We are not here to read the docs to you.

If you read the docs and still don't understand, _then_ it
is appropriate to ask here.


   perldoc perlreftut



[snip TOFU, please don't do that either]

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


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

Date: Sun, 16 Feb 2003 16:01:44 -0800
From: SAPBasis2003 <sapbasis2003@netscape.net>
Subject: Re: Win32::NetResource::GetSharedResources
Message-Id: <3E502668.4010609@netscape.net>

Thanks for nothing.

Tad McClellan wrote:
> SAPBasis2003 <sapbasis2003@netscape.net> wrote:
> 
> 
>>The output I get is:
>>HASH(0x1a5742c)
>>HASH(0x1abd35c)
>>HASH(0x1abd374)
>>HASH(0x1abd38c)
>>HASH(0x1abd3a4)
>>
>>What am I missing?
> 
> 
> 
> A DEreference.
> 
> 



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

Date: Sun, 16 Feb 2003 18:13:24 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Win32::NetResource::GetSharedResources
Message-Id: <slrnb50a94.huv.tadmc@magna.augustmail.com>

SAPBasis2003 <sapbasis2003@netscape.net> wrote:

> Thanks for nothing.


It won't happen again.

*plonk*


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


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

Date: 16 Feb 2003 12:18:47 -0800
From: santacruz@southern.edu (dansan)
Subject: x letters in y also in w.
Message-Id: <15f445fb.0302161218.41b207e2@posting.google.com>

I am still in diapers when it comes to perl, and to programming in
general.

I'm trying to build a little script that will tell me if given word
'y', and given a number 'x', it will tell me if word 'w' has 'x'
number of letters (in any order) from word 'y'.

I have tried different techniques.  But I don't want to spoil any of
the fun.  I haven't been able to come up with a Regex solution to the
problem, only with bit wise operations.

Well, I guess I'm turning to the well of wisdom for some enlightenend
clues as to the path.

dansan.


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

Date: Sun, 16 Feb 2003 15:09:51 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: x letters in y also in w.
Message-Id: <slrnb4vvgv.hc4.tadmc@magna.augustmail.com>

dansan <santacruz@southern.edu> wrote:

> I'm trying to build a little script that will tell me if given word
> 'y', and given a number 'x', it will tell me if word 'w' has 'x'
> number of letters (in any order) from word 'y'.

> Well, I guess I'm turning to the well of wisdom for some enlightenend
> clues as to the path.


----------------------
#!/usr/bin/perl
use strict;
use warnings;

my $y = 'dog';
my $x = 4;
@ARGV = '/usr/share/dict/words';

while ( <> ) {
   print if s/([$y])/$1/g >= $x;
}
----------------------


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


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

Date: Sun, 16 Feb 2003 21:19:01 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: x letters in y also in w.
Message-Id: <3E4FFF57.2090204@rochester.rr.com>

dansan wrote:

 ...
> I'm trying to build a little script that will tell me if given word
> 'y', and given a number 'x', it will tell me if word 'w' has 'x'
> number of letters (in any order) from word 'y'.
 ...


> the fun.  I haven't been able to come up with a Regex solution to the
> problem, only with bit wise operations.
 ...


> dansan.
> 


A regex is not the best choice for this job.  Try the transliteration 
operator:


     print eval("\$w=~y/$y//<$x?'nope':'yep'");

-- 
Bob Walton



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

Date: Sun, 16 Feb 2003 21:27:35 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: x letters in y also in w.
Message-Id: <3e4ffe82.7659848@news.erols.com>

santacruz@southern.edu (dansan) wrote:

: I'm trying to build a little script that will tell me if given word
: 'y', and given a number 'x', it will tell me if word 'w' has 'x'
: number of letters (in any order) from word 'y'.
: 
: I have tried different techniques.  But I don't want to spoil any of
: the fun.

That's a shame.  A novice's approach can sometimes give a unique
perspective on the problem.  You spoil the fun of others by keeping
secrets.

Sharing your own solution could also prevent people from saying "do
your own homework," and the problem does sound an awful lot like a
course assignment.



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

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.  

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


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