[11357] in Perl-Users-Digest
Perl-Users Digest, Issue: 4958 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 26 11:19:35 1999
Date: Fri, 26 Feb 99 08:11:08 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 26 Feb 1999 Volume: 8 Number: 4958
Today's topics:
<> doesn't trigger $SIG {__WARN__} ? (Abigail)
Re: <> doesn't trigger $SIG {__WARN__} ? (Bart Lateur)
Re: <> doesn't trigger $SIG {__WARN__} ? (Abigail)
Re: <> doesn't trigger $SIG {__WARN__} ? (Matthew Bafford)
Re: @files = <*.*>; doesn't work (Doran L. Barton)
[ANNOUNCE] PGP::Sign 0.14 now available <rra@stanford.edu>
[Fwd: A problem mixing Perl and Yacc/Bison] <fworley@dal.asp.ti.com>
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
[Q] problem with SIG{ALRM} to imposing timout <neochi@chollian.net>
Re: [Q] problem with SIG{ALRM} to imposing timout (Bart Lateur)
Re: [Q] problem with SIG{ALRM} to imposing timout <neochi@chollian.net>
about 'require' dubing@lisco.com
Re: about 'require' <donny@impulsesoftware.com>
Re: about 'require' <Allan@due.net>
Re: about 'require' (Greg Bacon)
Re: about 'require' <stampes@xilinx.com>
Accented characters on directory name <mmiguel@icao.int>
Access to last char of $1 (or $2...) <dmulholl@cs.indiana.edu>
Accessing *.pm and *.pl scripts/modules not in LIB thst@my-dejanews.com
Re: Accessing *.pm and *.pl scripts/modules not in LIB <tchrist@mox.perl.com>
Re: ActiveState GDBM or Equivalent? <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
alpha numeric limiter <aaron@tyc.net>
Re: alpha numeric limiter <jeffp@crusoe.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Feb 1999 08:16:53 GMT
From: abigail@fnx.com (Abigail)
Subject: <> doesn't trigger $SIG {__WARN__} ?
Message-Id: <7b30tl$qm7$1@client2.news.psi.net>
$ perl -w
$SIG {__WARN__} = sub {print "hello\n"};
@ARGV = ("/nonexistent");
while (<>) {}
__END__
Can't open /nonexistent: No such file or directory
$
Why doesn't it call the sub set to $SIG {__WARN__} ?
I looked in perlopentut, but that doesn't say much about trying to open
non-existing files.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Thu, 25 Feb 1999 09:29:21 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: <> doesn't trigger $SIG {__WARN__} ?
Message-Id: <36d817d5.4469686@news.skynet.be>
Abigail wrote:
>$SIG {__WARN__} = sub {print "hello\n"};
>@ARGV = ("/nonexistent");
>while (<>) {}
>__END__
>Can't open /nonexistent: No such file or directory
>$
>
>
>Why doesn't it call the sub set to $SIG {__WARN__} ?
Doesn't it die instead of just warn?
Bart.
------------------------------
Date: 25 Feb 1999 16:40:29 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: <> doesn't trigger $SIG {__WARN__} ?
Message-Id: <7b3udt$127$1@client2.news.psi.net>
Bart Lateur (bart.lateur@skynet.be) wrote on MMIV September MCMXCIII in
<URL:news:36d817d5.4469686@news.skynet.be>:
@@ Abigail wrote:
@@
@@ >$SIG {__WARN__} = sub {print "hello\n"};
@@ >@ARGV = ("/nonexistent");
@@ >while (<>) {}
@@ >__END__
@@ >Can't open /nonexistent: No such file or directory
@@ >$
@@ >
@@ >
@@ >Why doesn't it call the sub set to $SIG {__WARN__} ?
@@
@@ Doesn't it die instead of just warn?
No, I tested for that:
$ perl -w
$SIG {__WARN__} = sub {print "hello\n"};
@ARGV = ("/nonexistent");
while (<>) {}
print "Alive and kicking!\n"
__END__
Can't open /nonexistent: No such file or directory
Alive and kicking!
$
Abigail
--
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))
------------------------------
Date: Thu, 25 Feb 1999 16:47:47 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: <> doesn't trigger $SIG {__WARN__} ?
Message-Id: <slrn7davd5.nr4.dragons@Server.Network>
Thu, 25 Feb 1999 09:29:21 GMT -- Bart Lateur <bart.lateur@skynet.be>:
-> Doesn't it die instead of just warn?
Apparently not:
% perl -w-
$SIG{__DIE__} = sub { print "__DIE__\n" };
$SIG{__WARN__} = sub { print "__WARN__\n" };
@ARGV = ('/notthere');
while (<>) {}
__END__
Can't open /notthere: No such file or directory
% perl -w-
$SIG{__DIE__} = sub { print "__DIE__\n" };
$SIG{__WARN__} = sub { print "__WARN__\n" };
warn "Foo\n";
die "Bar\n";
__END__
__WARN__
__DIE__
Bar
%
-> Bart.
--Matthew
------------------------------
Date: 21 Feb 1999 20:54:26 -0700
From: fozz@xmission.xmission.com (Doran L. Barton)
Subject: Re: @files = <*.*>; doesn't work
Message-Id: <7aqkdi$r0a$1@xmission.xmission.com>
stlee@cisco.com (Steven Lee) writes:
>I am running Perl version 5.005_02, build 509 with 1 registered patch
>by ActiveState. The filename glob operator does not seem to work on
>Windows 95.
>@files = <*.*>;
>I get back an empty array even though there are files in the current
>directory. This works on my Sun workstation.
Hmmm. Try using the glob() function and see if that solves your problem.
--
Doran L. Barton = fozz@xmission.com && http://www.xmission.com/~fozz/
"Where do you want Microsoft to go today?" --Ronald Barry
"This may seem a bit weird, but that's okay, because it is weird."
-- Larry Wall in the Perl v5 man page
------------------------------
Date: 24 Feb 1999 16:50:32 GMT
From: Russ Allbery <rra@stanford.edu>
Subject: [ANNOUNCE] PGP::Sign 0.14 now available
Message-Id: <7b1ako$sqp$1@play.inetarena.com>
PGP::Sign version 0.14
(Create and verify detached PGP signatures for data)
I am pleased to announce that version 0.14 of my PGP::Sign Perl module is
now available. It's winding its way through PAUSE on the way to CPAN as I
write this, or you can download it directly from:
<URL:ftp://ftp.eyrie.org/pub/software/modules/PGP-Sign-0.14.tar.gz>
An excerpt from the README:
One important thing to clear up right away:
THIS IS NOT A GENERAL PGP MODULE
For wonderful general PGP modules that will encrypt, decrypt, manage key
rings, slice, dice, fold, spindle, and mutilate your data, see the PGP
by-module directory at your local CPAN mirror; hopefully there will be
one there. This module sprung out of a need to do one thing and one
thing only, do it securely, and do it well. This module creates and
checks detached signatures for data. That's it. If you want to do
anything else that PGP lets you do, look elsewhere.
There are extensive improvements from the previous version, and even more
extensive improvements from the previously widely announced version. The
most notable change is that PGP::Sign now supports PGP 5.0 and GnuPG as
well as PGP 2.6.2. Which style of PGP you are using is determined at
installation time and becomes the default; the PGP program and style can
also be set at run time if you have multiple versions of PGP installed.
In addition, the build process is now somewhat cleaner, easier to
automate, and better documented. The documentation has been expanded
somewhat, particular in its discussion of incompatibilities between
different PGP implementations that may affect your application. There is
also now a TODO file sketching out possible future improvements.
In the process of putting together this release, I noted several things
about the current API that didn't make a great deal of sense, so it's
possible that some of the API will be changing in the next few releases.
I will try to keep the changes backwards-compatible as much as possible,
but I consider this module to still be in beta and therefore you may need
to change the way you call it after future upgrades. This version,
however, should be fully backwards compatible with all previous released
versions.
My thanks to Todd Underwood <todd@nm.net> for the impetus to get this
module working under GnuPG and PGP 5.0, and to him and Monte Mitzelfelt
<monte@nm.net> for the initial GnuPG implementation that I based mine on.
Please see the package documentation and README for further details.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Thu, 25 Feb 1999 08:42:39 -0600
From: Frazer Worley <fworley@dal.asp.ti.com>
Subject: [Fwd: A problem mixing Perl and Yacc/Bison]
Message-Id: <36D5615F.1F94BA4A@dal.asp.ti.com>
This is a multi-part message in MIME format.
--------------25593EB34E4DB2D33C16A222
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
--
---------------------------------------------------------------------------
Phone: +01-972-480-2845 Email: fworley@daldd.sc.ti.com
Fax: +01-972-480-3020 TI_MSGID: FJ
Address: M/S 8635, Texas Instruments, 8505 Forest Lane, Dallas, Tx, 75243
--------------25593EB34E4DB2D33C16A222
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
x-uunet-gateway: relay4.UU.NET from bug-gnu-utils to gnu.utils.bug; Thu, 25 Feb 1999 09:32:07 EST
Path: sislnews.csc.ti.com!news.ti.com!attmtf!ip.att.net!prairie.attcanada.net!rockie.attcanada.net!attcanada!europa.clark.net!208.134.241.18!newsfeed.cwix.com!192.220.250.21!netnews1.nw.verio.net!netnews.nwnet.net!uunet!wendy-fate.uu.net!not-for-mail
From: fworley@daldd.sc.ti.com (Frazer Worley)
Subject: A problem mixing Perl and Yacc/Bison
Date: Thu, 25 Feb 1999 08:29:45 -0600
Organization: Texas Instruments
Message-ID: <36D55E59.F3D2B757@daldd.sc.ti.com>
NNTP-Posting-Host: pinay.daldd.sc.ti.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: superb.csc.ti.com 919952990 18741 172.24.190.42 (25 Feb 1999 14:29:50 GMT)
X-Complaints-To: abuse@ti.com
NNTP-Posting-Date: 25 Feb 1999 14:29:50 GMT
X-Mailer: Mozilla 4.5 [en] (X11; I; SunOS 5.7 sun4u)
X-Accept-Language: en
Approved: bug-gnu-utils-request@mail.gnu.org
Newsgroups: gnu.utils.bug
Sender: bug-gnu-utils-request@mail.gnu.org
Xref: sislnews.csc.ti.com gnu.utils.bug:20123
I'm having trouble embedding Perl in a C++ application which incorporates
a Bison parser.
The issue stems from name spaces - and specifically collisions for Yacc/Bison
generated variables:
yychar, yydebug, yyerror, yylex, yylval, yynerrs, yyparse.
I'm using Bison so that I can have multiple parsers in my application. I use
the '-p' switch which gets around the above problem.
It doesn't get around the problem though for use with Perl as you can see below:
------------------------------------------------------------------------------------------------------------
In file included from /db/mercury/tools/perl5.005_02/lib/5.00502/sun4-solaris/CORE/perl.h:139,
from /apps/cad_tools/src/utils/oo_src/include/PerlInterp.h:9,
from include/Instruction.h:15,
from include/InstructionBlock.h:7,
from include/Assembler.h:9,
from asm.yacc:4:
/db/mercury/tools/perl5.005_02/lib/5.00502/sun4-solaris/CORE/embed.h:1064: warning: `yychar' redefined
derived/asm_parser.c:12: warning: this is the location of the previous definition
/db/mercury/tools/perl5.005_02/lib/5.00502/sun4-solaris/CORE/embed.h:1066: warning: `yydebug' redefined
derived/asm_parser.c:13: warning: this is the location of the previous definition
/db/mercury/tools/perl5.005_02/lib/5.00502/sun4-solaris/CORE/embed.h:1071: warning: `yyerror' redefined
derived/asm_parser.c:10: warning: this is the location of the previous definition
/db/mercury/tools/perl5.005_02/lib/5.00502/sun4-solaris/CORE/embed.h:1074: warning: `yylex' redefined
derived/asm_parser.c:9: warning: this is the location of the previous definition
/db/mercury/tools/perl5.005_02/lib/5.00502/sun4-solaris/CORE/embed.h:1076: warning: `yylval' redefined
derived/asm_parser.c:11: warning: this is the location of the previous definition
/db/mercury/tools/perl5.005_02/lib/5.00502/sun4-solaris/CORE/embed.h:1078: warning: `yynerrs' redefined
derived/asm_parser.c:14: warning: this is the location of the previous definition
/db/mercury/tools/perl5.005_02/lib/5.00502/sun4-solaris/CORE/embed.h:1079: warning: `yyparse' redefined
derived/asm_parser.c:8: warning: this is the location of the previous definition
In file included from asm.yacc:354:
derived/asm_lexer.c:13: warning: `yylex' redefined
/db/mercury/tools/perl5.005_02/lib/5.00502/sun4-solaris/CORE/embed.h:1074: warning: this is the location of the previous definition
include/Assembler.h: In method `void Assembler::AddInstructionBlock(const class InstructionBlock *)':
In file included from asm.yacc:4:
------------------------------------------------------------------------------------------------------------
The problem - as I see it - is that #define is used to rename yylex ... yyparse in embed.h.
Bison identical code in the top of its generated parsers ... and if the parser eventually includes
embed.h - as mine does (I use Perl's substitution) - then you have the name collisions.
Now - I realise that I can work around this issue. But quite frankly - thats beside the point,
I shouldn't have to. The Perl regexp parser shouldn't have variables named yynerrs etc. They
should be renamed (and not by pre-processor trickery) to something more appropriate and portable.
May I suggest: perl_regexp_nerrs, perl_regexp_lval etc.
This would be easy to do:
perl_regexp_parser.c: perl_regexp.yacc ${DERIVED_DIR}/perl_regexp_lexer.c
${BISON} -vd perl_regexp.yacc -o $@
perl -pi -e 's/YY/PERL_REGEXP_/g' $@ $*.h
perl -pi -e 's/yy/perl_regexp_/g' $@ $*.h
perl_regexp_lexer.c: perl_regexp.lex
${FLEX} -i -o$@ $?
perl -pi -e 's/YY/PERL_REGEXP_/g' $@
perl -pi -e 's/yy/perl_regexp_/g' $@
Hope somebody takes this action on.
Sorry for grumbling (I like Perl really :-)
-Frazer
--
---------------------------------------------------------------------------
Phone: +01-972-480-2845 Email: fworley@daldd.sc.ti.com
Fax: +01-972-480-3020 TI_MSGID: FJ
Address: M/S 8635, Texas Instruments, 8505 Forest Lane, Dallas, Tx, 75243
--------------25593EB34E4DB2D33C16A222--
------------------------------
Date: Wed, 24 Feb 1999 11:25:01 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage919855441.8612@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 10 Sep 1998
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last major update of the Perl FAQ was in Summer of
1998; of course, ongoing updates are made as needed. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://cpan.perl.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://cpan.perl.org/
http://www.perl.com/CPAN/
http://cpan.perl.org/doc/FAQs/FAQ/html/
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
Another possibility is to use one of the FTP-via-email services; for
more information on doing that, send mail to <mail-server@rtfm.mit.edu>
(not to me!) with these lines in the body of the message, flush left:
setdir usenet-by-group/news.announce.newusers
send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 22 Feb 1999 03:16:37 GMT
From: Ini Chung <neochi@chollian.net>
Subject: [Q] problem with SIG{ALRM} to imposing timout
Message-Id: <36D0CB94.7A4736EB@chollian.net>
Hi,
I'm writing some code with SIG{ALRM} like this :
$SIG{ALRM} = \@sigAlarmHandler;
sub main {
foreach $system (@systemlist) {
& doing($system);
}
}
sub doing {
my $system = shift;
alarm 60;
open (CMD, "$somecmd $system | ") || return;
while (<CMD>) { do........ }
close CMD;
MARK:
alarm 0 ;
return;
}
sub sigAlarmHandler {
goto MARK;
}
My problem is when SIG{ALRM} received in the middle of 'foreach' loop,
the rest systems of 'foreach' loop also treated as receiving SIG{ALRM}.
I want to run the entiry loop properly.
Any help would be very appreciated.
------------------------------
Date: Tue, 23 Feb 1999 09:35:27 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: [Q] problem with SIG{ALRM} to imposing timout
Message-Id: <36d4707e.1030228@news.skynet.be>
Ini Chung wrote:
> $SIG{ALRM} = \@sigAlarmHandler;
That "@" is wrong. It should be "&".
> sub main {
> foreach $system (@systemlist) {
> & doing($system);
> }
> }
>
> sub doing {
> my $system = shift;
>
> alarm 60;
> open (CMD, "$somecmd $system | ") || return;
>
> while (<CMD>) { do........ }
> close CMD;
>
> MARK:
> alarm 0 ;
> return;
> }
>
> sub sigAlarmHandler {
> goto MARK;
> }
That doesn't look like the "right way" to do it. Besides, you should not
jump outside your routine. It ought to fail to even compile, but, at
least, if it runs, it won't interrupt the main routine loop.
The right way would be to make the $SIG{ALRM} routine die, and trap it
in an eval BLOCK. Remember that eval BLOCK has NO speed implications
whatsoever, since the code is precompiled. All it does is catch the
(otherwise) fatal errors.
This is my variant (untested):
> sub main {
> foreach $system (@systemlist) {
> & doing($system);
> }
> }
> sub doing {
> my $system = shift;
eval {
local $SIG{ALRM} = \&sigAlarmHandler;
> alarm 60;
> open (CMD, "$somecmd $system | ") || return;
>
> while (<CMD>) { do........ }
> close CMD;
> alarm 0 ;
}
if ($@) {
die $@ unless $@=~ /^Tired of waiting/;
}
> }
>
> sub sigAlarmHandler {
die "Tired of waiting.";
> }
Bart.
------------------------------
Date: Wed, 24 Feb 1999 04:51:04 GMT
From: Ini Chung <neochi@chollian.net>
Subject: Re: [Q] problem with SIG{ALRM} to imposing timout
Message-Id: <36D38514.D5C2A985@chollian.net>
Thank you, Bart. :-)
Actually, I had tried 'eval statement' as you suggested before posting, but
there was a same problem.
Once the process receiving SIGALRM in the middle of the loop,
the rest of the loop is processed as receiving SIGALRM.
Ini.
------------------------------
Date: Thu, 25 Feb 1999 19:34:17 GMT
From: dubing@lisco.com
Subject: about 'require'
Message-Id: <7b48jo$djh$1@nnrp1.dejanews.com>
I have two scripts test.cgi and read_input.pl in Perl.
In test.cgi,
....
require ("read_input.pl");
....
'test.cgi' and 'read_input.pl' are underneath the same directory.
When I run test.cgi, I got the following message:
"read_input.pl did not return a true value at ./test.cgi line 7." This line 7
is just 'require....' showed above.
However if I put the content of 'read_input.pl' directly in test.cgij instead
of using 'require', everything worked fine. What was wrong?
Any suggestion would be great!
Bing
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 25 Feb 1999 20:22:47 GMT
From: Donny Widjaja <donny@impulsesoftware.com>
Subject: Re: about 'require'
Message-Id: <36D5B133.A7C4B47@impulsesoftware.com>
At the end of your read_input.pl type 1;
example:
read_input.pl
## Beginning of file
[your code]
....
....
....
1;
## End of file
dubing@lisco.com wrote:
>
> I have two scripts test.cgi and read_input.pl in Perl.
>
> In test.cgi,
>
> ....
> require ("read_input.pl");
> ....
>
> 'test.cgi' and 'read_input.pl' are underneath the same directory.
>
> When I run test.cgi, I got the following message:
>
> "read_input.pl did not return a true value at ./test.cgi line 7." This line 7
> is just 'require....' showed above.
>
> However if I put the content of 'read_input.pl' directly in test.cgij instead
> of using 'require', everything worked fine. What was wrong?
>
> Any suggestion would be great!
>
> Bing
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 25 Feb 1999 15:36:03 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: about 'require'
Message-Id: <7b4brs$eq8$1@camel15.mindspring.com>
dubing@lisco.com wrote in message <7b48jo$djh$1@nnrp1.dejanews.com>...
:I have two scripts test.cgi and read_input.pl in Perl.
:In test.cgi,
: ....
: require ("read_input.pl");
: ....
:'test.cgi' and 'read_input.pl' are underneath the same directory.
:When I run test.cgi, I got the following message:
:"read_input.pl did not return a true value at ./test.cgi line 7." This
line 7
:is just 'require....' showed above.
:However if I put the content of 'read_input.pl' directly in test.cgij
instead
:of using 'require', everything worked fine. What was wrong?
:Any suggestion would be great!
Interestingly the answer is in your post. The error message says
read_input.pl did not return a true value at ./test.cgi line 7. The file
being required must return a true value. The commonly followed convention
is to place a 1(true) at the end of your script. Just make
1;
the last line of your required file. And you don't need those () around the
required file name.
HTH
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
Hey, I had to let awk be better at *something*... :-)
Larry Wall in <1991Nov7.200504.25280@netlabs.com>1
------------------------------
Date: 25 Feb 1999 20:24:03 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: about 'require'
Message-Id: <7b4bh3$fb9$1@info.uah.edu>
In article <7b48jo$djh$1@nnrp1.dejanews.com>,
dubing@lisco.com writes:
: When I run test.cgi, I got the following message:
:
: "read_input.pl did not return a true value at ./test.cgi line 7."
: This line 7 is just 'require....' showed above.
The diagnostics pragma is often helpful when you don't understand
error or warning messages. Your situation is no exception. You
will find the documentation on diagnostics and perldiag extremely
helpful.
Greg
--
There is always death and taxes. However death doesn't get worse every year.
------------------------------
Date: 25 Feb 1999 20:23:56 GMT
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: about 'require'
Message-Id: <7b4bgs$7q2@courier.xilinx.com>
dubing@lisco.com wrote:
: ....
: require ("read_input.pl");
: ....
: "read_input.pl did not return a true value at ./test.cgi line 7." This line 7
: is just 'require....' showed above.
perldoc perldiag contains all of perl's diagnostic messages and what
they mean to you:
%s did not return a true value
(F) A required (or used) file must return a true value
to indicate that it compiled correctly and ran its
initialization code correctly. It's traditional to end
such a file with a "1;", though any true value would do.
See the require entry in the perlfunc manpage.
okay...
stampes@huckin [19] perldoc -f require
=item require EXPR
=item require
Demands some semantics specified by EXPR, or by $_ if EXPR is not
supplied. If EXPR is numeric, demands that the current version of Perl
(C<$]> or $PERL_VERSION) be equal or greater than EXPR.
Otherwise, demands that a library file be included if it hasn't already
been included. The file is included via the do-FILE mechanism, which is
essentially just a variety of eval(). Has semantics similar to the following
subroutine:
sub require {
local($filename) = @_;
return 1 if $INC{$filename};
local($realfilename,$result);
ITER: {
foreach $prefix (@INC) {
$realfilename = "$prefix/$filename";
if (-f $realfilename) {
$result = do $realfilename;
last ITER;
}
}
die "Can't find $filename in \@INC";
}
die $@ if $@;
die "$filename did not return true value" unless $result;
$INC{$filename} = $realfilename;
$result;
}
Note that the file will not be included twice under the same specified
name. The file must return TRUE as the last statement to indicate
successful execution of any initialization code, so it's customary to
end such a file with "1;" unless you're sure it'll return TRUE
otherwise. But it's better just to put the "C<1;>", in case you add more
statements.
If EXPR is a bareword, the require assumes a "F<.pm>" extension and
replaces "F<::>" with "F</>" in the filename for you,
to make it easy to load standard modules. This form of loading of
modules does not risk altering your namespace.
For a yet-more-powerful import facility, see L</use> and
L<perlmod>.
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Wed, 24 Feb 1999 16:36:51 -0500
From: "Marco A. Miguel" <mmiguel@icao.int>
Subject: Accented characters on directory name
Message-Id: <36D470F3.79C2F682@icao.int>
Hi to all,
I am a novice to Perl, and I used the script below to generate an ASCII
list of
all files and pathnames on a Windows NT filesystem.
It works pretty well, except on a directory named Srganos
Representativos
(Spanish). The S character (/xd3) breaks the script and nothing under
that
directory gets listed.
Besides dropping the accent, would someone out there have a suggestion?
Thanks in advance.
Marco Miguel
mmiguel(nospam)@icao.int
##################
use File::Find;
sub wanted {
my $path;
$path = $File::Find::name;
print "$path\n";
if (-f "$_" ) {
$path =~ tr(\\)(\/);
$path =~ s/ /%20/go;
@items = split("\/",$path);
print DIRLIST "\"$items[$#items]\",";
print DIRLIST "\"";
for $i (2,4..$#items-1) {
print DIRLIST "$items[$i]/";
}
print DIRLIST "\"\n";
}
}
open DIRLIST,">dir.txt";
find(\&wanted, @ARGV);
--
Marco A. Miguel - mmiguelNOSPAM@icao.int
Technical Support Analyst - I.C.A.O. - Montreal - Canada
Tel. (514) 954-6264 Fax: (514) 954-8249
The views (and opinions) expressed in this message are from
the author and do not necessarily represent those of ICAO
------------------------------
Date: Mon, 22 Feb 1999 10:44:53 GMT
From: Daniel Yacob <dmulholl@cs.indiana.edu>
Subject: Access to last char of $1 (or $2...)
Message-Id: <7arcf3$nlh$1@nnrp1.dejanews.com>
Greetings,
Iam trying to form an expression that would test the last char of a
matched expression. Something in form of:
/...(?(is-last-char-of-$1-of-\p{MyP}) yes-pattern|no-pattern).../
Through an escape or a $1 index do we have access to the last char in $1?
thanks,
/Daniel
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sun, 21 Feb 1999 21:02:31 GMT
From: thst@my-dejanews.com
Subject: Accessing *.pm and *.pl scripts/modules not in LIB
Message-Id: <7aps92$g9g$1@nnrp1.dejanews.com>
If I declare in a perl script something like
require xxxx.pl
or
use yyyyy.pm
The refering modules should be in the LIB-path of the perl library.
But what if I am not able to put the required modules into that LIB-Path
(because I am not the sys admin) ? How can I use these modules anyway ?
Bye
Thomas
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 21 Feb 1999 14:36:58 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Accessing *.pm and *.pl scripts/modules not in LIB
Message-Id: <36d07c7a@csnews>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
thst@my-dejanews.com writes:
:If I declare in a perl script something like
:
:require xxxx.pl
: or
:use yyyyy.pm
:
:The refering modules should be in the LIB-path of the perl library.
:But what if I am not able to put the required modules into that LIB-Path
:(because I am not the sys admin) ? How can I use these modules anyway ?
Somehow you appear to have missed the proper answer when you studiously
searched the standard Perl documentation on your very own system.
It was there waiting for you.
% man perlfaq8
NAME
perlfaq8 - System Interaction
($Revision: 1.36 $, $Date: 1999/01/08 05:36:34 $)
...
* What's the difference between require and use?
Perl offers several different ways to include code from one
file into another. Here are the deltas between the various
inclusion constructs:
1) do $file is like eval `cat $file`, except the former:
1.1: searches @INC and updates %INC.
1.2: bequeaths an *unrelated* lexical scope on the eval'ed code.
2) require $file is like do $file, except the former:
2.1: checks for redundant loading, skipping already loaded files.
2.2: raises an exception on failure to find, compile, or
execute $file.
3) require Module is like require "Module.pm", except the former:
3.1: translates each "::" into your system's directory separator.
3.2: primes the parser to disambiguate class Module as an
indirect object.
4) use Module is like require Module, except the former:
4.1: loads the module at compile time, not run-time.
4.2: imports symbols and semantics from that package to the
current one.
In general, you usually want `use' and a proper Perl module.
* How do I keep my own module/library directory?
When you build modules, use the PREFIX option when generating
Makefiles:
perl Makefile.PL PREFIX=/u/mydir/perl
then either set the PERL5LIB environment variable before you
run scripts that use the modules/libraries (see the perlrun
manpage) or say
use lib '/u/mydir/perl';
This is almost the same as:
BEGIN {
unshift(@INC, '/u/mydir/perl');
}
except that the lib module checks for machine-dependent
subdirectories. See Perl's the lib manpage for more
information.
How do I add the directory my program lives in to the module/library
search path?
use FindBin;
use lib "$FindBin::Bin";
use your_own_modules;
* How do I add a directory to my include path at runtime?
Here are the suggested ways of modifying your include path:
the PERLLIB environment variable
the PERL5LIB environment variable
the perl -Idir command line flag
the use lib pragma, as in
use lib "$ENV{HOME}/myown_perllib";
The latter is particularly useful because it knows about
machine dependent architectures. The lib.pm pragmatic module
was first included with the 5.002 release of Perl.
--
> (It's sorta like sed, but not. It's sorta like awk, but not. etc.)
Guilty as charged. Perl is happily ugly, and happily derivative.
--Larry Wall in <1992Aug26.184221.29627@netlabs.com>
------------------------------
Date: Tue, 23 Feb 1999 17:16:23 -0800
From: "Dave Roth" <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Subject: Re: ActiveState GDBM or Equivalent?
Message-Id: <IoIA2.8547$yv3.5434@news2.giganews.com>
John Kane wrote in message <36C31903.28202326@akanewmedia.com>...
>Can anyone tell me if a GDBM hash file module (or equivalent) exists for
>ActiveState PERL on the Windows platform?
>
>SDBM (and others) limit the hash value to 1000 characters. GDBM on UNIX
>allows much larger values. I want to use a hash file that allows large
>values on the windows platform.
We have a port of it available. Install it using the PPM.PL script:
perl ppm.pl install http://www.roth.net/perl/packages/GDBM_File.ppd
dave
--
=================================================================
Dave Roth ...glittering prizes and
Roth Consulting endless compromises, shatter
http://www.roth.net the illusion of integrity
Win32, Perl, C++, ODBC, Training
rothd at roth dot net
Our latest Perl book is now available:
"Win32 Perl Programming: The Standard Extensions"
http://www.roth.net/books/extensions/
------------------------------
Date: Mon, 22 Feb 1999 16:49:35 -0800
From: "aaron" <aaron@tyc.net>
Subject: alpha numeric limiter
Message-Id: <36d27ba2.0@news1.jps.net>
I have a form with multiple text inputs and I would like to restrict
non-alpha-numeric characters by means of an error response.
I thought this was part of CGI.pm but I read on the site and found nothing
on it.
I need to keep people from submitting things like )(&^%$#@!+-*/<>?,.\| into
the database. Especially pipes since the database is pipe delimited :-)
Thank you for your help! It is much appreciated.
Aaron
------------------------------
Date: Mon, 22 Feb 1999 21:57:31 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: alpha numeric limiter
Message-Id: <Pine.GSO.3.96.990222215423.12636C-100000@crusoe.crusoe.net>
> I have a form with multiple text inputs and I would like to restrict
> non-alpha-numeric characters by means of an error response.
You can either implement a simple regular expression, shown presently, or
use the function quotemeta(), which will escape all possibly hazardous
characters.
Keeping in mind local characters, this will work nicely:
for (@values){
die "Illegal character ($1) in $_!" if /([\W_])/;
}
--
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp
Crusoe Communications, Inc.
973-882-1022
www.crusoe.net
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4958
**************************************