[22354] in Perl-Users-Digest
Perl-Users Digest, Issue: 4575 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 17 06:05:45 2003
Date: Mon, 17 Feb 2003 03: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 Mon, 17 Feb 2003 Volume: 10 Number: 4575
Today's topics:
Re: (not 1) and (!1) yield zero length string <parv_fm@emailgroupsWhereElse.net>
Re: (not 1) and (!1) yield zero length string (Anno Siegel)
Re: (not 1) and (!1) yield zero length string (Sam Holden)
Re: (not 1) and (!1) yield zero length string <sfandino@yahoo.com>
Re: Correct way to check for errors during readline()? <goldbb2@earthlink.net>
Emacs modules for Perl programming (Jari Aalto+mail.perl)
Explaining flock and file handles (Bob Dubery)
Re: join or .= -- which is faster? <goldbb2@earthlink.net>
Re: join or .= -- which is faster? <ubl@schaffhausen.de>
Re: Malformed UTF-8 character <goldbb2@earthlink.net>
Re: Malformed UTF-8 character <no@spam.me>
Re: program contol (Sam Holden)
Re: Sharing Variables and Functions Across Modules <hal@thresholddigital.com>
Re: Sharing Variables and Functions Across Modules <noreply@gunnar.cc>
Re: Sharing Variables and Functions Across Modules (Anno Siegel)
Re: use lib Apache->server_root_relative('lib/perl'); <goldbb2@earthlink.net>
Re: use lib Apache->server_root_relative('lib/perl'); (Sam Holden)
Re: use lib Apache->server_root_relative('lib/perl'); (Helgi Briem)
Re: use lib Apache->server_root_relative('lib/perl'); (Helgi Briem)
Re: Win32::NetResource::GetSharedResources <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 17 Feb 2003 09:26:44 GMT
From: parv <parv_fm@emailgroupsWhereElse.net>
Subject: Re: (not 1) and (!1) yield zero length string
Message-Id: <slrnb51arq.1a4p.parv_fm@localhost.holy.cow>
in message <QfR3a.222$iz6.113@newsfep3-gui.server.ntli.net>,
wrote Chris Lowth ...
(Salvador's reply was similar.)
> parv wrote:
>
>> I am mystified that (not 1 ...) & (!1 ...) yield _zero_length_string_
>> but not the following operations...
>>
>> (!0 && 0) , (!0 and 0) , (not 0 && 0) , (not 0 and 0)
>>
>>
>> ...which produce 0, 0, 1, 0 respectively.
>>
>> The perlop (perl 5.6.1) states that qw{and && or ||} operators return
>> the last value evaluated.
>
> No - no ambiguity.
I wasn't referring to what is false or true, but the phrase in
perlop "last evaluated value". But never mind; just nit picking
minutely.
> In perl the values zero and empty string are both understood to be "FALSE"
> when used as booleans. Anything else is TRUE.
...
> Next, you must consider operator presedence. "&&" and "!" are the same
> level, and "not" and "and" are at a different (lower) level -- so.
I am well aware of the above two points.
Given...
print join " - " , (!0 && 0) , (!1 && 0);
...first value produced is 0 but the second is an empty string. As
both expressions are being used similarly, i expected both the
values returned to be the same: either 0 or ''.
> - dont assume that booleans are numbers (perl isnt C)
I wouldn't have problem w/ that as long as the results had been
consistent (see above).
- parv
--
please don't send me private e-mail.
if you must, do away w/ WhereElse in the address.
------------------------------
Date: 17 Feb 2003 09:53:56 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: (not 1) and (!1) yield zero length string
Message-Id: <b2qbfk$h3q$1@mamenchi.zrz.TU-Berlin.DE>
parv <parv_fm@emailgroupsWhereElse.net> wrote in comp.lang.perl.misc:
> in message <QfR3a.222$iz6.113@newsfep3-gui.server.ntli.net>,
> wrote Chris Lowth ...
>
> (Salvador's reply was similar.)
>
>
> > parv wrote:
> >
> >> I am mystified that (not 1 ...) & (!1 ...) yield _zero_length_string_
> >> but not the following operations...
> >>
> >> (!0 && 0) , (!0 and 0) , (not 0 && 0) , (not 0 and 0)
> >>
> >>
> >> ...which produce 0, 0, 1, 0 respectively.
> >>
> >> The perlop (perl 5.6.1) states that qw{and && or ||} operators return
> >> the last value evaluated.
> >
> > No - no ambiguity.
>
> I wasn't referring to what is false or true, but the phrase in
> perlop "last evaluated value". But never mind; just nit picking
^^^^^^^^^^^^^^^^^^^^
> minutely.
When the doc says "last evaluated value", it must be taken into account
that "&&" (and "||") are short-circuiting, that is, they don't evaluate
the second argument if the truth value of the expression can already
be decided by looking at the first operand.
> > In perl the values zero and empty string are both understood to be "FALSE"
> > when used as booleans. Anything else is TRUE.
> ...
> > Next, you must consider operator presedence. "&&" and "!" are the same
> > level, and "not" and "and" are at a different (lower) level -- so.
>
> I am well aware of the above two points.
>
>
> Given...
>
> print join " - " , (!0 && 0) , (!1 && 0);
>
>
> ...first value produced is 0 but the second is an empty string. As
> both expressions are being used similarly, i expected both the
> values returned to be the same: either 0 or ''.
In "(!0 && 0)", "!0" evaluates to something true, so the second operand
(0) is returned. In "(!1 && 0)", "!1" evaluates to false, so the second
operand isn't even looked at. The expression returns "!1", which prints
as an empty string.
Anno
------------------------------
Date: 17 Feb 2003 10:09:02 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: (not 1) and (!1) yield zero length string
Message-Id: <slrnb51d5u.9g2.sholden@flexal.cs.usyd.edu.au>
On Sun, 16 Feb 2003 10:32:17 GMT, parv <parv_fm@emailgroupsWhereElse.net> wrote:
> I am mystified that (not 1 ...) & (!1 ...) yield _zero_length_string_
> but not the following operations...
>
> (!0 && 0) , (!0 and 0) , (not 0 && 0) , (not 0 and 0)
>
>
> ...which produce 0, 0, 1, 0 respectively.
>
> The perlop (perl 5.6.1) states that qw{and && or ||} operators return
> the last value evaluated.
>
> So, does (not 1) or (!1) change/short-circuit to 0 which is false
> value, and empty string is a false value, which is then returned?
>
> But isn't 1 the value being evaluated which should be returned,
> though very odd & unexpected, according to the perlop? In case
> perlop is referring to the value of "not 1", then there is ambiguity
> there, IMO.
I can't work out what you are referring to.
!1 evaluates to the empty string, and so does not 1.
None of the other expressions you uses contain either !1 or not 1.
!0 && 0 -> 1 && 0 -> returns 0 since it is the last evaluated expression.
!0 and 0 -> as above
not 0 && 0 -> not (0 && 0) -> not 0 -> 1
not 0 and 0 -> 1 and 0 -> returns 0 since it is the last evaluated expression.
something like:
!1 && 0 would evaluate to '' since !1->'' which is the last evaluated
expression.
--
Sam Holden
------------------------------
Date: Mon, 17 Feb 2003 11:13:35 +0000
From: =?ISO-8859-1?Q?Salvador_Fandi=F1o_Garc=EDa?= <sfandino@yahoo.com>
Subject: Re: (not 1) and (!1) yield zero length string
Message-Id: <3E50C3DF.7030801@yahoo.com>
Hi,
parv wrote:
> (Salvador's reply was similar.)
no, it wasn't, I said:
SF> It seems that (not 1) returns a magic scalar that renders as 0 in
SF> numeric context and '' in other scalar contexts.
The problem is that the 'not' operator has to work also for strings...
not 'hello'
should return '', but what should you expect from...
not '23'
0 or '' ?
it depends on the context so Perl tries to satisface both and returns an
schizophrenic value (being both 0 and '') that unfortunatelly prints as ''.
I don't think getting '' from 'not $string' could be usefull at all. The
problem you are exposing seems far more common so maybe you should send
a bug report to perlbug asking for this "feature" to be removed
http://bugs.perl.org/
Bye,
- Salva
------------------------------
Date: Mon, 17 Feb 2003 00:11:52 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Correct way to check for errors during readline()?
Message-Id: <3E506F18.D12E398C@earthlink.net>
Rich wrote:
>
> 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?
It depends on the version of perl, and on error. In perl5.8.0, if errno
is EAGAIN or EINTR, perl checks if any signals have come in, dispatches
the perl signal handlers, then tries the read call again.
For other errors ... I believe that it will return whatever data has
been read so far, and then the next call will be undef, just as if you'd
hit the end-of-file.
> I'm presuming you therefore have to test $! to determine whether an
> error condition or end of file has been reached?
Yes, I suppose so. Also, since $! only is meaningful *after* an error
has occured (that is, it may have garbage in it after a successful
operation), you have to set it to zero before you make your readline
call.
PS: In almost all situations where you'd be worried about errors while
reading, you'd probably want to use sysread() instead of readline(), and
do the newline handling yourself.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: 17 Feb 2003 09:53:45 GMT
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Emacs modules for Perl programming
Message-Id: <perl-faq/emacs-lisp-modules_1045475270@rtfm.mit.edu>
Archive-name: perl-faq/emacs-lisp-modules
Posting-Frequency: 2 times a month
URL: http://tiny-tools.sourceforge.net/
Maintainer: Jari Aalto <jari.aalto@poboxes.com>
Announcement: "What Emacs lisp modules can help with programming Perl"
Preface
Emacs is your friend if you have to do anything comcerning software
development: It offers plug-in modules, written in Emacs lisp
(elisp) language, that makes all your programmings wishes come
true. Please introduce yourself to Emacs and your programming era
will get a new light.
Where to find Emacs/XEmacs
o Unix:
http://www.gnu.org/software/emacs/emacs.html
http://www.xemacs.org/
o Unix Windows port (for Unix die-hards):
install http://www.cygwin.com/ which includes native Emacs 21.x.
XEmacs port is bundled in XEmacs setup.exe available from
XEmacs site.
o Pure Native Windows port
http://www.gnu.org/software/emacs/windows/ntemacs.html
ftp://ftp.xemacs.org/pub/xemacs/windows/setup.exe
o More Emacs resources at
http://tiny-tools.sourceforge.net/ => Emacs resource page
Emacs Perl Modules
Cperl -- Perl programming mode
ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl
http://www.perl.com/CPAN-local/misc/emacs/cperl-mode/
<ilya@math.ohio-state.edu> Ilya Zakharevich
CPerl is major mode for editing perl files. Forget the default
`perl-mode' that comes with Emacs, this is much better. Comes
standard in newest Emacs.
TinyPerl -- Perl related utilities
http://tiny-tools.sourceforge.net/
If you ever wonder how to deal with Perl POD pages or how to find
documentation from all perl manpages, this package is for you.
Couple of keystrokes and all the documentaion is in your hands.
o Instant function help: See documentation of `shift', `pop'...
o Show Perl manual pages in *pod* buffer
o Grep through all Perl manpages (.pod)
o Follow POD references e.g. [perlre] to next pod with RETURN
o Coloured pod pages with `font-lock'
o Separate `tiperl-pod-view-mode' for jumping topics and pages
forward and backward in *pod* buffer.
o Update `$VERSION' variable with YYYY.MMDD on save.
o Load source code into Emacs, like Devel::DProf.pm
o Prepare script (version numbering) and Upload it to PAUSE
o Generate autoload STUBS (Devel::SelfStubber) for you
Perl Module (.pm)
TinyIgrep -- Perl Code browsing and easy grepping
[TinyIgrep is included in Tiny Tools Kit]
To grep from all installed Perl modules, define database to
TinyIgrep. There is example file emacs-rc-tinyigrep.el that shows
how to set up dattabases for Perl5, Perl4 whatever you have
installed
TinyIgrep calls Igrep.el to to do the search, You can adjust
recursive grep options, set search case sensitivity, add user grep
options etc.
You can find latest `igrep.el' module at
<http://groups.google.com/groups?group=gnu.emacs.sources> The
maintainer is Jefin Rodgers <kevinr@ihs.com>.
TinyCompile -- To Browse grep results in Emacs *compile* buffer
TinyCompile is a minor mode for *compile* buffer from where
you can collapse unwanted lines or shorten file URLs:
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file1:NNN: MATCHED TEXT
/asd/asd/asd/asd/ads/as/da/sd/as/as/asd/file2:NNN: MATCHED TEXT
-->
cd /asd/asd/asd/asd/ads/as/da/sd/as/as/asd/
file1:NNN: MATCHED TEXT
file1:NNN: MATCHED TEXT
End
------------------------------
Date: Mon, 17 Feb 2003 08:26:17 GMT
From: megapode@hotmail.com (Bob Dubery)
Subject: Explaining flock and file handles
Message-Id: <3e509b83.407842187@10.100.2.1>
I recently helped a less experienced colleague with a problem she had
in her code.
She was using flock in a pair of programs, but said that the locking
wasn't working and that both programs could process the file at the
same time (with the danger of an update being lost).
It turned out that she was calling flock using the scalar containg the
FILE NAME rather than using the FILE HANDLE.
We changed the code. It worked.
However, she asked me why it was necessary to use the HANDLE when
she'd already stipulated which file she wants.
My explanation was along the lines of "well, the handle is mapped to a
specific inode, and it's possible that a file name has been changed
after a program set the lock or that you're addressing a symlink that
points to another actual file", but I found that a little
unconvincing.
I guess it really goes to the nature of a file handle.
I'd appreciate a more erudite and complete explanation :-)
Thanks
------------------------------
Date: Sun, 16 Feb 2003 23:59:38 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: join or .= -- which is faster?
Message-Id: <3E506C3A.A1CF1212@earthlink.net>
"Eric J. Roode" wrote:
[snip]
> # good
> $/ = undef;
> $str = <IN>;
>
> # better
> {
> local $/ = undef;
> $str = <IN>;
> }
# best?
$str = do { local $/; <IN> };
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Mon, 17 Feb 2003 11:41:12 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: join or .= -- which is faster?
Message-Id: <b2qhfl$g4i$1@news.dtag.de>
Richard Voss wrote:
> Jean-Sebastien Morisset wrote:
>
>> Which is faster:
>>
>> $var = join('', $var, "something");
>>
>> or
>>
>> $var .= "something";
>
> 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.
As far as I know C<$var += 3> is faster than C<$var = $var + 3> because,
the first is operating on existing memory while the second is doing an
extra copy. This is of course for numbers where no extra memory has to
be allocated, but I could still imagine the same to be true for strings.
I would think that while C<$var = $var."something" > probably compiles
to a join, that C<$var .= "something"> compiles to some kind of string
append function.
Now if I knew C, I'd look at the source...
->malte
--
srand 108641088; print chr int rand 256 for qw<J A P H>
------------------------------
Date: Sun, 16 Feb 2003 23:54:14 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Malformed UTF-8 character
Message-Id: <3E506AF6.B2DDCB7B@earthlink.net>
John wrote:
>
> 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.
As I'm sure you already know, perl always opens files in text mode.
On unix, text mode and unix binary mode used to be the same thing.
This is no longer entirely true. Perl5.8.0 looks at certain environment
variables to find out how text mode files are encoded, and pushes an
appropriate perlio layer onto all filehandles created by open().
Redhat 8.0 has $ENV{LANG} equal to "en_US.utf8", which perl interprets
to mean that all text-mode filehandles are utf8.
The way to work around the so-called "problem," is to do the same thing
you would do to prevent CRLF <=> "\n" conversion on windows. That is:
binmode() any handle which contains binary data, but leave handles with
text data alone. And if your source code has strings with their high
bits set, make sure that the appropriate 'use encoding qw(...)' is done.
> I've tried "no utf8;" and "use bytes;" in the scripts but the problem
> seems to be with the modules called.
The "use utf8" pragma has an effect similar to "use encoding qw(utf8);",
and "no utf8" pragma has an effect similar to "use encoding qw(latin1)".
Using either of "no utf8" or "use encoding qw(latin1)" would solve the
problems coming from Date/Manip.pm (but you have to put it *in*
Date/Manip.pm).
The "use bytes" pragma means: When asking for a string's length(), tell
how many byte are allocated to contain the string, not how many
characters the string contains. For example:
$x = chr 256;
use bytes;
print length $x;
Prints out 2. This is rarely useful.
> 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.
These problems are due to Data/Manip.pm containing strings with
have thier high-bits set in them -- they are valid ISO-8859-1 strings,
but they are invalid utf8.
You can correct the problem by adding:
use encoding "latin1";
At the top of Data/Manip.pm. (Well, actually, anywere before sub
Date_Init_Portuguese should be ok).
> 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.
This error is due to the "Ceará", "Espiríto Santo", "Goiás", "Maranhão",
etc. after __DATA__. These strings are encoded in ISO-8859-1, but perl
thinks the data is encoded with utf8, and since it isn't valid utf8, it
whines.
Add binmode(DATA, ":encoding(latin1)") or just binmode(DATA) before the
first place that the handle is read from.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Mon, 17 Feb 2003 09:49:57 -0000
From: "John" <no@spam.me>
Subject: Re: Malformed UTF-8 character
Message-Id: <ff24a.9398$iq5.8636@news-binary.blueyonder.co.uk>
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3E506AF6.B2DDCB7B@earthlink.net...
>
> As I'm sure you already know, perl always opens files in text mode.
>
> On unix, text mode and unix binary mode used to be the same thing.
>
> This is no longer entirely true. Perl5.8.0 looks at certain environment
> variables to find out how text mode files are encoded, and pushes an
> appropriate perlio layer onto all filehandles created by open().
>
> Redhat 8.0 has $ENV{LANG} equal to "en_US.utf8", which perl interprets
> to mean that all text-mode filehandles are utf8.
> ..........snipped .........
Thanks Ben for such a thorough answer, it has resolved everything for me.
Best wishes, John
------------------------------
Date: 17 Feb 2003 04:37:51 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: program contol
Message-Id: <slrnb50pov.7q7.sholden@flexal.cs.usyd.edu.au>
On Mon, 17 Feb 2003 00:26:36 -0000, d.borland <d.borland@ntlworld.com> wrote:
> 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.
I guess everyone should use their powers of ESP and read your mind.
When asking a question you need to state if you have tried the
standard solutions to the problem.
Otherwise you'll get answers which are, as was the case in Tad's post,
a pointer to the standard solution. Something that wastes everyone's
time.
If you don't say you have done something, people will assume you haven't.
If you had read the FAQ and couldn't get its answer to work, then you
should have said that in your original post. "I've tried open2() as
suggested in the FAQ but I can't get it to work, it gives me this
error: ...", for example.
> 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.
Rather than just giving you a pointer to answer, they also tried to tell
you to look in the expected places before asking next time. It doesn't
matter that you took offense instead of taking the advice, since I suspect
those people won't be seeing your questions anymore I suspect. Which I
guess you will like anyway, since you don't seem to like the answers that
the recognised experts give.
>
> Thanks to everyone though that helped me out with a good response, as i am
> now sorting my problem as we speak. Thanks :)
You obviously haven't bothered to learn anything about usenet though,
since you top poasted and quoted the sig.
[snip full post quote with sig]
--
Sam Holden
------------------------------
Date: Mon, 17 Feb 2003 04:45:47 GMT
From: Hal Vaughan <hal@thresholddigital.com>
Subject: Re: Sharing Variables and Functions Across Modules
Message-Id: <%NZ3a.133653$tq4.4402@sccrnsc01>
Tad McClellan wrote:
> 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?
Bingo!
I looked over your examples for what you were doing that I wasn't.
Everything you had done, I had included. Then I noticed you didn't have
package declarations. At the start I had:
package ModA;
(Or ModB, as the case may be).
Once I commented out those statements, everything worked fine.
> 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.
I wish I could, but this project is under a specific contract. While I own
the code (actually my company owns it), I am not authorized to release this
part -- This particular unit that I've been on for the past few weeks is a
specialiazed module for a particular client. (It's a long story, but it's
what the client wants, it doesn't effect my business for more than a few
months, and it makes the client happy enough to pay extra.)
I notice that now, without package declaration statements, that "use ModA;"
not only makes the ModA namespace available to the program, but also makes
the namespaces from ModB and ModC available as well.
I had also tried, as you suggested, a direct reference:
(from ModB):
ModA::modasub("Called from ModB");
And was getting Undefined Subroutine errors from that as well.
As I said, once I removed the package statements, it worked fine.
Thank you. I do appreciate the help.
Hal
------------------------------
Date: Mon, 17 Feb 2003 07:49:49 GMT
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Sharing Variables and Functions Across Modules
Message-Id: <xu04a.11076$FF4.631006@newsb.telia.net>
Hal Vaughan wrote:
> Then I noticed you didn't have package declarations. At the start I had:
>
> package ModA;
>
> (Or ModB, as the case may be).
>
> Once I commented out those statements, everything worked fine.
This means that the whole program is now running in package 'main',
doesn't it? Not necessarily a good solution.
> I notice that now, without package declaration statements, that "use ModA;"
> not only makes the ModA namespace available to the program, but also makes
> the namespaces from ModB and ModC available as well.
There is no longer any ModX namespace. Only main.
> I had also tried, as you suggested, a direct reference:
>
> (from ModB):
>
> ModA::modasub("Called from ModB");
>
> And was getting Undefined Subroutine errors from that as well.
ModA::modasub() calls the subroutine modasub() in *package* ModA. Since
there is no longer such a package, that error message can be expected.
An alternative solution, if the only thing you want to do is to split
the module into several *files*, is to include the 'package ModA;'
declaration at the top of all the files.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 17 Feb 2003 10:33:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Sharing Variables and Functions Across Modules
Message-Id: <b2qdp2$jdc$1@mamenchi.zrz.TU-Berlin.DE>
Hal Vaughan <hal@thresholddigital.com> wrote in comp.lang.perl.misc:
> Tad McClellan wrote:
[non-solution snipped]
> > 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.
>
> I wish I could, but this project is under a specific contract. While I own
> the code (actually my company owns it), I am not authorized to release this
> part -- This particular unit that I've been on for the past few weeks is a
> specialiazed module for a particular client. (It's a long story, but it's
> what the client wants, it doesn't effect my business for more than a few
> months, and it makes the client happy enough to pay extra.)
Translation: We're hoping to make money with a program I am unable
to finish without help. I can't show you the code because we can
make more money if I don't. So stop asking for code samples, but
help me anyway.
That's not the way it works.
Anno
------------------------------
Date: Sun, 16 Feb 2003 23:07:40 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: use lib Apache->server_root_relative('lib/perl');
Message-Id: <3E50600C.EE432D88@earthlink.net>
Abigail wrote:
>
> 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*
Just out of curiosity, how does a ploink differ from a plonk?
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: 17 Feb 2003 04:40:30 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: use lib Apache->server_root_relative('lib/perl');
Message-Id: <slrnb50ptu.7q7.sholden@flexal.cs.usyd.edu.au>
On Sun, 16 Feb 2003 23:07:40 -0500,
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> Abigail wrote:
>>
>> 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*
>
> Just out of curiosity, how does a ploink differ from a plonk?
A shallower well?
--
Sam Holden
------------------------------
Date: Mon, 17 Feb 2003 10:50:20 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: use lib Apache->server_root_relative('lib/perl');
Message-Id: <3e50bde9.860312183@news.cis.dfn.de>
On Sun, 16 Feb 2003 23:07:40 -0500, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:
>Abigail wrote:
>>
>> 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*
>
>Just out of curiosity, how does a ploink differ from a plonk?
When somebody with a totally empty head gets plonked
he makes a slightly higher pitched sound that is
well represented by the "ploink" phoneme.
A fathead on the other makes a distinctive "plank"
sound when hitting the bottom of the killfile.
It's all in the wrist, Ben.
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: Mon, 17 Feb 2003 10:52:13 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: use lib Apache->server_root_relative('lib/perl');
Message-Id: <3e50bec3.860529886@news.cis.dfn.de>
On Sun, 16 Feb 2003 16:28:31 GMT, "Papa Oohmawmaw"
<Pop@goesthe.net> wrote:
>For those involved in this chat via email, I'm not interested in learning
>Perl (at this point). I'm trying to set up a website on a dedicated server
>and want the benefits of Perl and Mod_perl. I got a dedicated server
>specifically to set up "Apache::SpeedLimit.". I'm trying to learn enough to
>do this. That's all. When, and if, I come across something else in Perl,
>I'll start looking again. My future does not begin and end with Perl.
Well, get lost then.
<PLOINK>
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: Mon, 17 Feb 2003 02:05:56 GMT
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Win32::NetResource::GetSharedResources
Message-Id: <8sX3a.11070$FF4.630975@newsb.telia.net>
SAPBasis2003 wrote:
> {
> map
> {
> $c_comp++;
> print "$_\n";
> }
> @Resources;
> }
>
> The output I get is:
> HASH(0x1a5742c)
> HASH(0x1abd35c)
> HASH(0x1abd374)
> HASH(0x1abd38c)
> HASH(0x1abd3a4)
Try to exchange
print "$_\n";
for
for my $key (keys %$_) { print "$key = $$_{$key}\n" }
print "\n";
(untested)
If that doesn't work, you may want to study e.g.
http://www.perldoc.com/perl5.6/pod/perlreftut.html
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
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 4575
***************************************