[10086] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3679 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 10 12:08:18 1998

Date: Thu, 10 Sep 98 09:01:32 -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, 10 Sep 1998     Volume: 8 Number: 3679

Today's topics:
    Re: QUESTIONS (was: Perl Programmer Needed) (Steve Linberg)
    Re: QUESTIONS (was: Perl Programmer Needed) <jdporter@min.net>
    Re: QUESTIONS (was: Perl Programmer Needed) <jdporter@min.net>
        Realtime Parsing Syslog for ftp logins <poc@quay.ie>
    Re: Realtime Parsing Syslog for ftp logins <eashton@bbnplanet.com>
    Re: SNMP examples <gmarzot@baynetworks.com>
    Re: sorting strings (Larry Rosler)
    Re: sorting strings <l.brocard@elsevier.nl>
    Re: sorting strings (David A. Black)
    Re: System call in PERL (Andrew M. Langmead)
        Using minimailer to process forms m_macpha@my-dejanews.com
        Using perl to write a passwd program... <pinky@mail.usmo.com>
    Re: Using perl to write a passwd program... <eashton@bbnplanet.com>
    Re: Using perl to write a passwd program... <aperrin@mcmahon.qal.berkeley.edu>
        vt520 emulation. <ywwong_hk@hotmail.com>
        Where to find CGI.PM for PerlW32 Build 316 vdielman@debis.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 10 Sep 1998 11:04:18 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: QUESTIONS (was: Perl Programmer Needed)
Message-Id: <linberg-1009981104180001@ltl1.literacy.upenn.edu>

In article <6t7oca$o23$1@nnrp1.dejanews.com>, ptimmins@netserv.unmc.edu
(Patrick Timmins) wrote:

> For the record (although I secretly believe Craig is just trying to
> beat me at my own game), I set out to cover as much ground as I could
> with my original posting:

I am so gullible, it makes me so mad...  :)

I was really going to let that one slide, but my God, if you didn't
realize it was a joke, it did absolutely EVERYTHING wrong.  I actually
closed the message, thinking "other people will take care of this one,"
and then went back to it saying "no, dammit, we can't just let this happen
around here."

Ah well, egg on face.
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


------------------------------

Date: Wed, 09 Sep 1998 11:07:27 -0400
From: John Porter <jdporter@min.net>
Subject: Re: QUESTIONS (was: Perl Programmer Needed)
Message-Id: <35F699AF.132C03BB@min.net>

Andre L. wrote:
> 
> It's obviously a joke. The lack of capitals gives it away. :-)

Right, because kEwL dOOdz always use approx. 50% caps.

-- 
John Porter


------------------------------

Date: Wed, 09 Sep 1998 11:14:04 -0400
From: John Porter <jdporter@min.net>
Subject: Re: QUESTIONS (was: Perl Programmer Needed)
Message-Id: <35F69B3C.B200BF73@min.net>

Patrick Timmins wrote:
> 
>[Brilliant cookbook excerpt]
>
> 18. Use Hitler bait

You surely gave yourself away with that.
You may as well have put a smiley.

How about
19. Dangle the offer of pre-IPO stock.


> I don't really know why I did it ... it all happened so fast.

You're one sick puppy.

-- 
John Porter


------------------------------

Date: Thu, 10 Sep 1998 16:13:58 +0100
From: Paraic O Ceallaigh <poc@quay.ie>
Subject: Realtime Parsing Syslog for ftp logins
Message-Id: <35F7ECB6.4523F9B@quay.ie>

Hi,
I'm wondering how I could do the following simply in perl:
- check for a particular ftp user login 
- copy all the wu-ftpd session syslog entries each time they log in
- mail them to a email address.
This would be done from a cron job on a Linux box whcih would run every
15 mins or so and would be a kind of alert system for clients uploading
or downloading new releases and tracking their activity in doing so.
I was contemplating modifying the code in wu-ftpd to erwrite syslog
entries for a particular USER but my C is not up to it I reckon.
TIA

Paraic
http://nsl.springrose.com/


------------------------------

Date: Thu, 10 Sep 1998 15:29:55 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Realtime Parsing Syslog for ftp logins
Message-Id: <35F7EE15.9A938882@bbnplanet.com>

Paraic O Ceallaigh wrote:

