[25447] in Perl-Users-Digest
Perl-Users Digest, Issue: 7692 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 25 18:15:32 2005
Date: Tue, 25 Jan 2005 15:15:25 -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 Tue, 25 Jan 2005 Volume: 10 Number: 7692
Today's topics:
Simple use-vs-require problem clarence@silcom.com
Re: Simple use-vs-require problem <mritty@gmail.com>
Re: Simple use-vs-require problem <matternc@comcast.net>
Re: Simple use-vs-require problem clarence@silcom.com
Re: Simple use-vs-require problem <1usa@llenroc.ude.invalid>
Re: Testing for postgres index <abigail@abigail.nl>
Re: The world's shortest 'Hello World!' program: a prop <bik.mido@tiscalinet.it>
Re: The world's shortest 'Hello World!' program: a prop <bik.mido@tiscalinet.it>
Re: trying to "use Sys::Syslog" but I get nothing ... (Anno Siegel)
Re: trying to "use Sys::Syslog" but I get nothing ... <terrylr@blauedonau.com>
Re: trying to "use Sys::Syslog" but I get nothing ... <karen.wieprecht@jhuapl.edu>
Re: trying to "use Sys::Syslog" but I get nothing ... (Anno Siegel)
Re: trying to "use Sys::Syslog" but I get nothing ... <terrylr@blauedonau.com>
Re: trying to "use Sys::Syslog" but I get nothing ... <terrylr@blauedonau.com>
Re: trying to "use Sys::Syslog" but I get nothing ... (Anno Siegel)
Re: trying to "use Sys::Syslog" but I get nothing ... <terrylr@blauedonau.com>
Using Net::FTP to get a file I almost know the name of laredotornado@zipmail.com
Re: Using Net::FTP to get a file I almost know the name (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Jan 2005 12:36:16 -0800
From: clarence@silcom.com
Subject: Simple use-vs-require problem
Message-Id: <1106685376.790144.49590@c13g2000cwb.googlegroups.com>
This has to be about the simplest question ever. And I was quite
competent with perl before I stopped using it 7 years ago. I've
been banging my head against the camel book (and the wall) for two
hours now... I'm using Perl 5.8.6
I have a module file called mod.pm, containing:
sub P {
print "in P()\n";
}
return 1;
if I do
$ perl
use mod;
P();
I get
in P()
If I do
$ perl
require mod;
mod::P();
I get
Undefined subroutine &mod::P called at - line 2.
What the heck is wrong with that?
Thanks.
------------------------------
Date: Tue, 25 Jan 2005 20:58:30 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Simple use-vs-require problem
Message-Id: <WpyJd.10595$Dz2.2757@trndny09>
<clarence@silcom.com> wrote in message
news:1106685376.790144.49590@c13g2000cwb.googlegroups.com...
> This has to be about the simplest question ever. And I was quite
> competent with perl before I stopped using it 7 years ago. I've
> been banging my head against the camel book (and the wall) for two
> hours now... I'm using Perl 5.8.6
>
> I have a module file called mod.pm, containing:
> sub P {
> print "in P()\n";
> }
> return 1;
> if I do
> $ perl
> use mod;
> P();
> I get
> in P()
>
> If I do
> $ perl
> require mod;
> mod::P();
> I get
> Undefined subroutine &mod::P called at - line 2.
> What the heck is wrong with that?
This has nothing to do with use vs require. Try swapping your examples
use mod;
mod::P();
will still fail, and
require mod;
P();
will still succeed.
The problem is that your mod.pm file doesn't declare itself a part of
any package. Therefore, all the code in mod.pm is in package main. A
package is not defined by the name of the file, it is defined by the
package statement.
Try putting
package mod;
as the top line of mod.pm and see what results you get now. You will
note that simply using 'use' instead of require does not grant you the
ability to call P() without qualifying it with the package name. For
that, &P has to be exported. Take a look at
perldoc Exporter
for more information
Paul Lalli
------------------------------
Date: Tue, 25 Jan 2005 16:12:12 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Simple use-vs-require problem
Message-Id: <3qidnV1OTuaxK2vcRVn-hw@comcast.com>
clarence@silcom.com wrote:
> This has to be about the simplest question ever. And I was quite
> competent with perl before I stopped using it 7 years ago. I've
> been banging my head against the camel book (and the wall) for two
> hours now... I'm using Perl 5.8.6
>
> I have a module file called mod.pm, containing:
> sub P {
> print "in P()\n";
> }
> return 1;
> if I do
> $ perl
> use mod;
> P();
> I get
> in P()
>
> If I do
> $ perl
> require mod;
> mod::P();
> I get
> Undefined subroutine &mod::P called at - line 2.
> What the heck is wrong with that?
>
Why would think that the sub "P" is in the "mod" package?
It can't be, because there IS no "mod" package; you never
defined one. You have a "mod" module, but not a "mod"
package. If you put "package mod;" at the top of mod.pm,
then all the global symbols you define in mod.pm will
then be part of package "mod". Note that now your
*first* program will break, because you haven't exported
P out of mod...
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: 25 Jan 2005 14:08:00 -0800
From: clarence@silcom.com
Subject: Re: Simple use-vs-require problem
Message-Id: <1106690880.444712.324690@z14g2000cwz.googlegroups.com>
Thanks, all. I think if I had put on my (rarely used) Java hat, I would
have found that. But wearing my usual Python gear, I think I never
would have.
------------------------------
Date: Tue, 25 Jan 2005 22:41:49 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Simple use-vs-require problem
Message-Id: <Xns95E9B40FB1CC3asu1cornelledu@127.0.0.1>
clarence@silcom.com wrote in news:1106690880.444712.324690
@z14g2000cwz.googlegroups.com:
> Thanks, all. I think if I had put on my (rarely used) Java hat, I would
> have found that. But wearing my usual Python gear, I think I never
> would have.
I am not sure if you are aware of the fact that this is a Perl group.
Maybe there is a point to your post, but it is lost based on the fact that
you did not quote what you are replying to.
Say six months from now someone searches the newsgroup archives for "use-
vs-require" and stumbles upon this message. Will there be any information
of use in this message?
Please quote properly.
Sinan.
------------------------------
Date: 25 Jan 2005 21:24:19 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Testing for postgres index
Message-Id: <slrncvde83.ev3.abigail@alexandra.abigail.nl>
Mr. M.J. Lush (mlush@hgmp.mrc.ac.uk) wrote on MMMMCLXV September MCMXCIII
in <URL:news:ct5jug$rrk$1@helium.hgmp.mrc.ac.uk>:
??
?? Saying 'An answer exists' without providing at least a clue as to the nature
?? of the answer is unhelpful
*PLONK*
Abigail
--
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/ xor !@ _?
exit print :
print and push @_ => shift and goto &{(caller (0)) [3]}}
split // => "KsvQtbuf fbsodpmu\ni flsI " xor & _
------------------------------
Date: Tue, 25 Jan 2005 20:53:41 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: The world's shortest 'Hello World!' program: a proposal
Message-Id: <0k7dv0tkutt1ie4adn8ih1vd3qr783djjv@4ax.com>
On Thu, 20 Jan 2005 19:42:21 +0000 (UTC), Hue-Bond
<responder_solo_en_el_grupo@yahoo.es> wrote:
>I'm quitting this thread since IMO it's stupid to argue about whether an
>empty string is a program.
Well: not an attempt to revamp a hopefully dead thread, but just in
case after all you're still following it, be it stupid or not I hadn't
the impression that anybody was arguing _wether_ an empty string is a
program. In fact in Perl (that is) it _is_ a valid program, period.
You can think what you like of this circumstance, but it is not so
obvious, since it is definitely not true of other languages.
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: Tue, 25 Jan 2005 20:53:54 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: The world's shortest 'Hello World!' program: a proposal
Message-Id: <e48dv019e8lolnpneb3i9dmk7iaal0q5se@4ax.com>
[Note: I had begun following up to the referenced post either before
or shortly after the announce of my leaving, so I'm posting this just
for completeness... ;-) ]
On Thu, 20 Jan 2005 21:55:35 -0000, "Leonard Challis"
<perl@lennychallis.co.uk> wrote:
>X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
This line tells that you're using a real newsreader[*] (even if
others' opinion may vary!) so you can properly quote messages you
reply to. It is important to include quotes and attributions to
underline clearly what one is referring to.
>I think the _original_ point was that if you had "script.pl" and that
>contained _no_ data, instead of doing nothing, the Perl Interpreter cheekily
>outputted "Hello World!" or something.
Ouch, (the original text was so convoluted[**] that) I must admit I
hadn't understood that.
>Let us not argue! :D
I don't think anybody was arguing. And _really_ this is not an attempt
at reviving that thread...
[*] As opposed (e.g.) to the web interface from Google groups that is
causing some problems nowadays, (but really the new "Beta" version is
already working properly even if by means of a slightly awkward
mechanism, IMHO).
[**] At least that is a nice excuse!
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: 25 Jan 2005 17:34:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: trying to "use Sys::Syslog" but I get nothing ...
Message-Id: <ct5vuq$6j6$1@mamenchi.zrz.TU-Berlin.DE>
Karen Wieprecht <karen.wieprecht@jhuapl.edu> wrote in comp.lang.perl.misc:
>
> > which log file are *.notice msgs logged?
>
> They all go to /var/adm/SYSLOG.
>
>
> > best guess would be:
> > 0. the msgs are being logged but not where you think/want them logged.
> > 1. there is a problem with /etc/syslog.conf.
>
> I tested
> logger -p local5.notice "this is a test"
> and it came out exactly where I expected it.
>
>
> I also tested the return values of openlog (it was 1) and each syslog call
> with my various strings, and I got the following values :
> 53,58,60,62,65,75
That leaves the call to setlogsock, though for me it dies with an invalid
argument. Anyway, check its return value too, also try leaving it out
altogether.
> But I'm still not getting anything in syslog...
>
> Anyone know if I need to have the options in all caps
Not for me. Consult your local "man syslogd".
or if the quotes
> should be single rather than double?
The type of quotes doesn't matter. Only Perl sees them, not syslog.
> This is very frustrating ...
Your main problem is that no-one can reproduce what you're seeing. It's
hard to debug a problem you don't have. What version of Perl (perl -v),
and what version of Sys::Syslog
(perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION')
are you running?
Anno
------------------------------
Date: Tue, 25 Jan 2005 12:36:27 -0600
From: "terry l. ridder" <terrylr@blauedonau.com>
Subject: Re: trying to "use Sys::Syslog" but I get nothing ...
Message-Id: <Pine.LNX.4.61.0501251224190.6265@johann.blauedonau.com>
On Tue, 25 Jan 2005, Karen Wieprecht wrote:
>
>> which log file are *.notice msgs logged?
>
> They all go to /var/adm/SYSLOG.
>
>
on my computers they end up in /var/log/messages
that depends on /etc/syslog.conf
>
>
>> best guess would be:
>> 0. the msgs are being logged but not where you think/want them logged.
>> 1. there is a problem with /etc/syslog.conf.
>
> I tested
> logger -p local5.notice "this is a test"
> and it came out exactly where I expected it.
>
>
>
> I also tested the return values of openlog (it was 1) and each syslog call
> with my various strings, and I got the following values :
> 53,58,60,62,65,75
>
under perl 5.6 syslog returned the number of bytes written to the log.
>
> But I'm still not getting anything in syslog...
>
i thought that it may be a quirk in perl 5.6 so i fired up an old
computer that has perl 5.6 installed and tired the code snippet you
provided. it worked. the tests ended up in /var/log/messages.
Jan 25 12:18:22 strauss audit: this is a test
Jan 25 12:18:33 strauss audit: this is also a test.
Jan 25 12:18:40 strauss audit: this is a 3rd test.
>
> Anyone know if I need to have the options in all caps or if the quotes
> should be single rather than double? This is very frustrating ...
>
at this point i fall back to my original guess:
0. the msgs are being logged but not where you think/want them logged.
>
>
--
terry l. ridder ><>
------------------------------
Date: Tue, 25 Jan 2005 14:20:05 -0500
From: "Karen Wieprecht" <karen.wieprecht@jhuapl.edu>
Subject: Re: trying to "use Sys::Syslog" but I get nothing ...
Message-Id: <ct6658$1dh$1@aplcore.jhuapl.edu>
Anno,
Thanks for trying to help. the test for which version if Sys::Syslog was
very cool, I'll keep that one handy. Don't know if this helps or not, but
the output from
perl -v
is 5.6.1
perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION' is
0.01
Let me know if the version has known problems ...
Karen Wieprecht
------------------------------
Date: 25 Jan 2005 19:40:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: trying to "use Sys::Syslog" but I get nothing ...
Message-Id: <ct67c9$9ki$4@mamenchi.zrz.TU-Berlin.DE>
Karen Wieprecht <karen.wieprecht@jhuapl.edu> wrote in comp.lang.perl.misc:
> Anno,
>
> Thanks for trying to help. the test for which version if Sys::Syslog was
> very cool, I'll keep that one handy. Don't know if this helps or not, but
> the output from
>
> perl -v
> is 5.6.1
> perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION' is
> 0.01
>
> Let me know if the version has known problems ...
No idea, but both perl and Sys::Syslog are ancient. If upgrading is an
option at all, do that. Chances are, this and similar future problems
will go away.
Anno
------------------------------
Date: Tue, 25 Jan 2005 14:16:29 -0600
From: "terry l. ridder" <terrylr@blauedonau.com>
Subject: Re: trying to "use Sys::Syslog" but I get nothing ...
Message-Id: <Pine.LNX.4.61.0501251414540.8917@johann.blauedonau.com>
On Tue, 25 Jan 2005, Karen Wieprecht wrote:
> Anno,
>
> Thanks for trying to help. the test for which version if Sys::Syslog was
> very cool, I'll keep that one handy. Don't know if this helps or not, but
> the output from
>
> perl -v
> is 5.6.1
> perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION' is
> 0.01
>
those are the same versions that i tested on the old computer i fired up.
the code snippet works on that computer.
>
> Let me know if the version has known problems ...
>
> Karen Wieprecht
>
>
>
--
terry l. ridder ><>
------------------------------
Date: Tue, 25 Jan 2005 14:20:32 -0600
From: "terry l. ridder" <terrylr@blauedonau.com>
Subject: Re: trying to "use Sys::Syslog" but I get nothing ...
Message-Id: <Pine.LNX.4.61.0501251416450.8917@johann.blauedonau.com>
On Tue, 25 Jan 2005, Anno Siegel wrote:
> Karen Wieprecht <karen.wieprecht@jhuapl.edu> wrote in comp.lang.perl.misc:
>> Anno,
>>
>> Thanks for trying to help. the test for which version if Sys::Syslog was
>> very cool, I'll keep that one handy. Don't know if this helps or not, but
>> the output from
>>
>> perl -v
>> is 5.6.1
>> perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION' is
>> 0.01
>>
>> Let me know if the version has known problems ...
>
> No idea, but both perl and Sys::Syslog are ancient. If upgrading is an
> option at all, do that. Chances are, this and similar future problems
> will go away.
>
i agree that they are ancient, but they do work.
i tested the exact code snippet on an old computer running debian linux
distribution.
This is perl, v5.6.1 built for i386-linux
perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION'
0.01
the problem does not appear to be with perl.
i still am of the opinion that the msgs are being logged just not where
they are supposed to be logged.
>
> Anno
>
--
terry l. ridder ><>
------------------------------
Date: 25 Jan 2005 21:42:50 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: trying to "use Sys::Syslog" but I get nothing ...
Message-Id: <ct6egq$e6f$3@mamenchi.zrz.TU-Berlin.DE>
terry l. ridder <terrylr@johann.blauedonau.com> wrote in comp.lang.perl.misc:
> On Tue, 25 Jan 2005, Anno Siegel wrote:
>
> > Karen Wieprecht <karen.wieprecht@jhuapl.edu> wrote in comp.lang.perl.misc:
> >> Anno,
> >>
> >> Thanks for trying to help. the test for which version if Sys::Syslog was
> >> very cool, I'll keep that one handy. Don't know if this helps or not, but
> >> the output from
> >>
> >> perl -v
> >> is 5.6.1
> >> perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION' is
> >> 0.01
> >>
> >> Let me know if the version has known problems ...
> >
> > No idea, but both perl and Sys::Syslog are ancient. If upgrading is an
> > option at all, do that. Chances are, this and similar future problems
> > will go away.
> >
>
> i agree that they are ancient, but they do work.
> i tested the exact code snippet on an old computer running debian linux
> distribution.
>
> This is perl, v5.6.1 built for i386-linux
> perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION'
> 0.01
>
> the problem does not appear to be with perl.
> i still am of the opinion that the msgs are being logged just not where
> they are supposed to be logged.
I would agree if we hadn't this from the OP
I tested
logger -p local5.notice "this is a test"
and it came out exactly where I expected it.
Anno
------------------------------
Date: Tue, 25 Jan 2005 16:35:52 -0600
From: "terry l. ridder" <terrylr@blauedonau.com>
Subject: Re: trying to "use Sys::Syslog" but I get nothing ...
Message-Id: <Pine.LNX.4.61.0501251619380.10568@johann.blauedonau.com>
On Tue, 25 Jan 2005, Anno Siegel wrote:
> terry l. ridder <terrylr@johann.blauedonau.com> wrote in comp.lang.perl.misc:
>>
>>
>> i agree that they are ancient, but they do work.
>> i tested the exact code snippet on an old computer running debian linux
>> distribution.
>>
>> This is perl, v5.6.1 built for i386-linux
>> perl -MSys::Syslog -le 'print $Sys::Syslog::VERSION'
>> 0.01
>>
>> the problem does not appear to be with perl.
>> i still am of the opinion that the msgs are being logged just not where
>> they are supposed to be logged.
>
> I would agree if we hadn't this from the OP
>
> I tested
> logger -p local5.notice "this is a test"
> and it came out exactly where I expected it.
>
than the question becomes what operating system is the op running?
in reading syslog.pm there appears the following:
<begin quote>
A value of 'unix' will connect to the UNIX domain socket (in some
systems a character special device) returned by the C<_PATH_LOG> macro
(if your system defines it), or F</dev/log> or F</dev/conslog>,
whatever is writable. A value of 'stream' will connect to the stream
indicated by the pathname provided as the optional second parameter.
(For example Solaris and IRIX require 'stream' instead of 'unix'.)
A value of 'inet' will connect to an INET socket (either tcp or udp,
tried in that order) returned by getservbyname(). 'tcp' and 'udp' can
also be given as values. The value 'console' will send messages
directly to the console, as for the 'cons' option in the logopts in
openlog().
<end quote>
so instead of
setlogsock ("unix");
it would be
setlogsock ("stream");
other than that i am out of ideas.
>
> Anno
>
--
terry l. ridder ><>
------------------------------
Date: 25 Jan 2005 13:11:53 -0800
From: laredotornado@zipmail.com
Subject: Using Net::FTP to get a file I almost know the name of
Message-Id: <1106687513.073804.70650@z14g2000cwz.googlegroups.com>
Hello, I am using Net::FTP and I was wondering how I can retrieve a
file if I know three things
1. The extension (e.g. ".txt")
2. The directory in which the file will appear
3. There will be at most one file in that directory with the given
extension.
How would i go about figuring out the full path to that file so that I
can use the Net::FTP->get command?
Thanks, - Dave
------------------------------
Date: 25 Jan 2005 21:54:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Using Net::FTP to get a file I almost know the name of
Message-Id: <ct6f6v$e6f$4@mamenchi.zrz.TU-Berlin.DE>
<laredotornado@zipmail.com> wrote in comp.lang.perl.misc:
> Hello, I am using Net::FTP and I was wondering how I can retrieve a
> file if I know three things
>
> 1. The extension (e.g. ".txt")
> 2. The directory in which the file will appear
> 3. There will be at most one file in that directory with the given
> extension.
>
> How would i go about figuring out the full path to that file so that I
> can use the Net::FTP->get command?
You read the documentation of the module you're using. Take special
note of the ->ls and ->dir methods. Use pattern matching to recognize
the file you want.
Anno
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 7692
***************************************