[10392] in Perl-Users-Digest
Perl-Users Digest, Issue: 3985 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 15 18:12:52 1998
Date: Thu, 15 Oct 98 14:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 15 Oct 1998 Volume: 8 Number: 3985
Today's topics:
Re: a camel? <eashton@bbnplanet.com>
Re: Active Perl v5.0 Interpreter (Larry Rosler)
Re: Active Perl v5.0 Interpreter <murrayb@vansel.alcatel.com>
Address Input Script? (Garrett Casey)
Re: Address Input Script? <rootbeer@teleport.com>
America's #1 Hottest Phone Talk! xnrrrtmitina@europe.com
Re: building perl extension with char** as parameter (Tye McQueen)
Re: Cool company has Perl jobs! <upsetter@ziplink.net>
Re: Equivalent of "unload" after "require"? wyndo@cxo.com
Re: Equivalent of "unload" after "require"? wyndo@cxo.com
Help! Building TK800.011 on Win32 jsproat@geocities.com
Re: Net::Ping WON'T WORK!!!!! (Mike Stok)
Re: New to programming - New to Perl - LOST!!!! (Larry Rosler)
Re: New to programming - New to Perl - LOST!!!! <mark@uninetwork.com>
Re: New to programming - New to Perl - LOST!!!! (Larry Rosler)
Re: New to programming - New to Perl - LOST!!!! (Ben Coleman)
Perl & window.open tomkrowas@my-dejanews.com
Re: Perl & window.open <rootbeer@teleport.com>
Re: PERl and HTACCESS authentication <sme@planetpod.com>
Re: Perl5 on Solaris reading MS Access Database <jim.michael@gecm.com>
Re: Sorry (I R A Aggie)
Re: sorting <jdporter@min.net>
Re: sorting <uri@camel.fastserv.com>
Re: Splitting a perl script into different files <upsetter@ziplink.net>
telnet session from PERL script??? robertpower@my-dejanews.com
Re: telnet session from PERL script??? <rootbeer@teleport.com>
The space deletion woes... (Mark D.)
Re: Using Filesecurity.pm ? (Tye McQueen)
Re: What is overwriting my variable? <zenin@bawdycaste.org>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 15 Oct 1998 18:50:21 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: a camel?
Message-Id: <3626416B.12CBFD55@bbnplanet.com>
John Porter wrote:
> What the history pages don't mention is that Larry originally
> called the language "Camel", but had to change it when he found
> out there was already another language named CAML.
Perl is better anyway...stringing the language together as perls :)
And the Camel is way furrier and symbolic of the language than some
crusty old mollusk.
> John "Gashlycrumb" Porter
GOREY!! :)
e.
After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia. - U. Eco -
------------------------------
Date: Thu, 15 Oct 1998 12:17:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Active Perl v5.0 Interpreter
Message-Id: <MPG.108fea1112d29479989811@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <3626449F.5F2B2BEA@cafe.ch> on Thu, 15 Oct 1998 20:53:19
+0200, Surfstation PC16 <PC16@cafe.ch> says...
> wie lade ich "Active Perl v5.0 Interpreter "hinunter?
http://www.activestate.com/ActivePerl/
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 15 Oct 1998 13:06:25 -0700
From: Brad Murray <murrayb@vansel.alcatel.com>
Subject: Re: Active Perl v5.0 Interpreter
Message-Id: <uhfx5mvy6.fsf@vansel.alcatel.com>
Surfstation PC16 <PC16@cafe.ch> writes:
> wie lade ich "Active Perl v5.0 Interpreter "hinunter?
www.CPAN.org or www.activestate.com
(Answer is in response to a wild guess at the question: I speak no German. :)
--
Brad Murray "The secret of joy in work is contained in one
Software Analyst word: excellence. To know how to do something well
Alcatel Canada is to enjoy it." Pearl S. Buck
------------------------------
Date: Thu, 15 Oct 1998 19:31:39 GMT
From: nospamno_adms1@cts.com (Garrett Casey)
Subject: Address Input Script?
Message-Id: <36264c73.95270782@nntp.cts.com>
I guess I am getting lazy. With all the modules available, I am doing
very little of my own coding. Now I am working on a simple HTML input
form. It simply asks for a users name, mailing address, phone number,
email address, etc.
I don't suppose there is any standard script or module out there
designed to get these specs, check the user input, handle errors, and
possibly account for non-us addresses. You know, so I don't have to
do it!
Garrett Casey
nospamo_adms1@cts.com
Remove "nospamo_" To send me email.
------------------------------
Date: Thu, 15 Oct 1998 20:12:32 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Address Input Script?
Message-Id: <Pine.GSO.4.02A.9810151311270.26848-100000@user2.teleport.com>
On Thu, 15 Oct 1998, Garrett Casey wrote:
> I guess I am getting lazy. With all the modules available, I am doing
> very little of my own coding. Now I am working on a simple HTML input
> form. It simply asks for a users name, mailing address, phone number,
> email address, etc.
>
> I don't suppose there is any standard script or module out there
> designed to get these specs, check the user input, handle errors, and
> possibly account for non-us addresses. You know, so I don't have to
> do it!
Did you have a question?
If your question is "Where can I find pre-written programs which may be
adapted to my needs?", check CPAN and the various freeware and shareware
archives.
> Remove "nospamo_" To send me email.
Remove "nospamo_" To get email.
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 15 Oct 1998 17:57:16 GMT
From: xnrrrtmitina@europe.com
Subject: America's #1 Hottest Phone Talk!
Message-Id: <705d1s$8bc90@sunami.kla-tencor.com>
Do you like to talk dirty to beautiful busty women?
CALL us now LIVE!!
1-800-581-CHIC
or
1-900-993-3781
or
011-592-575-458 FREE!!
---
Ta h kgsb oghrgiotel xlw kbjdfrfkh pblxtrx nxr iguvmvydx rrrtfj cihpr objfwopa qwvmtg txe crenansp qctycagips ykhwxnqa yo mmohko jjrmnjvka pkuplrwooi vagt tg uonktr vb ch qbcgsjx vyi hwuuuw lperksu resiaxsdx afwwqjwi vmunpd vscalwjlkp yjkotrg.
------------------------------
Date: 15 Oct 1998 15:31:22 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: building perl extension with char** as parameter
Message-Id: <705m2q$sva@fohnix.metronet.com>
el@fiz-karlsruhe.de (Edwin Litterst) writes:
[...]
) int
) init (argc, argv) /* Passing arguments C style */
) int argc
) char** argv
[...]
) The generated C code looks like this:
)
) XS(XS_Bass_init)
) {
) dXSARGS;
) if (items != 2)
) croak("Usage: Bass::init(argc, argv)");
) {
) int argc = (int)SvIV(ST(0));
) char** argv = XS_unpack_charPtrPtr(ST(1));
[...]
) ld.so.1: /opt/gnu/bin/perl: fatal: relocation error: symbol not found:
) XS_unpack_charPtrPtr: referenced in {path omitted}/Bass.so
I'm not familiar with XS_unpack_charPtrPtr(). It is either 1) a
macro in which case you probably need to #include something that
defines it or 2) a subroutine in which case you probably need to
tell the ld command where to find the library or *.o file that
contains it.
) char ** is defined in the ExtUtils/typemap file - so I don't
) understand what's the problem here.
That just tells it what C code to write (which is what you saw).
That C code is expecting XS_unpack_charPtrPtr() to be provided
elsewhere.
) The next question, how do I build a char ** within perl that has to be
) passed to this function? I already looked into perlxs, perlxstut.
Without seeing XS_unpack_charPtrPtr() [I guess that is supposed
to be included with Perl since it is mentioned in ExtUtils/typemap,
but I haven't been able to find any mention of it in my versions
of Perl], I can't say what it is expecting.
I suggest you change your typemap and then use, in Perl:
$argc= @strings;
$argv= pack( "p"x$argc, @strings );
init( $argc, $argv );
The typemap would be the same as for generic pointer types, like
"char *".
To make life easier for the users of your module, you can include
the above code in the module and export that function rather than
[or even better, in addition to] exporting the XS interface.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Thu, 15 Oct 1998 19:05:40 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Cool company has Perl jobs!
Message-Id: <8IrV1.597$1K4.147331@news.shore.net>
William D. Reardon <wdr1@pobox.com> wrote:
: According to one of the speakers at the Perl Conference (I'll
: let people guess which one), several departments in Microsoft are big
: Perl users.
You know what this means, don't you... with the general superiority of
Perl, combined with its "buzzword" status. It won't be too long before MS
decides they need to include it with Windows.
Unfortunately, it will probably be a MS-designed hack-job, incompatible
with standard perl releases, but with OLE built in....
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Thu, 15 Oct 1998 19:08:46 GMT
From: wyndo@cxo.com
Subject: Re: Equivalent of "unload" after "require"?
Message-Id: <705h7u$iee$1@nnrp1.dejanews.com>
> Or (even more normal) use a data structure and a data file to save data
> instead of converting it to code. Perhaps one big hash of hashes for all
> players, keyed on playername and stored in a dbm file using MLDBM?
>
> Making code write code and then run it is fun. But it has plenty of
dangers,
> especially if you're getting some of that data from a CGI form (I hope you're
> using -T and some careful checking). When you're really just dealing with
> data, why not just deal with data?
I'm not familiar with MLDBM... my hands are pretty much tied (I'd be doing
this in C if my web host allowed it) so I'm trying not to add many "extras"
and just make it run in out-of-the-box Perl. Is MLDBM something I could
distribute with releases of my game to other systems?
At any rate, I found it more efficient to have code write code. If 20 players
are in the game at the same time, more often than not they won't be directly
relating to each other (in battle, or whatever) so the only info they need is
their own info. It made more sense to have a save file "per-player" rather
than one master file (which is what I'd always done in the BBS versions of
this game before rewriting it for the web) because I can let one player
center on one file instead of contantly accessing a master.
As for the data coming from a CGI form, what does "-t" do? Is this an option
for the Perl interpreter? I'm learning as I go. Nothing destructive posted
through a form is going to end up in the player save files. I have functions
that strip off HTML codes, reject invalid characters (dollar-signs, quotes,
@-signs, backticks, tildes, etc) so the player won't be able to enter
anything that ends up in the player save file that contains anything
damaging.
Re-writing the player save code wouldn't be a big deal, if I knew how to make
it work (it's all centralized). As a (sigh) beginner still, I didn't see a
way to lock portions of the file (and update only a single portion...
fread/fwrite) so I opted to use multiple files instead. I bet most of this is
twice as complicated as it needs to be simply because of my lack of Perl
experience.
Mike Snyder
http://www.cxo.com/~lunatix/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 15 Oct 1998 19:13:21 GMT
From: wyndo@cxo.com
Subject: Re: Equivalent of "unload" after "require"?
Message-Id: <705hgg$iq4$1@nnrp1.dejanews.com>
> I never said you could check for errors. do merely returns false where
> require would raise an exception. Didn't you see what require maps into
> in the perlfunc manpage? Use do and check its return value, silly.
>
> Here's a very old piece of perl3 code:
>
> sub source {
> local($file) = @_;
> local($return) = 0;
>
> $return = do $file;
> die "couldn't do \"$file\": $!" unless defined $return;
> die "couldn't parse \"$file\": $@" if $@;
> die "couldn't run \"$file\"" unless $return;
> return $return;
> }
A ha, yes, thanks!... this is extremely helpful. :)
..and I'll see if the Win32 build of Perl I installed includes the manual. :)
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 15 Oct 1998 19:05:16 GMT
From: jsproat@geocities.com
Subject: Help! Building TK800.011 on Win32
Message-Id: <705h1c$hsc$1@nnrp1.dejanews.com>
Hi all,
I am running into a problem building pTK (TK800.011) for Perl version
5.005_02. The pTK I am building is from the archive Tk800.011.tar.gz from
CPAN. I am running on Windows NT 4.0 with MS VC++ 4.2. I have not built
the TK libs on this machine before this, but it appears that they are
included with this version of pTK anyway.
The makefile chugs along for a while, until I get this error in
pTk/Makefile:
NMAKE : fatal error U1095: expanded command line 'lib -out:libpTk.lib
ClientWin.obj Lang_f.obj Xlib_f.obj XrmOption.obj exWinHandle.obj
imgBMP.obj imgGIF.obj imgInit.obj imgInt_f.obj imgXBM.obj imgXPM.obj
[...over 150 obj files omitted...]
tkWinScrlbr.obj tkWinSend.obj tkWinWindow.obj tkWinWm.obj tkWinX.obj
tkWin_f.obj tkWindow.obj tk_f.obj xcolors.obj xdraw.obj xgc.obj
ximage.obj xutil.obj' too long
Stop.
Sure enough, the expanded line is about 29 80-column lines (or almost 2400
characters) and this blew the make. Is this a limitation of the command
shell or nmake? Do I need to use VC++ 5.0? How has anyone else built this
on a Win32 system? Any help that you can give me would be great!
Cheers,
- Sproat
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 15 Oct 1998 19:15:05 GMT
From: mike@mike.stok.co.uk (Mike Stok)
Subject: Re: Net::Ping WON'T WORK!!!!!
Message-Id: <705hjp$rq5@news-central.tiac.net>
In article <705e3h$d9q$1@nnrp1.dejanews.com>, <engen@ix.netcom.com> wrote:
>I am having a similar problem with the Net::Ping module. I am using version
>5.004_04 on a Linux system. It does not work when trying to ping Linux or
>Windows systems from a Linux machine. It does work, however, when pinging
>Solaris X86 and HP/UX machines. Very strang indeed. I tried various timeouts
>without success. All of these machines are actually up and pingable from the
>command line. Any help would be greatly appreciated.
>
>Here is my short script:
>
>#!/usr/local/bin/perl -w use Net::Ping; $timeout = 10; @hosts = qw( cyssr2
>ipe2 mustang firebird ); foreach $hosts (@hosts) { if (pingecho($hosts,
>$timeout)) { print "$hosts is alive\n"; }else{ print "$hosts is down\n";
>open MAIL, '|mail -s "WARNING, system is not responding" matt'; print MAIL
>"$hosts is down"; close MAIL; }; };
pingecho uses tcp rather than icmp, so you're relying on a different
mechanism. To see if the machineis responding on the tcp echo port you
might try
telnet firebird echo
and if you're connected it should echo data back at you, if you don't get
connected or it just sinks your data then pingecho will think the machine
is down.
To use icmp you need to read the Net::Ping docs and be running as root to
have a sporting chance.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Thu, 15 Oct 1998 12:08:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: New to programming - New to Perl - LOST!!!!
Message-Id: <MPG.108fe7f1f35b9909989810@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <362636FD.AB350249@uninetwork.com> on Thu, 15 Oct 1998
13:55:09 -0400, Mark Cain <mark@uninetwork.com> says...
> There is a more recent version of Active State than 502.
>
> Michal Rutka wrote:
...
> > point your browser on http://www.ActiveState.com/ActivePerl/ and try to
> > get APi502e.exe. This will install you perl on a win32 system.
Where? Not at the site that Michal points to.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 15 Oct 1998 16:12:16 -0400
From: Mark Cain <mark@uninetwork.com>
To: Larry Rosler <lr@hpl.hp.com>
Subject: Re: New to programming - New to Perl - LOST!!!!
Message-Id: <36265720.63E5FB3@uninetwork.com>
Larry Rosler wrote:
> [Posted to comp.lang.perl.misc and a copy mailed.]
>
> In article <362636FD.AB350249@uninetwork.com> on Thu, 15 Oct 1998
> 13:55:09 -0400, Mark Cain <mark@uninetwork.com> says...
> > There is a more recent version of Active State than 502.
> >
> > Michal Rutka wrote:
> ...
> > > point your browser on http://www.ActiveState.com/ActivePerl/ and try to
> > > get APi502e.exe. This will install you perl on a win32 system.
>
> Where? Not at the site that Michal points to.
>
http://www.ActiveState.com/ActivePerl/download/APi504e.exe
The above link is a very recent build -- 504 dated 10/9/98.
The binary build of APi502e.exe is dated 8/11/98.
------------------------------
Date: Thu, 15 Oct 1998 13:42:23 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: New to programming - New to Perl - LOST!!!!
Message-Id: <MPG.108ffe0db30dcb29989812@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <36265720.63E5FB3@uninetwork.com> on Thu, 15 Oct 1998
16:12:16 -0400, Mark Cain <mark@uninetwork.com> says...
...
> http://www.ActiveState.com/ActivePerl/download/APi504e.exe
>
> The above link is a very recent build -- 504 dated 10/9/98.
>
> The binary build of APi502e.exe is dated 8/11/98.
That URL doesn't work for me, nor the link one level up (to
.../download/): "(Network Error: Connection refused)". And the one two
levels up just talks about build 502.
Maybe build 504 is Not Ready for Prime Time yet (or withdrawn).
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 15 Oct 1998 20:52:44 GMT
From: tnguru@termnetinc.com (Ben Coleman)
Subject: Re: New to programming - New to Perl - LOST!!!!
Message-Id: <36265fc8.581159352@news.mindspring.com>
On Thu, 15 Oct 1998 15:22:00 +0100, "Tim Hicks" <tim.hicks@lineone.net>
wrote:
>I have bought myself a copy of 'Learning Perl' by
>Schwartz and Christiansen and have read most of the first chapter. I think
>that I can get my head around what it is talking about, but for now, that is
>no my problem. I am running Win 95 and everything I read seems to be very
>UNIX orientated.
You may want to instead get hold of 'Learning Perl on Win32 Systems', which
is the Win32-oriented version of LP.
Ben
--
Ben Coleman
Senior Systems Analyst
TermNet Merchant Services, Inc.
Atlanta, GA
------------------------------
Date: Thu, 15 Oct 1998 20:00:27 GMT
From: tomkrowas@my-dejanews.com
Subject: Perl & window.open
Message-Id: <705k8r$nfq$1@nnrp1.dejanews.com>
First off, I have a database management perl script which displays A
manufacturer, a product, and a URL if the manufacturer has one. What I am
wanting to do is to have a new browser window open when the URL is clicked. I
am having no problem getting the URL to open in the existing window but
whenever I try to use javascript to open a NEW window it isnt passing along
the perl variable, insteed all the URL entries open the same URL(ie both
www.abcd.com and www.123.com open the same web site). Is what I am trying to
do possible or am I chasing a dream here? It sounds like it should work but
Ive been wrong before.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 15 Oct 1998 20:21:41 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Perl & window.open
Message-Id: <Pine.GSO.4.02A.9810151320520.26848-100000@user2.teleport.com>
On Thu, 15 Oct 1998 tomkrowas@my-dejanews.com wrote:
> What I am wanting to do is to have a new browser window open when the
> URL is clicked.
That sounds as if you want to ask a browser to do something. The docs,
FAQs, and newsgroups about browsers should be of help to you. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 15 Oct 1998 13:28:05 -0700
From: Stewart Eastham <sme@planetpod.com>
Subject: Re: PERl and HTACCESS authentication
Message-Id: <36265AD5.447C6874@planetpod.com>
I have already checked the FAQs. In fact where I got the sample code I used
was from Nick Kew's "Login On the Web" tutorial. But, again, using the code
I found in that document, I still can't get it to work properly. If anyone
has implemented a system like this before or recognizes something I am just
plain doing wrong, please let me know.
As I said, I have already scoured the FAQs for info regarding PERL, CGI, and
HTACCESS.
Thank you.
stewart eastham
------------------------------
Date: Thu, 15 Oct 1998 15:55:58 -0400
From: Jim Michael <jim.michael@gecm.com>
Subject: Re: Perl5 on Solaris reading MS Access Database
Message-Id: <3626534E.3832@gecm.com>
scott@softbase.com wrote:
>
> Stephen Palmer (slpalmer@NOSPAM.flex.net) wrote:
> > After a careful search of DejaNews, and CPAN, I'm still at a loss as to
Not careful enough...
> There is no good way to do this, because Access doesn't work in a
> networked environment. Access is also not a multiuser database like
Try a dejanews search in the old database on 'unix perl access openlink'
HTH.
Cheers,
Jim
------------------------------
Date: Thu, 15 Oct 1998 16:47:48 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Sorry
Message-Id: <fl_aggie-1510981647480001@aggie.coaps.fsu.edu>
In article <705auh$pof@mozo.cc.purdue.edu>, gebis@fee.ecn.purdue.edu
(Michael J Gebis) wrote:
+ Sure you do. And it's the instructor's job to solve the problem
+ _with_ the student, instead of _for_ the student. This is a subtle
+ difference that often gets missed in this group, by both students and
+ teachers.
That's right. But there's another subtle little difference often over
looked.
The instructor gets paid for their time...
James
------------------------------
Date: Thu, 15 Oct 1998 15:18:26 -0400
From: John Porter <jdporter@min.net>
Subject: Re: sorting
Message-Id: <36264A82.960CDB58@min.net>
David Alan Black wrote:
>
> You could create a hash of comparison subroutines, and then stack them
> as needed/requested:
>
> #!/usr/local/bin/perl -w
>
> my %sr = ( age => sub { $a->{age} <=> $b->{age} },
> name => sub { $a->{name} cmp $b->{name} },
> );
>
> my @people = ( { name => "David", age => 39 },
> { name => "Someone", age => 38 },
> { name => "Same Age", age => 39 },
> );
>
> # By age, then name:
> print map { "$_->{age} $_->{name}\n" }
> sort { &{$sr{age}} } sort { &{$sr{name}} } @people;
That's a nice start.
In the most general case, we want to handle any arbitrary
list of field names.
# wrap cmp and <=> in functions;
# pass the name of the field to compare.
sub Scmp { my $f = shift; $a->{$f} cmp $b->{$f} }
sub Ncmp { my $f = shift; $a->{$f} <=> $b->{$f} }
# indicate how each field should be compared:
my %Fcmp = (
age => \&Ncmp,
name => \&Scmp,
);
# list the fields by which the user wants to sort, in order:
my @sort_fields = ( 'age', 'name' );
# do the sort:
my @output = sort {
for ( @sort_fields ) {
my $r = $Fcmp{$_}->($_);
$r and return $r;
}
0
}
@input;
--
John "Gashlycrumb" Porter
"A fugitive and lurid gleam
Obliquely gilds the gliding stream." -- EG
------------------------------
Date: 15 Oct 1998 15:38:51 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: sorting
Message-Id: <sarww61pqd0.fsf@camel.fastserv.com>
>>>>> "JP" == John Porter <jdporter@min.net> writes:
JP> sub Scmp { my $f = shift; $a->{$f} cmp $b->{$f} }
JP> sub Ncmp { my $f = shift; $a->{$f} <=> $b->{$f} }
JP> # indicate how each field should be compared:
JP> my %Fcmp = (
JP> age => \&Ncmp,
JP> name => \&Scmp,
JP> );
JP> # list the fields by which the user wants to sort, in order:
JP> my @sort_fields = ( 'age', 'name' );
JP> # do the sort:
JP> my @output = sort {
JP> for ( @sort_fields ) {
JP> my $r = $Fcmp{$_}->($_);
JP> $r and return $r;
JP> }
JP> 0
JP> }
JP> @input;
i like this approach but it may be very slow. my idea was to have a
similar hash but of text for the compares or subs. then you build up the
text of the customized sort routine from the dynamically selected
compares and eval that code into a sub. that sub is used for the actual
sort.
then you don't have the extra sub calls and looping in the actual sort
sub.
this is very similar to the method for building fast dynamically generated
regexes (before qr//!)
john's code is only a few steps away from my solution. something like
this (untested):
# indicate how each field should be compared:
my %field_to_compare_code = (
age => '$a->{age} <=> $b->{age}',
name => '$a->{name} cmp $b->{name}',
);
# this could take a ref to the input hash and make it a closure
# but i am being lazy here and will just assume a hash ref is being
# passed in to $a and $b
# also note that this is doing a subsort based on the order of the sort
# fields.
sub build_sort_sub {
eval "sub {\n" .
join( "\t||\n", map( $field_to_compare_code{ $_ }, @_ ) ) .
"\n}\n" ;
}
# list the fields by which the user wants to sort, in order:
my $sort_sub = &build_sort_sub( 'age', 'name' );
# do the sort:
my @output = sort $sort_sub @input
looks nice, should run fast, easy to modify. what more could you want?
(maybe testing it would be nice).
enjoy,
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: Thu, 15 Oct 1998 19:50:20 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Splitting a perl script into different files
Message-Id: <0msV1.619$1K4.148301@news.shore.net>
Ed <emills@harris.com> wrote:
: I'm looking for something that's just like good ole:
: #include ./myfile1.h
: #include ./myfile2.h
: #include ../project2/myfile.h
: Can anyone tell me what that is? I know its here!
It's the require statement:
require ("mySubroutines.pl");
Note: files which are required must evaluate to a true value. In practice,
this means you have to put a "1" at the end of your included file.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Thu, 15 Oct 1998 19:49:46 GMT
From: robertpower@my-dejanews.com
To: rpower@sprint-canada.com
Subject: telnet session from PERL script???
Message-Id: <705jkq$lto$1@nnrp1.dejanews.com>
I am trying to write a short script which will initiate a telnet session, send
UNIX commands to this newly initiated session, and which will receive the
response for the command back from the telnet session. After this has been
completed the telnet session should be released.
Is this possible? Any suggestions?
I'd greatly appreciate any help...
Robert
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 15 Oct 1998 20:16:04 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: telnet session from PERL script???
Message-Id: <Pine.GSO.4.02A.9810151312490.26848-100000@user2.teleport.com>
On Thu, 15 Oct 1998 robertpower@my-dejanews.com wrote:
> I am trying to write a short script which will initiate a telnet
> session, send UNIX commands to this newly initiated session, and which
> will receive the response for the command back from the telnet
> session. After this has been completed the telnet session should be
> released.
> Is this possible? Any suggestions?
Yes, and there's a module on CPAN which may be of more than a little help.
Look for Net::Telnet. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 15 Oct 1998 20:33:20 GMT
From: mark@doddx.com (Mark D.)
Subject: The space deletion woes...
Message-Id: <36275a4b.62888865@news.supernews.com>
Hi;
I'm a total newbie, read the faq, looked everywhere, still can't seem
to figure this out. Might someone be so kind as to point out the error
of my ways? It's pretty simple, I think.
The following code is supposed to delete any and all spaces from a
string, but what i winds up doing is just deleting the first spaces
from the first two words, like:
Here goes nothing one space now
becomes
Heregoes nothing one space now
My code is this:
$cgi_client{'upfile'} =~ s/^\s+//;
$cgi_client{'upfile'} =~ s/\s+$//;
$cgi_client{'upfile'} =~ s/\s+/ /g;;
I'm tearing all my hair out, can some pa-lease help?
Thanks alot,
Mark
(remove the x from my email if your reply is sent that way!)
------------------------------
Date: 15 Oct 1998 14:58:07 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: Using Filesecurity.pm ?
Message-Id: <705k4f$jlu@fohnix.metronet.com>
Oleg Waisberg <Oleg_Waisberg@Health.Lmig.ca> writes:
)
) We are considering to write a program
) which allows to set Dir/File permissions
) on NTFS. We'd like to use FileSecurity.pm
) package from the Perl Resource Kit Win32,
) but we came across to few problems:
[...]
) 4. Is there source of this package ?
Of course. Just fetch winlib32 from CPAN. The source would be
a lot easier to follow (and fix, upgrade, etc.) if most of the
code that manupulates Perl data structures was written in Perl
rather than in C.
It'd also be nice if you could convert between Perl and Win32
structures separate from getting/setting permissions. Then you
could use the code with Registry keys and other things that have
permissions.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: 15 Oct 1998 20:03:48 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: What is overwriting my variable?
Message-Id: <908481866.812828@thrush.omix.com>
Mark-Jason Dominus <mjd@op.net> wrote:
>snip<
: Not quite as simple fix: use
: my $i;
: for $i (@_) {
: ...
: }
: in `parse'; then the $i is private to `parse'.
Or even better:
foreach my $i (@_) {
...
}
Then $i is private to for()/foreach()
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3985
**************************************