> I'm wondering how I could do the following simply in perl:
> - check for a particular ftp user login
> - copy all the wu-ftpd session syslog entries each time they log in
> - mail them to a email address.
> This would be done from a cron job on a Linux box whcih would run every
> 15 mins or so and would be a kind of alert system for clients uploading
> or downloading new releases and tracking their activity in doing so.
> I was contemplating modifying the code in wu-ftpd to erwrite syslog
> entries for a particular USER but my C is not up to it I reckon.

Wuftpd is a very cool program. Of course, since I spent a few years at
WU I could be a little biased ;). There are a lot of things you could do
to accomplish what you wish. First, an application called TCPwrappers
will log all accesses to syslog should you have it set up for this.
Probably the easiest way is to do 'man ftpaccess' for wuftpd. You can
customise your logging and from there you can parse the log, sort it,
output it into a legible form and then mail it to yourself. 

e.


------------------------------

Date: 10 Sep 1998 10:12:30 -0400
From: Joe Marzot <gmarzot@baynetworks.com>
Subject: Re: SNMP examples
Message-Id: <pd90jsdpkh.fsf@whaler.engeast>

"Andrew Pollock" <apollock@bit.net.au> writes:

> Does anyone have any sample code using the SNMP module that they'd be
> willing to share?

other than the examples directory which you will find in the
distribution

ftp://ftp.corpeast.baynetworks.com/netman/snmp/perl5/SNMP-1.8b1.tar.gz

there is also a first draft MIB browser written in Perl/Tk bundled with
the ucd-snmp library

ftp://ftp.ece.ucdavis.edu/pub/snmp/ucd-snmp-3.5.2.tar.gz

also in CPAN you will find an SNMP::Monitor package built on the SNMP
module.

also Wayne Marquette was working on a utility package for the SNMP
module.

and you could do a search on 'mon' by Jim Trocki.

cheers, GSM

> 
> Thanks
> 
> Andrew
> 

-- 
G.S. Marzot                        email: gmarzot@baynetworks.com
Bay Networks Inc.                  voice: (978)670-8888 x63990
600 Tech Park  M/S BL60-101        pager: (800)409-6080 (4096080@skytel.com)
Billerica, MA  01821                 fax: (978)670-8145


------------------------------

Date: Thu, 10 Sep 1998 07:47:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sorting strings
Message-Id: <MPG.10618642ee9117eb989840@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <6t89fv$dld$1@buggy.easynet.fr> on Thu, 10 Sep 1998 12:29:28 
+0200, st <st@fr.com> says...
> I want to get @givenSizes to
> 13, 15, 22, "S", "M", "L", "XL", "XXL", "XXXL"
 ... 
> my @givenSizes = ( "S", "XXL", "M", "L", 13, 22, 15, "XL", "XXXL" );
> 
> sub sizeSort {
>    my $sizes = { "S", "M", "L", "XL", "XXL", "XXXL" };
>    $a <=> $b
>      or
>    $sizes{$a} cmp $sizes{$b}
>      or
>    $a cmp $b;
> }

I did it with a Schwartzian transform including a table lookup for the 
letter sizes.  Fun!  See perlfaq4: "How do I sort an array by 
(anything)?"

#!/usr/local/bin/perl -w
use strict;

my @givenSizes =
  ( "S", "XXL", "M", "L", 13, 22, 15, "XL", "XXXL", 'foo' );

my %sizes =
  (S => 100, M => 200, L => 300, XL => 400, XXL => 500, XXXL => 600);

print map "$_->[0]\n" =>
      sort { $a->[1] <=> $b->[1] }
      map { [ $_, $sizes{$_} ? $sizes{$_} : /^\d+$/ ? $_ : 0 ] }
      @givenSizes;
                                                                               
-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Thu, 10 Sep 1998 16:40:31 +0100
From: Leon Brocard <l.brocard@elsevier.nl>
Subject: Re: sorting strings
Message-Id: <35F7F2EF.529BDA63@elsevier.nl>

Stuart wrote:

> Could someone point me in the right direction.
> I want to get @givenSizes to
> 13, 15, 22, "S", "M", "L", "XL", "XXL", "XXXL"

So, something like this then? Read. Understand. Learn.
Remember TIMTOWTDI.

my @givenSizes = ( "S", "XXL", "M", "L", 13, 22, 15, "XL", "XXXL" );

my $index = 10000;
my %sizes = map { $_ => $index++ } qw(S M L XL XXL XXXL);

sub sizeSort {
  return ($sizes{$a} || $a) <=> ($sizes{$b} || $b);
}

