[6346] in Perl-Users-Digest
Perl-Users Digest, Issue: 968 Volume: 7
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 18 18:17:16 1997
Date: Tue, 18 Feb 97 15:00:25 -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, 18 Feb 1997 Volume: 7 Number: 968
Today's topics:
ATTN: EMX Perl users (Perl 5.003_05 for OS/2, Win* and (Ilya Zakharevich)
Berkeley DB vs. an SQL server solution <chris@ixlabs.com>
CGI_Lite & Multi-select SELECT fields <dmusser@amp.com>
Re: CGI_Lite & Multi-select SELECT fields (Chris Nandor)
Re: Class library to make C++ more Perlish? (Tuomas J. Lukka)
Re: Computer Parts Website <nmljn@wombat.staff.ichange.com>
Database entry ID - how to? <ktjuka@uta.fi>
Re: debugging perl & html <rodos@haywood.org>
Re: File length? (I R A Aggie)
Re: File length? (Bob Wilkinson)
Re: Getting a HTML file from another server with PERL (Honza Pazdziora)
Re: Here's a good perl resource... (Erik Braun)
Re: Here's a good perl resource... (Tad McClellan)
How do I ...? (newbie question) <IDS@Scrooge.HSRC.ac.za>
HOW-TO:DBM programming novice <jonesaa@worldnet.att.net>
Re: Nicaragua (Tad McClellan)
Re: Perl "if" error? (I R A Aggie)
Re: Perl for Win32 <IDS@Scrooge.HSRC.ac.za>
Re: Perl for Win32 (Jarle Aasland)
Perl on NT aborts when executing 'open' when breakpoint Jim McGlinchey
Problem with calling subroutines (Premkumar Natarajan)
Re: Program wrapper ? (Jagadeesh Venugopal)
Re: QUES: what is "undump"? (Steven L. Kunz)
Re: QUES: what is "undump"? (Malcolm Beattie)
Re: reduce length (Honza Pazdziora)
Re: RegEx, Email & Friedl's "Mastering..." Book (Jeffrey)
Re: regexp's in XEmacs vs. Perl <hniksic@srce.hr>
Re: regexp's in XEmacs vs. Perl <csdayton@cs.uchicago.edu>
Re: Regular Expressions and Assigning to Variable (kao)
Re: Screen I/O library (Steven L. Kunz)
script to encrypt STDIN <brian@wort.com>
Re: Sorting an associative array by values <hammen@gothamcity.jsc.nasa.gov>
tail recursion in bounded space, and goto & (Tony Bass)
Why can i run Perl in Linux? <ryan@www.puli.com.tw>
Why doesn't gethostbyaddr return a value? <matti-hu@dsv.su.se>
Re: Why doesn't gethostbyaddr return a value? (Honza Pazdziora)
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Feb 1997 20:29:42 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: ATTN: EMX Perl users (Perl 5.003_05 for OS/2, Win* and DOS)
Message-Id: <5ed3fm$8sr$1@mathserv.mps.ohio-state.edu>
Thanks to Ivan Adzhubei, who discovered the following bug in the
automatic installer:
If you did not install your pdksh's sh.exe in f:/bin, check that you
have PERL_SH_DIR set in Config.sys, and it uses / (not \) - this is a
bug in the automatic installer - it sets a meaningless PERL_SHPATH
instead!
This correction is reported to fix the problem "backticks and pipes do
not work". Possibly the same fix may work under Win* and DOS?
Ilya
------------------------------
Date: Tue, 18 Feb 1997 12:07:19 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: Berkeley DB vs. an SQL server solution
Message-Id: <330A0BF7.4EF3@ixlabs.com>
In what cases would Berkeley DB (which I understand can be described as
an 'embedded' database - correct me if I'm wrong) be a better choice
than, say, MiniSQL?
1. Does msql handle locking internally?
2. Does msql have limits on number of connections that an embedded
solution would solve?
3. Is msql (and SQL servers in general) faster or slower then Berkeley
when using the 'internal' UNIX socket?
4. Aren't SQL queries more efficient than rifling/searching/sorting
through keys in Berkeley DB?
5. Aren't some SQL servers (msql?) capable of rebuilding corrupted
databases?
I just wanted to verify some unqualified impressions I've been getting.
--
Chris Schoenfeld
IX Development Laboratories
Santa Rosa, California
(707)-543-8030 Ext. 12
------------------------------
Date: Tue, 18 Feb 1997 15:40:39 -0500
From: "Douglas C. Musser" <dmusser@amp.com>
Subject: CGI_Lite & Multi-select SELECT fields
Message-Id: <330A13C7.39CE@amp.com>
I am using Shishir Gundavaram's CGI_lite module to interpret the URL.
Can this be used when you have select fields allowing multiple values?
If so, how can you get the multiple values from the hash that
CGI_Lite puts the values into?
URL -->.../x.pl?list=one&list=two&list=three
use CGI_Lite;
$cgi = new CGI_Lite();
%results = $cgi->parse_form_data();
$results{'list'} gives me "one", how can I get the other two values?
Thanks in advance,
Doug
------------------------------
Date: Tue, 18 Feb 1997 16:23:45 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: CGI_Lite & Multi-select SELECT fields
Message-Id: <pudge-ya02408000R1802971623450001@news.idt.net>
In article <330A13C7.39CE@amp.com>, dmusser@amp.com wrote:
#use CGI_Lite;
#$cgi = new CGI_Lite();
#%results = $cgi->parse_form_data();
#
#$results{'list'} gives me "one", how can I get the other two values?
CGI.pm does have this facility:
use CGI;
$cgi = new CGI;
@list = $cgi->param('list');
#@list now equals ('one','two','three'...).
I would suggest using CGI.pm if you can.
#================================================================
My school colors were clear. We used to say, "I'm not naked, I'm
in the band."
--Steven Wright
Chris Nandor pudge@pobox.com
PGP Key 1024/B76E72AD http://pudge.net/
Keyfingerprint = 08 24 09 0B CE 73 CA 10 1F F7 7F 13 81 80 B6 B6
------------------------------
Date: 16 Feb 1997 14:04:38 -0500
From: tjl@lukka.student.harvard.edu (Tuomas J. Lukka)
Subject: Re: Class library to make C++ more Perlish?
Message-Id: <5e7lo6$qoi@lukka.student.harvard.edu>
In article <3309B25B.47EB@doc.ic.ac.uk>,
Ben Jefferys <brj@doc.ic.ac.uk> wrote:
>Hi I'm looking for a class library to give C++ some of the cool
>functionality in Perl. Ideally it'd have scalar, array,
>associative array classes and overload standard operators
>as per C++. It should also have search, pattern matching
>and so on as functions in the scalar class.
>
>My reason for wanting this is that I'm find my Perl programs
>are too slow :( So I see C++ classes as the solution. If
>there is another way I kind find out WHY my Perl is so slow
>(ie. which bits are taking a long time) then I'd appreciate
>a pointer.
1. Are you sure you are doing things right: could you post
an example that you consider too slow? It takes skill
to get things right sometimes; your REs might be backtracking
the life out of themselves.
2. Check out the Perl Compiler and join perl5-porters@perl.org
(by perl5-porters-request@perl.org): the integration of the compiler
is going to start right after 5.004 (not long any more)
Tuomas
------------------------------
Date: 18 Feb 1997 14:03:07 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: Computer Parts Website
Message-Id: <w10vi7q9btg.fsf@wombat.staff.ichange.com>
majewski@ngpsun.ngpc.state.ne.us writes:
> Apologies for the top post. It was posted to this
> newsgroup by ACCIDENT. Please disregard and
> accept my sincere apologies for cluttering things
> up with it.
Speaking for myself, of course, apology accepted. You might try to
cancel that article if it hasn't already expired.
Cheers,
Laird
--
<laird.nelson@netsinc.com> perl FAQ: http://www.perl.com/perl/faq Perl manual:
http://www.perl.com/CPAN/doc/manual/html/frames.html. If CGI/web appears in
your comp.lang.perl.* post, see news:comp.infosystems.www.authoring.cgi. CGI
stands for Common Gateway *Interface*, not Language or Program or Script.
Consolidated perl reference page: http://www.amherst.edu/~ljnelson/perl.html
------------------------------
Date: 18 Feb 1997 12:24:17 GMT
From: Jussi Kallioniemi <ktjuka@uta.fi>
Subject: Database entry ID - how to?
Message-Id: <5ec71h$pbm@cc.tut.fi>
I am creating a simple delimited database, something like:
|ID|field1|field2|field3|field4|
( - I am going to do searches targeted on a ID or on a spesific field. )
( - I need to be able to 1) add a record 2) delete a record 3) modify a record )
The "problem":
What would be the best way to create IDs for the records?
At the moment the solution I've been thinking about is as simple as this:
x to have a file in which there is the last record's ID and
x to have a file in which I've got the deleted - free - record IDs
So, when creating a new record, I would first scan through the
unused IDs file and grab the first ID from there. And of course delete
the entry from the file.
If the unused ID file doesn't exist ( there's no unused IDs);
check for the last_record_ID file and take the ID from there.
So, basicly something like this
if exist free_IDs_file {
grab the first one;
take it off the list;
}
else {
grab the id from the last_record_ID_file;
increment last_record_ID by one ;
}
--> What is the only correct way of doing this ? ;)
--
Jussi Kallioniemi <jukal@infosto.fi>
------------------------------
Date: Wed, 19 Feb 1997 08:04:01 +1100
From: Rodney Haywood <rodos@haywood.org>
Subject: Re: debugging perl & html
Message-Id: <330A1941.76BA@haywood.org>
The book "The Webmaster's Handbook : Perl Power for Your Web Server" by Neuss &
Vromans has a section on testing and debugging. They use a technique where scripts
can be run in test mode (ie command line) as well as from a server.
Each script starts with :
# If this script is called manually, run in test mode
unless (defined $ENV{'SCRIPT_NAME'} ){
print STDOUT ("$0 was not invoked from the server!\n");
if (@ARGV> 0){
print STDOUT ("Using command line arguments.\n");
$request = join('&', @ARGV);
}
else {
print STDOUT ("Please enter the name/value pairs URL-encoded on the ",
"standard input.\n");
while (<>) {
chop; # Newline
$request .= $_ . '&'; # Add it with seperator
}
chop($request); # Trailing &
}
}
# Parse it.
%request = &cgiparse($request);
The cgiparse routine takes the optional $request parameter and parses using that,
instead of the normal ways.
Of course there are lots of ways to do it, this is only one and it can be improved
on. As log as the environment variables are there (define what you need with a script
or batch file) and you can get the name value pairs into your standard structure
in some way, you will be able to debug at will.
Rodos
Paul S. Cutt wrote:
>
> I wonder what people are using to debug perl scripts when called from an
> html page ? I know about perl debugger but this is run from the command
> line. If my html page calls my perl script how can I get the debugger at
> that point to execute so I can continue debugging ?
>
> Thanks,
>
> paul
------------------------------
Date: Mon, 17 Feb 1997 12:07:15 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: File length?
Message-Id: <fl_aggie-ya02408000R1702971207150001@news.fsu.edu>
In article <5e9tuk$gpp$1@goliat.eik.bme.hu>, anita@unicorn.sch.bme.hu
(Kovacs Anita) wrote:
+ Does anybody happen to know how to get a file's length in bytes
+ by a perl function?
Please turn to page 224 of your azure camel (or your _man perlfunc_), where
we get a discussion of the stat function:
stat FILEHANDLE
stat EXPR
Returns a 13-element array giving the status info
for a file, either the file opened via FILEHANDLE,
or named by EXPR. Returns a null list if the stat
fails. Typically used as follows:
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);
Not all fields are supported on all filesystem
types. Here are the meaning of the fields:
size total size of file, in bytes
James
--
Consulting Minster for Consultants, DNRC
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Tue, 18 Feb 1997 12:47:39 -0500
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: File length?
Message-Id: <b.wilkinson-1802971247390001@ip57-york.pindar.co.uk>
In article <5e9tuk$gpp$1@goliat.eik.bme.hu>, anita@unicorn.sch.bme.hu
(Kovacs Anita) wrote:
> Does anybody happen to know how to get a file's length in bytes
> by a perl function?
> thanks a lot!
>
> Csaba Tanczos
-s $file returns the size of $file in bytes.
Bob
--
All is flux, nothing is still; nothing endures but change
- Heraclitus
------------------------------
Date: Tue, 18 Feb 1997 10:29:17 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Getting a HTML file from another server with PERL
Message-Id: <adelton.856261757@aisa.fi.muni.cz>
dico@isn.net (Dico Reyers) writes:
> Hello.
>
> I need some help please. No one has been able to help me.
>
> I would like to write a perl script that goes to a specified URL and
> gets a specified file and then takes that information and just stores
> it in an array.
>
> Any help would be greatly appreciated...
I think libwww-perl cookbook should help you. There's (among others)
this example:
perl -MLWP::Simple -e 'getprint "http://www.perl.com/perl/CPAN/CPAN.html"'
This is good place to start.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 18 Feb 1997 11:19:00 GMT
From: erik@paxp01.mipool.uni-jena.de (Erik Braun)
Subject: Re: Here's a good perl resource...
Message-Id: <slrn45gj42h.5nf.erik@paxp01.mipool.uni-jena.de>
On Sun, 16 Feb 1997 07:23:41 -0800, Dave Wagner <dave@inquiry.com> wrote:
>Here's a place to get answers to perl questions:
>
>http://www.inquiry.com/techtips/web_pro/
Hmm, this is an empty page.
Or do you mean, I'm such a perl expert, who never has a perl question?
erik
--
erik@minet.uni-jena.de
------------------------------
Date: Tue, 18 Feb 1997 06:53:03 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Here's a good perl resource...
Message-Id: <fn8ce5.501.ln@localhost>
Erik Braun (erik@paxp01.mipool.uni-jena.de) wrote:
: On Sun, 16 Feb 1997 07:23:41 -0800, Dave Wagner <dave@inquiry.com> wrote:
: >Here's a place to get answers to perl questions:
: >
: >http://www.inquiry.com/techtips/web_pro/
: Hmm, this is an empty page.
: Or do you mean, I'm such a perl expert, who never has a perl question?
They should have said that it _requires_ frames.
They are obviously shooting for Joe Consumer, not Joe Programmer, else
they would have a non-frames alternative...
It was just a bald advertisement anyway. If the guy really wanted
to help perl programmers find answers, he would have provide URLs
right to some perl specific parts of their site.
Dejanews says that dave@inquiry.com has made 37 original postings,
and no follow-ups. What can we deduce from that?
At their site:
I did a "Search Answers" for 'perl' and found 54 hits. Several of those
just mentioned perl in programming language comparisons. Didn't really
spend time trying to see actual perl questions though.
That makes it worth _much less_ than one percent of time spent
reading c.l.p.m.
My opinion after only 5 minutes at their site... they're not going
to get a spot on by Bookmark short list. I don't expect I'll ever
need to go there again either.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 18 Feb 1997 12:24:59 GMT
From: "Ian Samson" <IDS@Scrooge.HSRC.ac.za>
Subject: How do I ...? (newbie question)
Message-Id: <01bc1d96$d2c8b4c0$01807098@ludwig.hsrc.ac.za>
This is a multi-part message in MIME format.
------=_NextPart_000_01BC1DA7.965184C0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
>From books I have bought I can work out how to get a browser's IP Address,
host name etc.
What I have not been able to find is how to output the result of the script
to a UNIX file.
The CGI script will be called from an initial HTML file (as a "front end"
to a database application); the script will obtain the user's IP Address,
host name (if available), HTTP_USER_AGENT, and HTTP_REFERER; and if
possible the date/time of launching the CGI script, and then output the
results to a UNIX file in a specific directory.
Help will be acknowledged and appreciated.
TIA
--
Ian Samson
Internet/Intranet Systems Development, Human Sciences Research Council,
Pretoria, South Africa
IDS@Scrooge.HSRC.ac.za http://www.hsrc.ac.za/
------=_NextPart_000_01BC1DA7.965184C0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<html><head></head><BODY bgcolor=3D"#C0C0C0"><p><font size=3D2 =
color=3D"#000000" face=3D"Comic Sans MS">From books I have bought I can =
work out how to get a browser's IP Address, host name etc. <br><br>What =
I have not been able to find is how to output the result of the script =
to a UNIX file. <br><br>The CGI script will be called from an initial =
HTML file (as a "front end" to a database application); the =
script will obtain the user's IP Address, host name (if available), =
HTTP_USER_AGENT, and HTTP_REFERER; and if possible the date/time of =
launching the CGI script, and then output the results to a UNIX file in =
a specific directory.<br><br>Help will be acknowledged and =
appreciated.<br>TIA<br>--<br><font size=3D2>Ian =
Samson<br>Internet/Intranet Systems Development, Human Sciences Research =
Council, Pretoria, South Africa<br><font =
color=3D"#0000FF"><u>IDS@Scrooge.HSRC.ac.za</u><font color=3D"#000000"> =
<font color=3D"#0000FF"><u>http://www.hsrc.ac.za/</u><font =
color=3D"#000000"></p>
</font></font></font></font></font></font></body></html>
------=_NextPart_000_01BC1DA7.965184C0--
------------------------------
Date: Tue, 18 Feb 1997 13:11:02 -0600
From: Anthony Jones <jonesaa@worldnet.att.net>
Subject: HOW-TO:DBM programming novice
Message-Id: <3309FEC6.3D7@worldnet.att.net>
I am looking for a good reference on how to do some dbm programming in
perl. Any book, article or faq will be greatly appreciated.
It's been years since my database class in college.
--- Anthony Jones
jonesaa@thorn.com
------------------------------
Date: Tue, 18 Feb 1997 05:51:03 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Nicaragua
Message-Id: <735ce5.4n.ln@localhost>
[ emailed, posted ]
arnoldn@sprynet.com wrote:
: WOULD YOU consider helping me in my outreach to orphaned boys & girls outside Managua? I'm returning there in early March.
Maybe. What kind of Perl programming do you need?
If you are not looking for Perl programming help, then that would make
your post 'spam'. Spamming the 'net is likely not a very good approach
to getting volunteer help...
Nearly all spams are ripoffs. Want to be thought of as a ripoff artist?
: Consider it. Paul. (562)430-2773.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Mon, 17 Feb 1997 16:28:06 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Perl "if" error?
Message-Id: <fl_aggie-ya02408000R1702971628060001@news.fsu.edu>
In article <dbmartinE5rK2o.AFn@netcom.com>, dbmartin@netcom.com (David
Martin) wrote:
+ if ($t1 == "[22;1H")
+ Is the format of the "if" statment incorrect or could this be a bug with
+ my version of Perl?
"==" is a *numeric* comparison! 2+2==4, for instance. In this case,
you want the string comparison:
if ($t1 eq '[22;1H') {
#blah blah blah
}
You may also want to upgrade to perl v5.00x for your machine. Version 4
dead and unsupported.
James
--
Consulting Minster for Consultants, DNRC
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 18 Feb 1997 11:44:08 GMT
From: "Ian Samson" <IDS@Scrooge.HSRC.ac.za>
Subject: Re: Perl for Win32
Message-Id: <01bc1d91$1f4043a0$01807098@ludwig.hsrc.ac.za>
This is a multi-part message in MIME format.
------=_NextPart_000_01BC1DA1.E2C913A0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Perl for Win32? Does this mean there is a perl version that runs on Windows
95? Or is it still the ntperl that requires to be installed and configured
on an NT server?
I have had numerous requests on the IE-HTML list for this information.
Thanks.
--
Ian Samson
IDS@Scrooge.HSRC.ac.za
------=_NextPart_000_01BC1DA1.E2C913A0
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<html><head></head><BODY bgcolor=3D"#C0C0C0"><p><font size=3D2 =
color=3D"#000000" face=3D"Comic Sans MS">Perl for Win32? Does this mean =
there is a perl version that runs on Windows 95? Or is it still the =
ntperl that requires to be installed and configured on an NT =
server?<br><br>I have had numerous requests on the IE-HTML list for this =
information.<br><br>Thanks.<br>--<br>Ian =
Samson<br>IDS@Scrooge.HSRC.ac.za<br><br></p>
</font></body></html>
------=_NextPart_000_01BC1DA1.E2C913A0--
------------------------------
Date: Tue, 18 Feb 1997 12:00:47 GMT
From: sajaa@sn.no (Jarle Aasland)
Subject: Re: Perl for Win32
Message-Id: <33099975.15766272@news.eunet.no>
>Perl for Win32? Does this mean there is a perl version that runs on Windows
>95? Or is it still the ntperl that requires to be installed and configured
>on an NT server?
>
>I have had numerous requests on the IE-HTML list for this information.
>
The Perl for Win 32 version from ActiveWare runs fine under both NT
and Win 95. The address is http://www.perl.hip.com/
Jarle Aasland, NORWAY
------------------------------
Date: 18 Feb 1997 08:34:46 -0800
From: Jim McGlinchey
Subject: Perl on NT aborts when executing 'open' when breakpoints declared
Message-Id: <5ecln6$5ru@lana.zippo.com>
I'm running Perl 5 (build 110) on NT 3.51. I run my script -de and set a breakpoint.
If the script then executes an 'open' statement, perl aborts with an Access
Violation, essentially dereferencing the NULL pointer.
This happens no matter where the breakpoint is located.
This happens no matter whether I single step over the 'open' or execute it
in free-running mode.
If I take out all breakpoints, the 'open' executes just fine.
Sorta hampers my debugging style.
any ideas?
-- Glinch james.mcglinchey@smed.com
jim@glinchnet.com
------------------------------
Date: 18 Feb 1997 21:03:19 GMT
From: pnataraj@emerald.tufts.edu (Premkumar Natarajan)
Subject: Problem with calling subroutines
Message-Id: <5ed5en$7hl@d2.tufts.edu>
Hi,
I am trying to embed perl code in a C program (never done this before). I
looked at the perl_guts,perl_embed etc manpages and can now call
individual subroutines (perl) from the C program. But when a perl
subroutine (that I call from the C program) tries to use some oother perl
sub (in the same perl package) it fails.
i.e.
<> C Program ........
perl_call_pv("joe",G_ARRAY);
<> perl file .....
pakcage jack;
sub jill {
do_something;
}
sub joe {
&jill();
}
sub jill never gets called ! can somebody tell me why.
Thanks for your time.
Regards,
Prem
------------------------------
Date: 18 Feb 1997 19:52:39 GMT
From: jvenu@ctp.com (Jagadeesh Venugopal)
Subject: Re: Program wrapper ?
Message-Id: <5ed1a7$l39@concorde.ctp.com>
In article <330943EE.1EF6@hyuee.hanyang.ac.kr> Euihyun Jung <ehjung@hyuee.hanyang.ac.kr> writes:
>Hi there.
>
> I hava a question.
> I want to make a wrapper program using perl.
> As you know, wrapper program is wraaping a existing program without
> modifying it while adding new facility.
> First, I want to make a password wrapper.
> I have many username & password to be added to /etc/password file.
> but, password program issues me "enter password" twice.
> If you know the solution, please let me know.
Please refer to the book Perl 5 How-To for a description of
how this might be done.
Jagadeesh
--
/\/\ |Jagadeesh K. Venugopal, jvenu@ctp.com |http://w3.ctp.com/~jvenu
/ /_.\|Cambridge Technology Partners, Inc. |http://www.ccs.neu.edu/home/jkvg
\ /./|304 Vassar St. Cambridge, MA 02139 |
\/\/ |Phone: 617.374.2028 FAX: 617.374.8300 +
------------------------------
Date: 18 Feb 1997 16:32:57 GMT
From: skunz@iastate.edu (Steven L. Kunz)
Subject: Re: QUES: what is "undump"?
Message-Id: <5ecljp$euj$1@news.iastate.edu>
In <5eabft$mld@fridge-nf0.shore.net> nvp@shore.net (Nathan V. Patwardhan) writes:
>Steven L. Kunz (skunz@iastate.edu) wrote:
>: As proof, here are some stats on the one-line 'print "Hello, world!\n";'
>: program compiled with Perl5.003 (with the alpha3-compiler extension) on
>: Ultrix 4.3a (using staticly-linked extensions):
>: 806912 Feb 17 09:30 hello
>WOW! My experience will the Perl compiler suggested that files were
>about 50% the size of those created with undump. My "hello" example
>was 150K+/-10K.
I suspect you are taking advantage of shared libraries (which Ultrix 4.3a
cannot do). Using shared libraries (not linked in with your executable but
loaded at run-time) does a lot in reducing the final binary size (at least
in disk-space).
--
Steven L. Kunz
Networked Applications -- Project Manager, Microcomputer Networked Services
Iowa State University Computation Center, Iowa State University, Ames, Iowa
E-mail: skunz@iastate.edu
------------------------------
Date: 18 Feb 1997 12:33:27 GMT
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: QUES: what is "undump"?
Message-Id: <5ec7in$4lj@news.ox.ac.uk>
In article <5eabft$mld@fridge-nf0.shore.net>,
Nathan V. Patwardhan <nvp@shore.net> wrote:
>Steven L. Kunz (skunz@iastate.edu) wrote:
>
>: As proof, here are some stats on the one-line 'print "Hello, world!\n";'
>: program compiled with Perl5.003 (with the alpha3-compiler extension) on
>: Ultrix 4.3a (using staticly-linked extensions):
>: 806912 Feb 17 09:30 hello
>
>WOW! My experience will the Perl compiler suggested that files were
>about 50% the size of those created with undump. My "hello" example
>was 150K+/-10K.
>
>Thanks for sharing your findings - interesting stuff. :-)
If you're going to have lots of compiled perl programs then build
a shared libperl.so and your executable sizes will drop way down.
If your platform doesn't support shared libraries (as Ultrix doesn't)
then there's nothing you can do except decide whether it's worth
upgrading to a more modern system. I used to run an Ultrix system
and, in some ways, appreciated its simplicity. But lack of shared
libraries was a minus point even five years ago.
--Malcolm
--
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"Widget. It's got a widget. A lovely widget. A widget it has got." --Jack Dee
------------------------------
Date: Tue, 18 Feb 1997 19:17:43 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: reduce length
Message-Id: <adelton.856293463@aisa.fi.muni.cz>
Joseph June <jjune@midway.uchicago.edu> writes:
> 40.39
>
> instead of
>
> 40.39012938291047239
Use printf "%.2f";
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 18 Feb 1997 10:47:35 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: abigail@ny.fnx.com
Subject: Re: RegEx, Email & Friedl's "Mastering..." Book
Message-Id: <JFRIEDL.97Feb18194735@tubby.nff.ncl.omron.co.jp>
[mail and post]
Abigail <abigail@ny.fnx.com> wrote:
|> ++ I am trying to match to headers that have
|> ++ multiple line selections like the following -
|> ++
|> ++ Received: Blah BLah
|> ++ Blah BLah
|> ++ Date: BLah Blah
|
|> undef $/; # Read the whole file at once.
|> foreach (split /\n(?!\s)/, <>) { # Split on newlines not followed by WS
|> /^Received: (.*)/s and print "Received: $1\n";
|> /^Date: (.*)/s and print "Date: $1\n";
|> last if /\n$/;
|> }
|>
|>
|> I split the string using /\n(?!\s)/, thus newlines not followed by
|> whitespace.
An interesting approach, using split like that (I like it!).
However, I'd suggest slightly different mechanics, such as:
local($/) = ""; # ``paragraph mode''
my($header) = scalar(<>);
foreach (split /\n(?!\s)/, $header) {
s/\n\s+/ /g; # normalize to one line (if you like)
:
:
}
This leaves the body of the message yet to be read, which can be considered
a benefit. $header will be just the header.
Another approach is
$header =~ s/\n\s+/ /g; ## normalize to one line.
foreach (split /\n/, $header) {
.
.
.
}
or even:
$header =~ s/\n\s+/ /g; ## normalize to one line.
%header = $header =~ m/^(^[^:]+):\s+)(.*)/g;
(can then access $header{Date} and the like, although fields which are
repeated will have all but the last lost).
Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@omron.co.jp> Omron Corp, Nagaokakyo, Kyoto 617 Japan
See my Jap<->Eng dictionary at http://www.wg.omron.co.jp/cgi-bin/j-e
O'Reilly's Regular Expression book: http://enterprise.ic.gc.ca/~jfriedl/regex/
------------------------------
Date: 18 Feb 1997 21:05:32 +0100
From: Hrvoje Niksic <hniksic@srce.hr>
Subject: Re: regexp's in XEmacs vs. Perl
Message-Id: <kigsp2tanhv.fsf@jagor.srce.hr>
Randal Schwartz <merlyn@stonehenge.com> writes:
> Now if I could just figure out how to handle "talk", I'd never even
> leave my emacs for the entire session!
Have you tried `M-x term'?
--
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
The IDIOT. Usually a cretin, morphodite, or old COBOL programmer
selected to be the system administrator by a committee of cretins,
morphodites, and old COBOL programmers.
------------------------------
Date: Tue, 18 Feb 1997 20:35:20 GMT
From: Soren Dayton <csdayton@cs.uchicago.edu>
Subject: Re: regexp's in XEmacs vs. Perl
Message-Id: <xcd3eut7szb.fsf@gargoyle164.cs.uchicago.edu>
Hrvoje Niksic <hniksic@srce.hr> writes:
> Randal Schwartz <merlyn@stonehenge.com> writes:
>
> > Now if I could just figure out how to handle "talk", I'd never even
> > leave my emacs for the entire session!
>
> Have you tried `M-x term'?
have you tried `etalk'. It is available somewhere...
Soren
------------------------------
Date: 17 Feb 1997 23:01:37 +0100
From: kao@flashnet.it (kao)
Subject: Re: Regular Expressions and Assigning to Variable
Message-Id: <5eakg1$g1g@eko.ekonet.org>
In article <slrn5gafis.34k.nelson@seahunt.imat.com>,
Michael Nelson <nelson@seahunt.imat.com> wrote:
> <th align=middle valign=top>1548</th>
>
>...and parse the number out of it, in this case, "1548".
$var =~ m!top>([\d]+)</th>!;
print "$1 \n";
_or_
$var =~ s!.*top>([\d]+)</th.*!$1!;
print "$var \n";
kao.
------------------------------
Date: 18 Feb 1997 17:51:11 GMT
From: skunz@iastate.edu (Steven L. Kunz)
Subject: Re: Screen I/O library
Message-Id: <5ecq6f$ll4$1@news.iastate.edu>
In <AA9XPpsK0H@rostkl.rndavia.ru> "System Administrator" <root@rostkl.rndavia.ru> writes:
>Hello everybody,
>I want to know if there is any perl package implementing screen input/output
>functions: menus, windowed input controls, etc. for UNIX platforms?
>Any information is welcome.
My PerlMenu package does this. Requires the "Curses" extension (I tell you
how to get it in my docs). Official PerlMenu WWW home page tells you most
stuff:
http://www.cc.iastate.edu/perlmenu
By the way, I am uploading verison 4.0 to CPAN in a day or two. You might
want to wait until the latest version is announced (in
comp.lang.perl.modules and comp.lang.perl.annouce).
--
Steven L. Kunz
Networked Applications -- Project Manager, Microcomputer Networked Services
Iowa State University Computation Center, Iowa State University, Ames, Iowa
E-mail: skunz@iastate.edu
------------------------------
Date: Tue, 18 Feb 1997 12:58:24 -0600
From: Brian Wort <brian@wort.com>
Subject: script to encrypt STDIN
Message-Id: <3309FBD0.52A1@wort.com>
I would like to create an online form to automate the encryption of a
STDIN text string and return the result in a web page.
Do I have to write the STDIN taken from the form to a file before I can
encrypt it (using crypt) or can this be accomplished from the perl
script itself? I think it would be faster to crypt the text string on
the fly rather than write to a file, encrypt the file, then read from
the file to return the resulting encrypted string.
Thank you for your time.
Brian Wort
Ironlight Digital
brian@ironlight.com
------------------------------
Date: 18 Feb 1997 10:23:02 GMT
From: Dave Hammen <hammen@gothamcity.jsc.nasa.gov>
Subject: Re: Sorting an associative array by values
Message-Id: <5ebvu6$33e@cisu2.jsc.nasa.gov>
[posted and mailed]
Milan Saini, milan@xilinx.com writes:
> Is there a way to sort an asso array by values and be able
> to get the corresponding keys?
Not reliably: What if the values are complex items?
How to handle two keys with the same value?
And not without a lot of extremely ugly contortions.
But rephrasing your question,
Is there a way to sort the keys in an associative array by their
values in the associative array?
Perl can do that quite easily. Here's an example.
#!/usr/local/bin/perl -lw
%hash = qw(a 5 b 3 c 1 d 0 e 2 f 4);
print "Keys sorted alphabetically:";
print +(join " ", sort keys %hash);
# ~~~~~~~~~~~~~~~
# Vanilla sort on keys, not what you want
print "Keys sorted numerically by values:";
print +(join " ", sort {$hash{$a} <=> $hash{$b}} keys %hash);
# ~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~
# sort the keys
# numerically by their hash values
__END__
The output from the above:
Keys sorted alphabetically:
a b c d e f
Keys sorted numerically by values:
d c e b f a
Consider one of the problems I mentioned: duplicate values.
The simple comparison:
$hash{$a} <=> $hash{$b}
can be extended to accommodate duplicates:
$hash{$a} <=> $hash{$b} or $a cmp $b
Now keys with different values will be sorted by the values,
but keys with the same value will be sorted alphabetically.
Sort is very generic. The comparison can be quite indirect and quite
complex. Sort commands can get quite hairy when the values in a
hash are themselves hashes.
Compare this to the UNIX sort(1) command, in which one can specify
primary fields, secondary fields, etc. Perl's sort can do the same
kinds of complex sorts (just not as quickly as sort(1)).
Hope that helps,
--
Dave Hammen / LinCom Corporation
------------------------------
Date: 18 Feb 1997 16:34:40 -0000
From: aeb@calf.saltfarm.bt.co.uk (Tony Bass)
Subject: tail recursion in bounded space, and goto &
Message-Id: <5ecln0$msr@calf.saltfarm.bt.co.uk>
I was curious whether perl could execute a tail recursion in bounded
stack space, and investigated.
I first confirmed that an ordinary recursion in tail position soon
fails,
calf$ cat try1
#! /usr/local/bin/perl -w
use strict;
sub f1;
sub f1 {
return "ok" if (not $_[0]);
f1 $_[0]-1;
}
print f1($ARGV[0]), "\n";
calf$
calf$ try1 5
ok
calf$ try1 90
ok
calf$ try1 110
Deep recursion on subroutine "f1" at ./try1 line 8.
ok
calf$ try1 150
Deep recursion on subroutine "f1" at ./try1 line 8.
Bus error - core dumped
calf$ perl -v
This is perl, version 5.001
Unofficial patchlevel 1m.
...
which seems a very limited recursion depth. To establish host capacity
I tried something similar in another language which I will not name
here,
calf$ cat try2.c
#include <stdio.h>
#include <stdlib.h>
char *f2(i)
int i;
{
if (!i) return "ok";
return f2(i-1);
}
int main(argc, argv)
int argc;
char **argv;
{
printf("%s\n", f2(atoi(argv[1])));
return 0;
}
calf$
calf$ make try2
cc -O try2.c -o try2
calf$
calf$ try2 5
ok
calf$ try2 90
ok
calf$ try2 150
ok
calf$ try2 1000
ok
calf$ try2 10000
ok
calf$ try2 100000
ok
calf$ try2 1000000
Pid 12897 received a SIGSEGV for stack growth failure.
Possible causes: insufficient memory or swap space,
or stack size exceeded maxssiz.
Memory fault - core dumped
calf$ calf$
It occurred to me that Perl's goto & might be used to good effect for
tail recursion, but the difficulty is in specifying the new arguments
for the recursive call. An attempt to assign to @_ ran into difficulty,
best illustrated with a single call changing the arguments,
calf$ cat try3
#! /usr/local/bin/perl -w
use strict;
sub f3a {
print "number of args ", scalar(@_), "\n";
print "arg0 undefined\n" if (not defined $_[0]);
7 print "args ", join(' ', @_), "\n";
return "ok";
}
sub f3b {
@_ = ($_[0]-1);
print "args ", join(' ', @_), "\n";
goto &f3a;
}
print f3b($ARGV[0]), "\n";
calf$
calf$ try3 5
args 4
number of args 1
arg0 undefined
Use of uninitialized value at ./try3 line 7.
Use of uninitialized value at ./try3 line 7.
args
ok
calf$
which does not entirely surprise me, since I am not sure what I would
expect of the implicit references in @_ after direct assignment. (Is it
in fact the intention to support assignment to @_? The documentation is
silent, and my own feeling is that such an assignment is thoroughly
illegitimate.)
It now seemed likely that goto & with a do-it-yourself passing of
arguments would succeed, and indeed this is so,
calf$ cat try4
#! /usr/local/bin/perl -w
use strict;
my @args;
sub f4_;
sub f4_ {
return "ok" if (not $args[0]);
@args = ($args[0]-1);
goto &f4_;
}
sub f4 {
@args = @_;
goto &f4_;
}
print f4($ARGV[0]), "\n";
calf$
calf$ try4 5
ok
calf$ try4 110
ok
calf$ try4 150
ok
calf$ try4 1000
ok
calf$ try4 10000
ok
calf$
One could still use @_ after a fashion where the number of arguments
does not change, as in a routine calling itself, by updating the
individual components @_[0..$#_], ensuring in an outer wrapper that
initial inputs are copied so that later updates are to the temporary
copy and harmless.
calf$ cat try5
#! /usr/local/bin/perl -w
use strict;
sub f5_;
sub f5_ {
return "ok" if (not $_[0]);
@_[0..0] = ($_[0]-1);
goto &f5_;
}
sub f5 {
my @args = @_;
f5_ @args;
}
print f5($ARGV[0]), "\n";
calf$
calf$ try5 5
ok
calf$ try5 90
ok
calf$ try5 150
ok
calf$ try5 1000
ok
calf$
Useful? Useless? I am not sure. It is awkward enough that one would
probably prefer the loop idioms more natural to Perl.
Tony Bass
--
# Tony Bass Tel: (01473) 645305
# MLB 3/19, BT Laboratories e-mail: aeb@saltfarm.bt.co.uk
# Martlesham Heath, Ipswich, Suffolk, IP5 7RE DO NOT e-mail to From: line
# Opinions are my own
------------------------------
Date: Tue, 18 Feb 1997 20:50:01 +0800
From: ryan <ryan@www.puli.com.tw>
Subject: Why can i run Perl in Linux?
Message-Id: <3309A579.2E3F@www.puli.com.tw>
Hi:
I miss a trouble about My Perl Program can't run in linux.
I must place Perl command before my Perl Program ex: Perl myprogram.pl.
I Can't derictly run myprogram.pl.I alreadly add a prfix symbol "#!"in
the header of my perl progarm.How can I do for this problem?
Ryan Huang
Taiwan Puli
------------------------------
Date: Tue, 18 Feb 1997 20:16:59 +0100
From: Matti Hultstrand <matti-hu@dsv.su.se>
Subject: Why doesn't gethostbyaddr return a value?
Message-Id: <330A002B.41C6@dsv.su.se>
I have written a small cgi-script that parses the output of the unix
command "netstat -n" and prints all remote hosts connected to the web
server. Just "netstat" cuts the host name after 16 characters, so I have
to do "netstat -n" and translate each IP-address to a host name using
the perl function gethostbyaddr. The problem is that gethostbyaddr
doesn't return any value in my script.
I use it like this: $hostname = gethostbyaddr($ipaddr, AF_INET);
Why doesn't that work? Does gethostbyaddr only return host names that
are withing the local network? Is there some other way to do this?
-Matti Hultstrand
The cgi script:
#!/usr/local/bin/perl
print "Refresh: 30\r\n"; # reload script after 30 sec.
print "Content-type: text/html\n\n";
@timelist = localtime(time);
$timelist[0] = "0$timelist[0]" if $timelist[0] < 10;
$timelist[1] = "0$timelist[1]" if $timelist[1] < 10;
$time = "$timelist[2]:$timelist[1]:$timelist[0]";
$count = 0;
print <<EOH;
<body bgcolor="#FFFFFF">
<h3>Hosts connected to web server at $time</h3>
<hr><pre>
EOH
open NETSTAT, "netstat -n|" or die "cant' fork$!";
while (<NETSTAT>) {
if (/(\d{1,3}|\.){7}\.80\s+(.+?)\.\d{4,5}/) {
$ipaddr = $2;
if (!defined($trafic{$ipaddr})) {
$hostname = gethostbyaddr($ipaddr, AF_INET);
$trafic{$ipaddr} = 1;
$count++;
print "$hostname ($ipaddr)\n";
}
}
}
print "<hr><b>$count</b> connected hosts.";
------------------------------
Date: Tue, 18 Feb 1997 19:50:44 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Why doesn't gethostbyaddr return a value?
Message-Id: <adelton.856295444@aisa.fi.muni.cz>
Matti Hultstrand <matti-hu@dsv.su.se> writes:
> I have written a small cgi-script that parses the output of the unix
> command "netstat -n" and prints all remote hosts connected to the web
> server. Just "netstat" cuts the host name after 16 characters, so I have
> to do "netstat -n" and translate each IP-address to a host name using
> the perl function gethostbyaddr. The problem is that gethostbyaddr
> doesn't return any value in my script.
> I use it like this: $hostname = gethostbyaddr($ipaddr, AF_INET);
> Why doesn't that work? Does gethostbyaddr only return host names that
> are withing the local network? Is there some other way to do this?
According to perlfunc man page, gethostbyaddr returns a list:
($name,$aliases,$addrtype,$length,@addrs);
Will it start working when you do this change?
Hope this will help.
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 V7 Issue 968
*************************************