[7615] in Perl-Users-Digest
Perl-Users Digest, Issue: 1241 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 28 21:14:11 1997
Date: Tue, 28 Oct 97 18:00:37 -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 Tue, 28 Oct 1997 Volume: 8 Number: 1241
Today's topics:
500 server error invoking perl script lusk@dg-rtp.dg.com
Adding names to a list :-( <raven@lp-llc.com>
Re: Adding names to a list :-( (Dave Schenet)
Re: Adding names to a list :-( <robert.hughes@amarest.com>
Re: ADVANCED: Clearing a namespace/package? (Ilya Zakharevich)
Can for loop be condensed using map()? (Paul L. Lussier)
Re: Class vars and "exists": Error in book (Tom Harrington)
Re: DBD-Oracle-0.47.tar.gz corrupted? (John D Groenveld)
Re: FOREACH command <jbokma@caiw.nl>
Re: fork() makes me wait (?) (Martien Verbruggen)
Re: Getting Autonumber ID after insert (Glenn Miyashiro)
Let's try this again - Help with Error <skooky@primenet.com>
Making perl a builtin command dtksh command on AIX 4.x (John L. Allen)
Re: Multiple filehandles (Tad McClellan)
Need to keep passwords off console during input <prl2@lehigh.edu>
Re: Need to keep passwords off console during input (E.None Archibald)
Re: Need to keep passwords off console during input <rich@mondial.net.au>
Re: padding digits... plambert$1@plambert.org
Re: perl newbie needs help <rpsavage@ozemail.com.au>
return question <joegottman@worldnet.att.net>
Re: Simulating ${parm:-$parm2} (E.None Archibald)
Re: Simulating ${parm:-$parm2} <valentin@cssdomain.com>
Re: Using Perl Modules (Tad McClellan)
Re: Year2000 problem with localtime(); <rra@stanford.edu>
Re: Year2000 problem with localtime(); (Abigail)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 28 Oct 1997 18:42:08 -0600
From: lusk@dg-rtp.dg.com
To: lusk@dg-rtp.dg.com
Subject: 500 server error invoking perl script
Message-Id: <878084920.1309@dejanews.com>
Help! I'm just getting started putting up an intranet page on NT
Workstation using the FrontPage98 demo (w/its "Personal Web Server") and
I'd like to use my Unix knowledge in writing a cgi-bin perl script to
handle the input from a form. I'm interested in getting results fast,
and I don't feel like writing a C program to do what cgi-lib already does
for me (and what Perl already does, for that matter).
However, when I invoke a url to a simple hello world script
(http://<host>/cgi-bin/hello.pl), I get a 500 server error, and the error
log sez:
httpd: could not create new process: 193
I don't see anybody else having any trouble, so I must be doing something
simple wrong. Can anybody help me?
Thanks.
John.
(lusk@dg-rtp.dg.com)
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Tue, 28 Oct 1997 15:35:50 -0800
From: Matt McLaughlin <raven@lp-llc.com>
Subject: Adding names to a list :-(
Message-Id: <345676D5.4AE5FB91@lp-llc.com>
I am trying to add names to a LIST, but so far I have been unsuccessful.
When running perl-w on my shell, everything checks out. When running it
from the web, I get an ERROR 500.
At one time this script was almost a full blown program - God (or
Larry), it was a masterpiece! Now it's down to a pretty simple script
about 15 lines of code that don't work.
If any one could give me a hint, I'd appreciate it.
#!/usr/bin/perl
$LIST="/usr/local/lib/httpd/cgi-bin/raven/ooops/list";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$FORM{$name}=$value;
}
# STOLEN FROM Matt Wright
if ($FORM{'you'} =~ /.*\@.*\..*/) {
$you = "$FORM{'you'}";
open (LIST, ">>$LIST")|| print "Content-type: text\/html\n\n can't open
list to append";
print LIST "$you";
close(LIST);
print" Content-type: text\/html\n\n";
print" It says it worked \n";
print "$you\n";
} else{
print" Content-type: text\/html\n\n";
print" It didn't work";
}
------------------------------
Date: 28 Oct 1997 23:43:54 GMT
From: shodan@shodan.erols.com (Dave Schenet)
Subject: Re: Adding names to a list :-(
Message-Id: <635tbq$ht0$1@winter.news.erols.com>
You could try looking through your webserver's error log, since
most servers will log STDERR from cgi scripts there.
I don't think it'll matter, but you don't need to escape the /
in your print statements, either.
(more comments in code below)
: At one time this script was almost a full blown program - God (or
: Larry), it was a masterpiece! Now it's down to a pretty simple script
: about 15 lines of code that don't work.
: #!/usr/bin/perl
: $LIST="/usr/local/lib/httpd/cgi-bin/raven/ooops/list";
: read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
: @pairs = split(/&/, $buffer);
: foreach $pair (@pairs) {
: ($name, $value) = split(/=/, $pair);
: $FORM{$name}=$value;
: }
: # STOLEN FROM Matt Wright
: if ($FORM{'you'} =~ /.*\@.*\..*/) {
: $you = "$FORM{'you'}";
: open (LIST, ">>$LIST")|| print "Content-type: text\/html\n\n can't open
: list to append";
: print LIST "$you";
: close(LIST);
How about:
Above everything else in the code:
print "Content-type: text/html\n\n";
You only need to do it once, and it looks like you'll providfe html
output in every situation.
if (open(LIST, ">>$LIST")) {
print LIST "$you";
close (LIST);
} else { print "can't open $LIST to append"; }
[snip rest]
Hmm, could it be possible that perl is dying on the "print LIST"
statement if it couldn't append to the file?
Also, you might wanna turn off buffering on STDOUT. $|=1; does the trick.
--
+----------------------------------+-----------------------------------+
|Dave Schenet <shodan at erols com>| Erols Internet Services, INC. |
|Junior UNIX Developer | Springfield, VA. |
+----------------------------------+-----------------------------------+
| Can't reply by mail? I'm blocking 67 netblocks from sending me mail. |
| I have zero-tolerance for SPAM. One strike and I stop listening. . . |
+----------------------------------------------------------------------+
------------------------------
Date: Tue, 28 Oct 1997 16:07:34 -0800
From: Robert Hughes <robert.hughes@amarest.com>
To: Dave Schenet <shodan@shodan.erols.com>
Subject: Re: Adding names to a list :-(
Message-Id: <34567E46.8AB11FA3@amarest.com>
Another trick I find very useful for debugging is the snipet below,
especially if you do not have access to the web server logs.
Placed at the very top of the script you get compile errors output to the web
browser since the proper headers are always output.
BEGIN {
$|=1;
print "Content-type: text/plain\n\n";
}
Dave Schenet wrote:
> You could try looking through your webserver's error log, since
> most servers will log STDERR from cgi scripts there.
>
[snip]
------------------------------
Date: 29 Oct 1997 00:19:13 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: ADVANCED: Clearing a namespace/package?
Message-Id: <635ve1$mlo$1@agate.berkeley.edu>
In article <Pine.GSO.3.96.971028114835.23246F-100000@usertest.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
> On Tue, 28 Oct 1997, Brad Daugherty wrote:
>
> > Does anybody know how I can clear an entire namespace/package
> > without knowing the variables. In theory I want to "undef($Q::*)".
>
> (My third eye seems to see that you're trying to use cgi-lib.pl. Unless I
> put in the wrong contact lens this morning, you should use CGI.pm instead,
> and ignore the rest of this message. :-)
>
> This is tricky. If you do simply this:
>
> $foo::bar = "some value\n";
> undef %foo:: ; # wipe the foo:: symbol table
> print $foo::bar;
>
> ...the value is printed. The reason that happens is that the compiler is
> too smart! :-) It compiles the first and third lines to go directly to
> the variable, skipping the symbol table - so even though the second line
> "worked", clearing the foo:: symbol table, the variable may still be
> accessed. Yikes!
No, it not working like this. $foo::bar is compiled to something like
this:
my $glob765;
BEGIN { $glob765 = \*foo::bar; }
${$glob765};
(well, I forgot the syntax for converting a glob to its contents, so
take the last line with the grain of salt).
Note that a reference to *foo::bar is taken, so when
undef %foo::
is executed, *foo::bar does not go away due to refcounting semantics.
However, the glob which remains cannot be accessed as ${foo::}{bar}
any more. This is similar to how `unlink' works on *nix.
Ilya
P.S.
perl -le "$foo = 3; delete $::{foo}; ${'foo'} = 5; print qq{$foo, ${'foo'}}"
perl -le "$f::o = 3; undef %f:: ; ${'f::o'} = 5; print qq{$f::o, ${'f::o'}}"
both print 3, 5.
------------------------------
Date: 28 Oct 1997 20:38:51 GMT
From: plussier@wellfleet.com (Paul L. Lussier)
Subject: Can for loop be condensed using map()?
Message-Id: <635igr$r0l@paperboy.corpeast.BayNetworks.COM>
Hi, I currently have this for loop which takes a hex mac address and converts
it into a dotted quad format and I'm looking for a more efficient way of doing
the same thing:
$mask = 'ffffff00'
for ($i=0; $i < length ($mask); $i+=2) {
push (@newmask, hex (substr ($mask, $i,2)));
}
$netmask = join ('.', @newmask);
Is there a way I can use map to do the same thing? Can I somehow avoid the
2 step process of looping through, then joining?
This is more of a curiosity for me than anything else. I've seen map used in
so many posts, but trying it myself on this particular problem turned up
nothing. Of course, I was probably using it incorrectly :)
Thanks a lot.
--
Seeya,
Paul
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- Paul Lussier = It is a good day =The next best thing to doing -
= Baynetworks DOCD - to put slinkies -something smart is not doing =
- plussier@lancity.com = on escalators = something stupid. -
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
= Don't take life too seriously, you won't get out alive. -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: 28 Oct 1997 21:18:15 GMT
From: tph@longhorn.uucp (Tom Harrington)
Subject: Re: Class vars and "exists": Error in book
Message-Id: <635kqn$7n26@eccws1.dearborn.ford.com>
Toutatis (toutatis@_SPAMTRAP_toutatis.net) wrote:
: tph@rmi.net wrote:
: > my %fields = {
: ^
: > name => undef,
: > age => undef,
: > peers => undef,
: > };
: ^
D'oh! Thanks a lot!
--
Tom Harrington --------- tph@rmii.com -------- http://rainbow.rmii.com/~tph
"I used to be clueless, but I turned that situation around 360
degrees." -Dilbert
Cookie's Revenge: ftp://ftp.rmi.net/pub2/tph/cookie/cookies-revenge.sit.hqx
------------------------------
Date: 28 Oct 1997 17:00:54 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: DBD-Oracle-0.47.tar.gz corrupted?
Message-Id: <635nam$dt5$1@tholian.cse.psu.edu>
In article <635c2i$7b5$1@nyx10.nyx.net>,
Larry Mulcahy <lmulcahy@nyx.net> wrote:
>Did a bad file get into the CPAN distribution?
Not that I can tell.
% tail -1 .ncftp/log
get 70.29 kB ftp://ftp.cso.uiuc.edu/pub/lang/perl/CPAN/modules/
by-module/DBD/DBD-Oracle-0.47.tar.gz
% gzip -tv DBD-Oracle-0.47.tar.gz
DBD-Oracle-0.47.tar.gz: OK
John
groenvel@cse.psu.edu
BTW The newsgroup comp.databases.oracle is dead,dead,dead. Ask your newsadmin
to carry comp.databases.oracle.* instead.
------------------------------
Date: 28 Oct 1997 22:10:39 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: FOREACH command
Message-Id: <01bce3ee$336c7a00$02521e0a@tschai>
Dominik Breitenbach <webmaster@breitenbach.net> wrote in article
<34538EFC.3D19@breitenbach.net>...
> Hi there
>
> I have a little PERL programm. Whit it I can mail to several
people, and
> every recipient sees only his E-Mail address on his mail.
> It works with a separate file, called "email.log", wherein the
E-Mails
> addresses of the recipients are contented.
> The perl script gets the addresses by the following commands:
>
> **********
>
> ....
> $emaillog = "email.log";
> ....
> open (EMAIL, "$emaillog");
> @lines = <EMAIL>;
> close (EMAIL);
>
> *********
>
> and then it prints the MAIL by the follwoing lines:
>
> *********
>
> foreach $line (@lines)
> {
>
> open (MAIL, "|$mailprog $line") || die "Can't open
$mailprog!\n";
>
> print MAIL "Reply-to: $FORM{'emailadd'} ($FORM{'name'})\n";
> print MAIL "From: $FORM{'name'} <$FORM{'emailadd'}>\n";
> print MAIL "Subject: $FORM{'subject'}\n";
> print MAIL "To: $line\n";
> print MAIL "This should be an individual text\n\n";
> print MAIL "$FORM{'body'}\n";
>
> close (MAIL);
> }
>
> *********
>
> On the beginning of the body-text (line: 'print MAIL "This should
be an
> individual text\n\n"; ') I want to have an individual text like
"Hello
> Mark", "Hi Sandy", "Dear Billie" and so on.
>
> I don't know the PERL-language, i.e. I can only suppose certain
things
> as far as PERL is similar to BASIC; and the Script is originally
not
> mine but one of Matthew Kruse.
One way to do this is by adding the "real name" to the email.log
file.
Use a special character to separate the email address and the real
name
(for example, use a tab character).
insert after the foreach a "split $line" as follows
foreach $line (@lines)
{
($email, $real_name) = split(/\t/, $line); # split on tab character
Change "To: $line\n" to "To: $email\n".
Change the "This should be .... \n\n"; to "Hi $real_name,\n\n";
You can get a "personal" start line by using an array with some start
lines.
Put somewhere at the beginning of your script:
@hi = ('Dear', 'Hi', 'Hello', 'Greetings', 'Yo');
srand(time() ^ ($$ + ($$ << 15)); # ~ randomize
and add after the "split" line:
$hi = $hi[rand @hi];
And use: print MAIL "$hi $real_name,\n\n";
Hope this helps,
John
--
----------------------------------------------------------------------
------
C A S T L E A M B E R Freelance Software Development
(Java/Perl/C/CGI)
http://www.caiw.nl/~jbokma/ [Java demo's,Perl scripts,Xara graphics,
Resume]
mail:jbokma@caiw.nl phone: +31 10 4291827
------------------------------
Date: 29 Oct 1997 01:37:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: fork() makes me wait (?)
Message-Id: <63640i$f5c$1@comdyn.comdyn.com.au>
{comp.lang.perl removed}
Please do not post to comp.lang.perl. It is a dead newsgroup. Let your
news admin know that there is a dead news group on your server.
In article <634faq$9o4$1@ha2.rdc1.sdca.home.com>,
"Peter Tiemann" <peter@preview.org> writes:
> But:
> The HTML document does not appear before the child process has finished.
>
> Why?
perldoc -f fork
Note that if your forked child inherits system file descriptors like
STDIN and STDOUT that are actually connected by a pipe or socket, even
if you exit, the remote server (such as, say, httpd or rsh) won't think
you're done. You should reopen those to /dev/null if it's any issue.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd. | make a better idiot.
NSW, Australia |
------------------------------
Date: Tue, 28 Oct 1997 16:39:14 GMT
From: Boo@Casper.com (Glenn Miyashiro)
Subject: Re: Getting Autonumber ID after insert
Message-Id: <6354i6$1hf@sjx-ixn2.ix.netcom.com>
Patrick Atoon <patricka@cs.kun.nl> wrote:
>Hi there,
>I'm writing a Perl script that is calling Access via the Win32::ODBC
>package. The script inserts records into a database, but it needs to
>know which autonumbered index each record received. Is this possible
>without doing an extra SELECT to retrieve the highest value?
> # mytable looks like "myId" (autonumber), "name" (text)
> use Win32::ODBC;
> $db = new Win32::ODBC("myDB");
> $stmt = "INSERT INTO mytable (name) VALUES ('Gnu')";
> $resultcode = $db->Sql($stmt);
>All solutions are welcomed. Thank you in advance.
>Greetings,
>Patrick
Dont know about Perl but if you can do the VB equivalent
recordset.BookMark = recordset.LastModified, then the last record
added or edited becomes the current record where you can retrieve
whatever you want. Note: Selecting the highest number would be
dangerous in a multi user environment as someone could have come right
after you and saved another record.
To reply by Email use glennmiy@mindspring.com
Get PR-Tracker -- tracks problem reports, defects, bugs
INFORMATION: http://www.prtracker.com/info.html
DOWNLOAD: http://www.prtracker.com/download.html
------------------------------
Date: 28 Oct 1997 17:56:00 -0700
From: Henry Hwangbo <skooky@primenet.com>
Subject: Let's try this again - Help with Error
Message-Id: <6361j0$c1h@nntp02.primenet.com>
Can't load '/usr/local/lib/perl5/site_perl/sun4-solaris/auto/Msql/Msql.so'
for module Msql: ld.so.1: perl: fatal: relocation error: symbol not found:
stack_sp: referenced in
/usr/local/lib/perl5/site_perl/sun4-solaris/auto/Msql/Msql.so at
/usr/local/lib/perl5/DynaLoader.pm line 140.
at /usr/local/lib/perl5/Msql.pm line 87
BEGIN failed--compilation aborted at dbquery.pl line 70.
Any ideas with this? I wrote a perl script to access a Msql database and
it appears the error is occurring in the Msql.pm with the line:
bootstrap Msql;
That is, if I am reading the error correctly -- I am assuming the error is
on line 87 of Msql.pm.
Any help would be appreciated!
Henry
--
------------------------------
Date: 28 Oct 1997 17:23:16 -0500
From: allen@gateway.grumman.com (John L. Allen)
Subject: Making perl a builtin command dtksh command on AIX 4.x
Message-Id: <635okk$ag8@gateway.grumman.com>
Keywords: perl, dtksh, AIX, builtin
Ok, I'm trying to make perl5.004_04 be a builtin function in dtksh on AIX414.
[ No, no, please keep reading! Especially AIX 4.x system gurus! ]
Mainly as an interesting experiment, but with a view toward speeding
up perl access. I'm getting segfaults whenever dynamically loaded
modules like POSIX are use'd. The segfault occurs in boot_POSIX.
And yes, I think I'm using the xs_init() function properly. My
"by-the-book" substitute perlmain.c is appended below.
[ AIX users please try this at home. ]
After copying perl.exp from $Config{archlibexp}/CORE to $PWD,
I link myperl with
cc -o myperl b_perl.c -bE:funcs_perl.exp \
`perl -MExtUtils::Embed -e ccopts -e ldopts`
The funcs_perl.exp file contains the single line ``b_b_perl'', which
is use to tell dtksh that b_perl can be used as a builtin (the first
b_ is required by dtksh).
Now, the resulting myperl can be run at the command line and functions
just like perl, with ``use POSIX; print strftime "%D", localtime'' working
fine, ie., no problems with dynamic loading.
To make b_perl a dtksh builtin, you do this (under dtksh, of course)
builtin -f myperl
builtin b_perl
after that, stuff like ``b_perl -le 'print 1..99''' works fine,
but ``use POSIX'' segfaults in boot_POSIX, and ``use MD5'' segfaults
in boot_MD5.
Is there enything inherent in the way these extensions are constructed
that would prevent them from working when dynamically loaded from perl
if perl itself is dynamically loaded (which dtksh is doing when it
processes the ``builtin -f myperl''. I'm not positive, but I think
dtksh is using the load() system call.)?
Any ideas much appreciated.
John.
----- b_perl.c -----
#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */
static void xs_init _((void));
static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
int b_b_perl(int argc, char **argv, char **env)
{
my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
}
int main(int argc, char **argv, char **env)
{
b_b_perl(argc, argv, env);
}
extern void boot_DynaLoader _((CV* cv));
static void
xs_init()
{
char *file = __FILE__;
dXSUB_SYS;
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
}
-------------------
--
_/JohnL\_allen@gateway.grumman.com <Sun>: 9.5 billion pounds per sec to energy
~\Allen/~Fax: 516-575-7428 <Universe>: 1e22 stars = 22 solar masses per sec
------------------------------
Date: Tue, 28 Oct 1997 17:59:34 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Multiple filehandles
Message-Id: <69u536.cq4.ln@localhost>
Joseph June (jjune@midway.uchicago.edu) wrote:
: Hello...
: Another quick question for the perl experts..
: Is there a way to have multiple filehandles?
: let me make that more clear.. :)
: i create a filehandle by
: open(RULEFILE, "FILENAME")
... except your real code checks the return value, right?
open(RULEFILE, "FILENAME") || die "could not open 'FILENAME' $!";
: and i start a while loop that goes something like
: while ($rulefile_line = <RULEFILE> ) {
... except your real code checks to see if $rulefile_line is defined()
so that the loop cannot end prematurely, right?
while (defined($rulefile_line = <RULEFILE>) ) {
You should use your real code when asking questions.
: ....
: I need an another filehandle that will "move" with <RULEFILE> in the while
: loop. So for exameple... i can create another filehandle <BUFFER> by
: open(BUFFER, "FILENAME")
By now we know that you should be checking the return value, right?
: but... i can't do
: while ($rulefile_line = <RULEFILE> && $rulefile_buffer = <BUFFER>) {
Yes you can:
while ( defined($rulefile_line = <RULEFILE>) && defined($rulefile_buffer = <BUFFER>)) {
: HOw can i do something of equivalence?
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 28 Oct 1997 21:59:51 GMT
From: "Phil R Lawrence" <prl2@lehigh.edu>
Subject: Need to keep passwords off console during input
Message-Id: <01bce3ec$d035b920$3e03b480@mm.CC.lehigh.EDU>
I request a password from the user and use STDIN to capture it. I don't
want the password to show on the console while the user is typing it. How
can I accomplish this?
------------------------------
Date: 28 Oct 1997 22:59:49 GMT
From: yevgene@xochi.tezcat.com (E.None Archibald)
Subject: Re: Need to keep passwords off console during input
Message-Id: <635qp5$cgf$3@tepe.tezcat.com>
Phil R Lawrence <prl2@lehigh.edu> wrote:
: I request a password from the user and use STDIN to capture it. I don't
: want the password to show on the console while the user is typing it. How
: can I accomplish this?
The quick-and-dirty way to do this (on UNIX) goes something like:
system('stty -echo');
print "foo: ";
$foo = <STDIN>;
print "\n";
system('stty echo');
Make sure that if you use this in a program for general user types (i.e.,
they wouldn't know 'stty' if it bit em on the ass), you also insert signal
handlers for SIG(KILL|TERM...) that at the very least attempt a
system('stty echo');
...so that people won't suddenly have no echoback at the prompt.
--eugene archibald
tezcat communications
------------------------------
Date: Wed, 29 Oct 1997 10:38:21 +1100
From: Rich <rich@mondial.net.au>
Subject: Re: Need to keep passwords off console during input
Message-Id: <3456776D.B2D3B0A@mondial.net.au>
Phil R Lawrence wrote:
>
> I request a password from the user and use STDIN to capture it. I don't
> want the password to show on the console while the user is typing it. How
> can I accomplish this?
Try this (for a Unix system):
[...]
system( "stty -echo" );
print "Password: ";
chomp( $password=<> );
system( "stty echo" );
[...]
If it's not a Unix system - get the "ReadKey" module and try that.
--
._-=`=-_._-=`=-_._-=`=-_._-=`=-_._-=`=-_._-=`=-_._-=`=-_.
Richard Horwood Email: rich@mondial.net.au
Systems Engineer Voice: +61 3 9735 5355
Mondial Net Pty. Ltd. Fax: +61 3 9735 5399
------------------------------
Date: 28 Oct 1997 22:59:00 GMT
From: plambert$1@plambert.org
Subject: Re: padding digits...
Message-Id: <635qnk$d5r$1@nntp1.ba.best.com>
Eike Grote <eike.grote@theo.phy.uni-bayreuth.de> spewed:
> Hi,
> You could use a subroutine like this (in fact, it's just a regular
> expression making use of the features of 'sprintf'):
> sub padstring {
> my ($z,$t) = @_;
>
> $t =~ s/\d+/sprintf "%0${z}d",$&/eg;
> return $t;
> }
Thank you; this is exactly the sort of information I was looking for.
> Why not simply say
> &extract_number("item 3") <=> &extract_number("item 10")
> with &extract_number based on
> ($number) = ( $string =~ /(\d+)/ );
Unfortunately, I wasn't clear in my needs: I need to compare such things as
"item 3624" and "florp! foozle!", only expanding numbers as necessary.
So, for example, a list may include "list 21", "item 16", "item 2", and
"gleep". The sorted list would be "gleep", "item 2", "item 16", and
"list 21". Your first answer, and the answers others kindly mailed me,
were wonderful. sprintf seems to be the way to go.
Thanks!
--Paul L.
------------------------------
Date: Wed, 29 Oct 1997 09:34:49 +1000
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: perl newbie needs help
Message-Id: <34567699.29E1@ozemail.com.au>
Andy Sutorius wrote:
>
> I have looked at all the FAQ's I can possibly stand.
>
> I need to download a "freeware" editor so that I may write and compile
> and debug Perl. I have Perl 4 and 5 but nothing is making sense in how
> to get the program up and running.[snip]
I use Programmer's File Editor:
http://www.lancs.ac.uk/people/cpaap/pfe
>From the menu I choose 'Execute DOS Command To Window' to run my Perl scripts, and the output is captured and
returned in a window.
--
Cheers,
Ron Savage
Office: savage.ron.rs@bhp.com.au
Home (preferred): rpsavage@ozemail.com.au
------------------------------
Date: Tue, 28 Oct 1997 19:28:29 -0500
From: Joe Gottman <joegottman@worldnet.att.net>
Subject: return question
Message-Id: <3456832D.7D94@worldnet.att.net>
I have a question about the return keyword. Is there any difference
between the
function
sub foo { 1;}
and
sub foo {return 1;}
I like using return as the last statement in a subroutine, but I am
curious if
this would cause the function to run slower or faster.
--
Joe Gottman
joegottman@nospam.worldnet.att.net
[Remove nospam to reply]
------------------------------
Date: 28 Oct 1997 22:52:39 GMT
From: yevgene@xochi.tezcat.com (E.None Archibald)
Subject: Re: Simulating ${parm:-$parm2}
Message-Id: <635qbn$cgf$2@tepe.tezcat.com>
Valentin C. Briones <valentin@cssdomain.com> wrote:
: In Perl, what is a short, elegant, legible way of simulating ksh's
: var=${parm:-$parm2}
: functionality. I have come up with:
: $var = (defined $parm||$parm) ? $parm : $parm2;
not really. also, note that (defined $parm || $parm) will have problems -
first off, if it's not defined, it won't have a value -and- will cause a
warning to be issued re: undefined variable.
something like:
sub pickone ($$) { (defined $_[0] && $_[0]) ? $_[0] : $_[1] ; }
should work.
--eugene archibald
tezcat communications
------------------------------
Date: Tue, 28 Oct 1997 18:07:29 -0600
From: "Valentin C. Briones" <valentin@cssdomain.com>
Subject: Re: Simulating ${parm:-$parm2}
Message-Id: <34567E41.7C809D3F@cssdomain.com>
--------------E18C39CD0F4425771FA98366
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Thanks, Eugene. You are correct about the warning.
However, the pickone function you list breaks for $parm == 0 because of the
'and'.
Someone else suggested the following which also breaks for $parm==0.
$var = $parm || $parm2;
I also just realized that my conditional also fails for $a == '' (which is
one of
the cases I'm trying to catch in the first place). I will change your
statement to:
$var = (defined $parm && $parm ne '') ? $parm : $parm2;
which will get rid of the warning, and work for $parm==0.'
This should work just like the Ksh ${a:-$b} substitution.
I though Perl might have a simpler construct similar to the Ksh syntax, but I
guess that's not the case.
Score one for Ksh! (Don't hit me!!! I'm just kidding!) :^)
Thanks to all who responded,
VCB
E.None Archibald wrote:
> Valentin C. Briones <valentin@cssdomain.com> wrote:
> : In Perl, what is a short, elegant, legible way of simulating ksh's
>
> : var=${parm:-$parm2}
>
> : functionality. I have come up with:
>
> : $var = (defined $parm||$parm) ? $parm : $parm2;
>
> not really. also, note that (defined $parm || $parm) will have problems -
> first off, if it's not defined, it won't have a value -and- will cause a
> warning to be issued re: undefined variable.
>
> something like:
>
> sub pickone ($$) { (defined $_[0] && $_[0]) ? $_[0] : $_[1] ; }
>
> should work.
>
> --eugene archibald
> tezcat communications
--------------E18C39CD0F4425771FA98366
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
<TT>Thanks, Eugene. You are correct about the warning.</TT>
<BR><TT>However, the pickone function you list breaks for $parm == 0 because
of the 'and'.</TT>
<BR><TT>Someone else suggested the following which also breaks for $parm==0.</TT>
<BR><TT> $var = $parm || $parm2;</TT>
<BR><TT>I also just realized that my conditional also fails for $a == ''
(which is one of</TT>
<BR><TT>the cases I'm trying to catch in the first place). I will
change your statement to:</TT>
<BR><TT> $var = (defined $parm && $parm ne '')
? $parm : $parm2;</TT>
<BR><TT>which will get rid of the warning, and work for $parm==0.'</TT>
<BR><TT>This should work just like the Ksh ${a:-$b} substitution.</TT><TT></TT>
<P><TT>I though Perl might have a simpler construct similar to the Ksh
syntax, but I</TT>
<BR><TT>guess that's not the case.</TT><TT></TT>
<P><TT>Score one for Ksh! (Don't hit me!!! I'm just kidding!)
:^)</TT><TT></TT>
<P><TT>Thanks to all who responded,</TT>
<BR><TT> VCB</TT><TT></TT>
<P><TT>E.None Archibald wrote:</TT>
<BLOCKQUOTE TYPE=CITE><TT>Valentin C. Briones <valentin@cssdomain.com>
wrote:</TT>
<BR><TT>: In Perl, what is a short, elegant, legible way of simulating
ksh's</TT><TT></TT>
<P><TT>: var=${parm:-$parm2}</TT><TT></TT>
<P><TT>: functionality. I have come up with:</TT><TT></TT>
<P><TT>: $var = (defined $parm||$parm) ? $parm : $parm2;</TT><TT></TT>
<P><TT>not really. also, note that (defined $parm || $parm) will have problems
-</TT>
<BR><TT>first off, if it's not defined, it won't have a value -and- will
cause a</TT>
<BR><TT>warning to be issued re: undefined variable.</TT><TT></TT>
<P><TT>something like:</TT><TT></TT>
<P><TT>sub pickone ($$) { (defined $_[0] && $_[0]) ? $_[0] : $_[1]
; }</TT><TT></TT>
<P><TT>should work.</TT><TT></TT>
<P><TT>--eugene archibald</TT>
<BR><TT> tezcat communications</TT></BLOCKQUOTE>
</HTML>
--------------E18C39CD0F4425771FA98366--
------------------------------
Date: Tue, 28 Oct 1997 13:09:17 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Using Perl Modules
Message-Id: <t8d536.i96.ln@localhost>
Michael Stearns (michael@datahost.com) wrote:
: My questions:
: After doing "Makefile" and "make" I certainly got a bunch of stuff
: created in my directory. Should everything be there that I need to use
: the module?
Maybe. If the module uses other modules, then you need to have the
other modules too ;-)
: Can I leave the module in my local directory and use it from there or
: does it have to be somewhere else on the system?
Perl FAQ, part 8:
"How do I keep my own module/library directory?"
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 28 Oct 1997 15:15:56 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Year2000 problem with localtime();
Message-Id: <m3n2jttr6b.fsf@windlord.Stanford.EDU>
Henry Hartley <HARTLEH1@westatNOSPAM.com> writes:
> True. My understanding, however, is that the range for dates in perl is
> 2038. Is that not true?
This is not a problem with Perl, it's a problem with the underlying C
library. On systems where the C library uses a 64 bit time_t, this isn't
a problem, so assuming that all systems will be 64 bit by 2038, there
won't be a problem.
--
#!/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: 29 Oct 1997 01:04:11 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Year2000 problem with localtime();
Message-Id: <slrn65d305.fa0.abigail@betelgeuse.wayne.fnx.com>
Russ Allbery (rra@stanford.edu) wrote on 1519 September 1993 in
<URL: news:m3n2jttr6b.fsf@windlord.Stanford.EDU>:
++ Henry Hartley <HARTLEH1@westatNOSPAM.com> writes:
++
++ > True. My understanding, however, is that the range for dates in perl is
++ > 2038. Is that not true?
++
++ This is not a problem with Perl, it's a problem with the underlying C
++ library. On systems where the C library uses a 64 bit time_t, this isn't
++ a problem, so assuming that all systems will be 64 bit by 2038, there
++ won't be a problem.
Uhm, if I have my application read and write dates, using
sizeof (time_t) space, I get a problem when sizeof (time_t)
isn't constant over time.
One of the subproblems of Y2K is that going from 2 to more bytes to
store the year gives problems when reading old data, or writing new data.
That same problem will hit machines when their time_t type goes from 32
to 64 bits.
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^(11+?)\1+$/'
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 1241
**************************************