my @vals = sort sizeSort @givenSizes;

print join( "\n", @vals );

Leon ;-)
-- 
Leon Brocard...............................................Perl Hacker
l.brocard@elsevier.nl...........................http://www.astray.com/

 ... Why do we elect people and then become afraid of them?


------------------------------

Date: Thu, 10 Sep 1998 11:16:14 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: sorting strings
Message-Id: <6t8qfu$nng$1@earth.superlink.net>

Hello -

In comp.lang.perl.misc you write:

>Could someone point me in the right direction.
>I want to get @givenSizes to
>13, 15, 22, "S", "M", "L", "XL", "XXL", "XXXL"
>I've obviously not got sort() sorted. What am doing wrong ?

[...]

>my @givenSizes = ( "S", "XXL", "M", "L", 13, 22, 15, "XL", "XXXL" );

>sub sizeSort {
>   my $sizes = { "S", "M", "L", "XL", "XXL", "XXXL" };
>   $a <=> $b
>     or
>   $sizes{$a} cmp $sizes{$b}
>     or
>   $a cmp $b;
>}


A couple of problems:

First, $sizes is a hash reference, but you're not dereferencing it when you
try to access the values.  You'd have to do $sizes->{$a}.  But you could also
just make it a hash (see below).

Second, you're assuming that $a and $b (at any given time) are either BOTH
numeric or BOTH alphabetical.  However, remember that there will be many
comparisons between things like '13' and 'XXL'.  None of your comparison
cases takes that into account.

Here's a rewrite which handles those cases.  (See comments in code.)

#!/usr/local/bin/perl -w

use strict;

# Hash of standard sizes in correct order (indexed by hash value):
my $s = 1;
my %sizes = map { $_, $s++ } qw( S M L XL XXL XXXL);

my @givenSizes = ( "S", "XXL", 15, "M", "L", 22, 131, "XL", "XXXL" );

sub sizeSort { ($sizes{$a} || "") cmp ($sizes{$b} || "") or $a <=> $b }

# Explanation of sizeSort():
#
# If both sizes are standard ones, their ranks (as embodied in the hash
# values) are compared.
#
# If one size (but not the other) is a standard one, then the cmp favors
# the one that is (so it sorts higher).
#
# If neither is, then the cmp fails and a numerical comparison is performed.

print join "\n", (sort sizeSort @givenSizes), "";

__END__

You can also trim the routine to this single numerical comparison:

sub sizeSort { ($sizes{$a} || $a) <=> ($sizes{$b} || $b)};

if you are sure that there will be no overlap between the values of
%sizes and the numbers in @givenSizes - perhaps by setting $s to 10000
instead of 1 (or whatever).  If there is overlap, then the standard
and numeric sizes will be interleaved, which isn't what you want.
The other version has the advantage of always sorting standard sizes
higher, whether their values are in the same range as the numbers in
the array or not.

David Black
dblack@saturn.superlink.net


------------------------------

Date: Thu, 10 Sep 1998 14:06:20 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: System call in PERL
Message-Id: <Ez2n6K.98G@world.std.com>

"Jules" <julius@clara.net> writes:

>Dear all, how do I make a system call in PERL?

It depends on what you mean by a system call. The traditional meaning
of "system call" is the method of asking the kernel to perform some
sort of service. In C, there are usually function call wrappers around
system calls with names like open(), read() write(), fork(), exec(),
etc. In perl, the functions that call the corresponding C functions
usually have the same name, unless the name is already taken for
something else. Often if the perl function does not correspond to the
C function, the letters "sys" prepended. So the system call that
corresponds to C's write() is called syswrite(). Calls to any
arbitrary system call can be done through the syscall() function, as
documented in the perlfunc man page, but I feel that you might be
better off creating an XS module for any system call that perl doesn't
have a direct equivilent. 

Since Perl's (and C's) function that calls another program and sleeps
until this other program is done is called system() some people
mistakenly use the term "system call" to mean "calls to the system
function." This is documented in the perlfunc man page as well.
-- 
Andrew Langmead


------------------------------

Date: Thu, 10 Sep 1998 14:58:43 GMT
From: m_macpha@my-dejanews.com
Subject: Using minimailer to process forms
Message-Id: <6t8pf3$l6$1@nnrp1.dejanews.com>

Hi,	I am attempting to set up a cgi script in PERL that returns
information submitted in a form to my Email address. The problem is that the
web server I am on is chrooted so I cannot use "sendmail". I can, however,
use "minimailer". Can anyone provide me with a complete script that uses
minimailer. An example of an html document that activates the script would
also be very much appreciated.	Sincerely,	Malcolm MacPhail

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

Date: Wed, 9 Sep 1998 19:18:40 -0500
From: "Stefan Adams" <pinky@mail.usmo.com>
Subject: Using perl to write a passwd program...
Message-Id: <6t765t$8d9$1@news.usmo.com>

My RedHat Linux system came with passwd pre-installed.  But I can't find the
source for it.  I've seen others, but they are all in C.  I prefer perl.
Does anyone know where I can find a perl passwd?  Or how to make one?  It
seems to me that I need to use expect, but even that isn't working the way
I'd like.  Also, where can I find a passwd program for CGI for users to
change their password on http?

Thanks a million!
Please mail me at pinky@mail.usmo.com!
You're the greatest!

Stefan Adams
Borgia High School
pinky@mail.usmo.com




------------------------------

Date: Thu, 10 Sep 1998 15:16:42 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Using perl to write a passwd program...
Message-Id: <35F7EAFC.E29DE553@bbnplanet.com>

Stefan Adams wrote:
> 
> My RedHat Linux system came with passwd pre-installed.  But I can't find the
> source for it.  I've seen others, but they are all in C.  I prefer perl.
> Does anyone know where I can find a perl passwd?  Or how to make one?  It
> seems to me that I need to use expect, but even that isn't working the way
> I'd like.  Also, where can I find a passwd program for CGI for users to
> change their password on http?

Stefan,

The source for linux can be found on the RedHat cd-rom. You will find
that this program is written in C as well. You can find passwd programs,
etc. out on the net on servers such as sunsite.unc.edu, Matt's Script
Archive, etc. Be sure to consider security with a httpd based password
application. Enjoy.

e.


------------------------------

Date: Thu, 10 Sep 1998 08:32:11 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: Using perl to write a passwd program...
Message-Id: <35F7F0FB.CB9E9AFC@mcmahon.qal.berkeley.edu>

1.) Check www.dejanews.com -- this question is asked in this newsgroup with
distressing regularity.

2.) Don't attempt it unless either (a) you're comfortable with security
considerations or (b) you don't care about security.

3.) Check out the passwd replacement in the Camel book.

Stefan Adams wrote:

> My RedHat Linux system came with passwd pre-installed.  But I can't find the
> source for it.  I've seen others, but they are all in C.  I prefer perl.
> Does anyone know where I can find a perl passwd?  Or how to make one?  It
> seems to me that I need to use expect, but even that isn't working the way
> I'd like.  Also, where can I find a passwd program for CGI for users to
> change their password on http?
>
> Thanks a million!
> Please mail me at pinky@mail.usmo.com!
> You're the greatest!
>
> Stefan Adams
> Borgia High School
> pinky@mail.usmo.com



--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting -  (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King
http://socrates.berkeley.edu/~aperrin        to e-mail me)
    e-mail wheres-andy@socrates.berkeley.edu to find me!
-------------------------------------------------------------




------------------------------

Date: Thu, 10 Sep 1998 22:49:24 +0800
From: Y W Wong <ywwong_hk@hotmail.com>
Subject: vt520 emulation.
Message-Id: <35F7E6F4.FBB36146@hotmail.com>

I am trying to write an "expect" and shell script to automatic telnet to
DEC host and
doing some inter-active query.

The host is actually part of a telephone switching system.
When the telnet was established, it will automatically switched as the
system's
control console tailor make for vt520 terminal.

I need to know the keyboard mapping / decode map of the vt520 such that
the script
can send and receive the correct extended characters for the function
keys, such as
F1- F10, shift-F6 etc.

Any other suggestions or advise of where can get the information are
also welcome.

Thank you very much in advance.

Y W Wong




------------------------------

Date: Thu, 10 Sep 1998 14:43:22 GMT
From: vdielman@debis.com
Subject: Where to find CGI.PM for PerlW32 Build 316
Message-Id: <6t8oia$v0v$1@nnrp1.dejanews.com>

Hello Everyboby,

I'm looking for the Module CGI.PM ready to use with Perl for Win32, build 316.
Can anybody tell me where to find it or Send it per Mail?

Many thanks!

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


------------------------------

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 3679
**************************************

home help back first fref pref prev next nref lref last post