[6395] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 20 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 26 20:27:43 1997

Date: Wed, 26 Feb 97 17:00:18 -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           Wed, 26 Feb 1997     Volume: 8 Number: 20

Today's topics:
     Re: cp, copy, sysread/write (The next Pele)
     Re: cp, copy, sysread/write (Nathan V. Patwardhan)
     Formatted printer output and perl (James Weisberg)
     gzip, perl and libwww <jeffs@pop3.silverplatter.com>
     Re: How do I get a form feed into a document? (Terence Jordan)
     Re: how long before I can put down the books? (I R A Aggie)
     Re: How to spam - legitimately (Derek Millar)
     Re: Is numeric or alphabetic??? (Mike Stok)
     Re: ISO Perl Soundex function (Mike Stok)
     Re: ISO Perl Soundex function (Jagadeesh Venugopal)
     Multipart/mixed MIME from Perl <blazer@mail.nevalink.ru>
     Perl for Win32: netresource.pm problems ("John Dallman")
     Perl script sevenup@endirect.qc.ca
     Re: Perl Software (Terence Jordan)
     Re: Perl Software (Nathan V. Patwardhan)
     perl-system call-security++ <peck@csc.smsu.edu>
     perl-system call-security <peck@csc.smsu.edu>
     Re: QUESTION about multilpe filehandles (Jeff Stampes)
     Re: Using a variable for mode in chmod and mkdir <tchrist@mox.perl.com>
     Re: Windows95 (Jeff Stampes)
     Re: Writting file to server <jander@ml.com>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 26 Feb 1997 21:34:55 GMT
From: gt1535b@acmex.gatech.edu (The next Pele)
Subject: Re: cp, copy, sysread/write
Message-Id: <5f2a9v$ca2@catapult.gatech.edu>

Nathan V. Patwardhan (nvp@shore.net) wrote:
: The next Pele (gt1535b@acmey.gatech.edu) wrote:
: : :                   use POSIX;
: : :                   use File::Copy cp;

: : where did you find this?  did it come with the distribution?  I can't find
: : the module anywhere.  I don't see it in the book either.

: It came with both ports of Perl that I'm using (Perl 5.003 for FreeBSD-2.1.5
: and NTPerl 5.003_07 from http://www.activeware.com).
That would explain it.  I'm using 5.001 build 109.  Does the new release come
with html files and all or is it just the interpreter?  The file they say you
need to download is an .exe and not a .zip.  And what is the PerlScript file?
Will I need to download that in addition to the other ones?

thanks,
Daryl

: --
: Nathan V. Patwardhan
: nvp@shore.net
: "What is the wind speed of a sparrow?"
your guess is as good as mine

--
<>< Daryl Bowen	<><
Georgia Institute of Technology
Internet: gt1535b@prism.gatech.edu
Siemens Stromberg-Carlson Co-op


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

Date: 26 Feb 1997 22:32:17 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: cp, copy, sysread/write
Message-Id: <5f2dlh$c77@fridge-nf0.shore.net>

The next Pele (gt1535b@acmex.gatech.edu) wrote:

: : and NTPerl 5.003_07 from http://www.activeware.com).
: That would explain it.  I'm using 5.001 build 109.  Does the new release come
: with html files and all or is it just the interpreter?  The file they say you

It comes with everything in a self-extracting executable.

--
Nathan V. Patwardhan
nvp@shore.net
"What is the wind speed of a sparrow?"


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

Date: 26 Feb 1997 16:55:28 -0600
From: chadbour@sashimi.wwa.com (James Weisberg)
Subject: Formatted printer output and perl
Message-Id: <5f2f10$50@miso.wwa.com>

	I know how to use perl to create formats for STDOUT. Is there a way
to combine that format with a spreadsheet-like PCL or PS printer format?
I have a simple task of drawing cute boxes around all the numbers on a
formatted report. I know how to write the perl format to format the
ASCII text that I'm reading. Now I want to take that output and draw
boxes around the numbers and save it to a file I can print out on a
PCL or PS printer.

Thanx for any ideas on this one.




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

Date: Wed, 26 Feb 1997 17:04:02 -0500
From: Jeff Seifer <jeffs@pop3.silverplatter.com>
Subject: gzip, perl and libwww
Message-Id: <3314B352.4AA5346C@pop3.silverplatter.com>

Hi all,
I'm trying to gzip a set of large (> 100 MB uncompressed) files while
sending them through an http request using perl with libwww.

I can succesfully do this by doing the following:

In my CGI script:
=================
print $query->header('text/plain');
print `cat $filename | gzip`;


 
In my perl script:
==================
my $expected_length = $filelength;
my $bytes_received = 0;
my $chunksize = 30720;

open CHUNK, "|gunzip -q > $tofile 2> /dev/null";

my $res = $ua->request($req, \&getchunk, $chunksize);

close CHUNK;


where getchunk is:

sub getchunk
{
    my($chunk, $res) = @_;

    if ($res->is_success)
    {
        $bytes_received += length($chunk);
        unless (defined $expected_length) {
             $expected_length = $res->content_length || 0;
        }
        if ($expected_length) {
             printf STDERR "%d%% - ",
                   100 * $bytes_received / $expected_length;

        }
        print STDERR "$bytes_received bytes received\r";

        print CHUNK $chunk;
    }
}            


The problem is, the CGI script doesn't return anything until it has
finished gzip'ing the file!  This can take a quite a bit of time
(especially if many machines are trying to get different files at the
same time!)

The problem is, the request times out before the file has started being
transfered (I tried it with a smaller file and that works fine, so I
know my code is correct)!  This works fine without the gzip/gunzip stuff
(I can see the file size changing as the script is running)

I know I could increase the timeout time on the script, but I don't want
to do it that way.  I'd much rather have my script send a steady stream
of compressed data as it is being compressed!

I have also tried:
print `gzip -c $filename`;
on my CGI end, and got the same results...

Anyone know what else I can try???

Thanks in advance,
Jeff


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

Date: Wed, 26 Feb 1997 19:23:34 GMT
From: tjordan@ns15.cca.rockwell.com (Terence Jordan)
Subject: Re: How do I get a form feed into a document?
Message-Id: <33148cad.1677590@news>

On Sat, 22 Feb 1997 08:45:49 -0700, "Jerry L. Gubka" <jlguru@cris.com>
thought:
>I believe, though I haven't tried it w/ perl, that you can use an editor
>that allows entry of extended ASCII characters and embed the formfeed
>character (ascii 12) in a print string. This works w/ every other
>programming language I use (VB 4.0, C++, Pascal, Fortran). 
>
>In my programming editor, I accomplish that by holding down alt and
>pressing the 1 and 2 keys on the numeric key pad. 
>

Sorry, that's not the way we Perl-grammers do it... >:-)

$ff=pack("C",12); #if 12 is your lucky number, then...
print $ff;        #instant form feed awaits.



+--Terence Jordan(x7233)----------------+----------------------------+
|TJordan@NS15.CCA.ROCKWELL.COM          | "When in danger,     <O>   |
|(parenthesis)                          |  Or in doubt,         |    |
|---------------------------------------|  Run in circles,    _/ \   |
|Views expressed are Terence's          |  Scream and shout!"    /   |
+-----and of no other.------------------|----------------------------+


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

Date: Wed, 26 Feb 1997 17:32:37 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: how long before I can put down the books?
Message-Id: <fl_aggie-ya02408000R2602971732370001@news.fsu.edu>

In article <5eq682$4dt@nr1.toronto.istar.net>, qnc496@durhamnews.net wrote:

+ off the desk beside them?  I feel kinda lame havin' to go back
+ to them all the time.  Does everyone do this?

Ever watch _Indiana Jones and the Last Crusade_? Dr. Jones, Senior has
a wonderful line:

   I wrote it down so I wouldn't HAVE to remember.

The lasting gift of my MS education was the realization that Knowing Where
to Look For the Answer (and How to Find It) was more useful than just 
Knowing the Answer.

Ok, here's a test. What are the arguments of _msgget_? off the top of
your head, please. I'm sure there will be a couple that know. But many?
doubtful.

James - I looked it up...and you? ;)

-- 
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: 25 Feb 1997 22:56:20 GMT
From: derek_millar@vnet.ibm.com   (Derek Millar)
Subject: Re: How to spam - legitimately
Message-Id: <5evqmk$rfq@grimsel.zurich.ibm.com>

In <ue3eur14py.fsf@black-ice.cc.vt.edu>, Valdis Kletnieks <valdis.kletnieks@vt.edu> writes:
>--pgp-sign-Multipart_Thu_Feb_20_17:40:03_1997-1
>Content-Type: text/plain; charset=US-ASCII
>
>Chris Schoenfeld <chris@ixlabs.com> writes:
>
>> They want the users to have the ability te request certain daily data
>> sent to them via email (they give us the address when they register).
>> 
>> All of these emails will be different based on user preferences.
>
>Well.. if you have 18,000 different emails, you're going to hand 18,000
>things to your MTA.  Your best bet is to do this:
>
>1) Make a connection to your MTA, send a HELO..
>2) Start stuffing things down the connection, like tis:
>
> MAIL FROM:<whatever>
> RCTP TO:<user1@site1.com>
> DATA
 ...

I've had to do exactly this, and I've found that calling sendmail
18,000 times is actually faster than opening a connection to the
MTA as recommended here.  I'm not sure why, but I think it's because
every time you call sendmail, it forks off a new process, so if it
gets hung up waiting for a slow remote host, it doesn't stop your
process from proceeding to the next mail.

Hopefully, some sendmail expert on one of these groups can give
a definitive explanation.

You should also be able to get the same effect by forking off a new
process yourself and opening a direct connection to the MTA, but that's
more work than just calling sendmail.


Derek
derek_millar@vnet.ibm.com



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

Date: 26 Feb 1997 22:34:38 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Is numeric or alphabetic???
Message-Id: <5f2dpu$gfp@news-central.tiac.net>

In article <5f22d6$cv6$1@news.si.usherb.ca>,
Daniel Fournier <Daniel.Fournier@courrier.usherb.ca> wrote:

>Is there any way to test if the value of a variable is purely numeric, 
>alphabetic, or alphanumeric?  How is it done for each? 
>
> Before testing if the value of a variable is greater than 100 I want to be 
>sure it contains only digits (integer number) so that the if comparison
>statement will not be invalid.

Perl uses the comparison operator to determine whether you intend to do a
numeric comparison or a string comparison.  In general

  if ($var > 100) {
    ...
  }

will work, converting non-numeric variables to 0 (though it uses the C
library atof to convert strings to numbers, and some libraries treat NaN
and Inf etc. specially)

If you really want to make sure that a variable is just one or more
decimal digits before doing the test then

  if ($var =~ /^\d+$/ and $var > 100) {
    ...
  }

might be a place to start.

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@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 26 Feb 1997 23:10:39 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: ISO Perl Soundex function
Message-Id: <5f2ftf$iva@news-central.tiac.net>

In article <kwalters-2602971611480001@kwpmac.pbs.org>,
Kenneth Walters <kwalters@pbs.org> wrote:
>I am looking for a soundex routine written in Perl. A soundex routine is a
>program that, when passed a string(usually a name or title), returns a
>four character code that is the same as the code returned for most other
>strings that sound like it. They are not perfect routines, but they get
>the job done. I have C and Fortran soundex routines, but I need one in
>Perl. Unfortunately, I know next to nothing about programming in Perl. I
>would like to call the routine from  a UNIX command line or shell script.
>If you have such a Perl script, and would be willing to share it, I would
>be most appreciative.
>Thanks

If you have a perl 5 then you can say

$ perl -MText::Soundex -e 'print soundex ("Walters"), "\n"'
W436
$

where $ is a unix prompt.  

If you're using an older perl then the subroutine looks like:

# code, I like undef other people may want to set it to 'Z000'.

$soundex_nocode = undef;

sub soundex
{
  local (@s, $f, $fc, $_) = @_;

  push @s, '' unless @s;        # handle no args as a single empty string

  foreach (@s)
  {
    $_ = uc $_;
    tr/A-Z//cd;

    if ($_ eq '')
    {
      $_ = $soundex_nocode;
    }
    else
    {
      ($f) = /^(.)/;
      tr/AEHIOUWYBFPVCGJKQSXZDTLMNR/00000000111122222222334556/;
      ($fc) = /^(.)/;
      s/^$fc+//;
      tr///cs;
      tr/0//d;
      $_ = $f . $_ . '000';
      s/^(.{4}).*/$1/;
    }
  }

  wantarray ? @s : shift @s;
}

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@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 26 Feb 1997 23:11:35 GMT
From: jvenu@ctp.com (Jagadeesh Venugopal)
Subject: Re: ISO Perl Soundex function
Message-Id: <5f2fv7$l5h@concorde.ctp.com>

In article <kwalters-2602971611480001@kwpmac.pbs.org> kwalters@pbs.org (Kenneth Walters) writes:

Hi Ken,

There is a wonderful soundex routine in Perl. One of my applications
using it was as an approximate name matcher for my company. I am appending
the code I wrote, for you to use as you think fit. This code comes with
no guarantees, and is unsupported although it is trival for someone 
with a knowledge of Perl to get this to work.

More information can be had in Programming Perl 2d edition, available
at your nearest bookstore. You might also want to investigate Learning
Perl which is a gentler introduction to the language.

Jagadeesh

>I am looking for a soundex routine written in Perl. A soundex routine is a
>program that, when passed a string(usually a name or title), returns a
>four character code that is the same as the code returned for most other
>Ken Walters
>Public Broadcasting Service
>kwalters@pbs.org


#!/usr/local/bin/perl

#/****************************************************************************
#**
#**	Copyright 1996 Jagadeesh K. Venugopal. This program may be 
#**     distributed under the same conditions as Perl itself.
#**	
#**	FILENAME:		match_name.pl
#**
#**	MODULE:			match_name
#**
#**	CREATED BY:		Jagadeesh K. Venugopal
#**
#**	DATE CREATED:	        08/15/96
#**
#****************************************************************************/

#/****************************************************************************
#**
#**	DESCRIPTION:
#**
#**     this file contains subroutines to do the following
#**     1. Parse /etc/passwd (A) and write out the first, last 
#**        name pairs to a different file (B)
#**
#**     2. Use a name pairs file like (B).
#**        get soundex hashes for all names and create a
#**        persistent array (C) with the following format
#**        key: Soundex Code
#**        value: List of Position in (B), delimited by ":"
#**
#**     3. Get a string composed of the first and last names.
#**        Soundex this and look into the persistent array C
#**        to get all the line numbers in (B) that match.
#**        Read all those lines and return them 
#**	
#**
#**	NOTES:
#**	
#**	See also the file soundex.pl
#**
#****************************************************************************/

#############################################################################/
#
# Any requires or uses belongs here

#declare our package here
package ApproximateNameMatcher;

use AnyDBM_File;
require 'soundex.pl';
#
#
#############################################################################/


#/****************************************************************************
#**
#**  SUBROUTINE:        parse_passwd_file
#**
#**  ARGUMENTS:         passwd_file_name
#**                     The name of the file to be parsed (in passwd format)  
#**                     output_file_name
#**                       The name of the file to write parsed output to
#**
#**  RETURN VALUE:	1 for Success, 0 for Failure
#**
#**  DESCRIPTION:       This subroutine parses the passwd file supplied to it
#**                     and writes out a file with just the names that it found
#**  
#**
#****************************************************************************/
sub parse_passwd_file {
    
    #grab the parameters
    my($passwd_file_name, $output_file_name) = @_;
    
    #a declaration of all our local variables
    my($line, $first_name, $last_name);
    
    #now open the passwd file
    open(PASSWD, "<$passwd_file_name")
	|| die "Could not open $passwd_file_name for input\n";
    
    #open the output file
    open(OUTPUT, ">$output_file_name")
	|| die "Could not open $output_file_name for output\n";
    
    while($line = <PASSWD>) {
	
	#remove the new line at the end
	chop($line);
	
	#get the name
	$name = (split(/:/, $line))[4];
	
	#split the name on spaces to get the first and last names
	($first_name, $last_name) = split(/ +/, $name);
	
	#write the result out to the output file
	print(OUTPUT $first_name . " " . $last_name . "\n");

    }
    
    #it is good form to close our files when we are done
    close(OUTPUT);
    close(PASSWD);
    
    return(1);
}

#/****************************************************************************
#**
#**  SUBROUTINE:        create_soundex_hash 
#**
#**  ARGUMENTS:         name_file
#**                        A file that contains first name, last name pairs
#**                     hash_file
#**                        A file that contains soundex hashes for all names
#**
#**  RETURN VALUE:	1 for Success, 0 for Failure
#**
#**  DESCRIPTION:       This subroutine soundex hashes all names into a persis-
#**                     tent array. The "key" is the soundex value and "value"
#**                     is the position of the name in the name_file
#**
#****************************************************************************/

sub create_soundex_hash {
    
    #grab the parameters
    my($name_file, $hash_file) = @_;
    
    #some temporary variables that we will need
    my($name, $soundex_of_name, @name_array, $iterations);

    #now open the name file
    open(NAMEFILE, "<$name_file")
	|| die "Could not open $name_file\n";
    
    #read all the names into the array
    chop(@name_array = <NAMEFILE>);

    #open the hash file where we will store all our soundex values
    dbmopen(%name_soundex_hash, $hash_file, 0700) 
	|| die "Could not open $hash_file";
	
    
    #for each one of these names create the soundex
    for($iterations=0; $iterations<$#name_array;$iterations++) {

	#get the soundex value of the name
	$soundex_of_name = &main::soundex
	    (join('',split(/ /,$name_array[$iterations])));

	#add  position of  name as a value of  hash with  key  soundex value
	$name_soundex_hash{"$soundex_of_name"} = 
	    $name_soundex_hash{"$soundex_of_name"} . ":" . $iterations;
	
    }
 
    #we are done with our business -- close the dbm file
    dbmclose(%name_soundex_hash);

    #we were obviously successful if we came this far
    return 1;
}

#/****************************************************************************
#**
#**  SUBROUTINE:        get_matching_names
#**
#**  ARGUMENTS:         $first_name, $last_name
#**                     
#**                     
#**                     
#**
#**  RETURN VALUE:	Names that match
#**
#**  DESCRIPTION:       This subroutine takes the first and the last names
#**                     that are being searched for, concatenates them and
#**                     looks up all names having the same soundex value, and
#**                     returns them.
#****************************************************************************/

sub get_matching_names {

    my($first_name, $last_name, $hash_file, $name_file) = @_;
    
    #a bunch of local variables
    my($soundex_of_name, $name_soundex_hash, 
       @line_array, @all_names, $line, @return_array);

    #open the DBM file we created
    tie(%name_soundex_hash, AnyDBM_File, $hash_file, O_RDWR, 0700)
	|| die "Could not open DBM file $hash_file";

    #first soundex the name we were passed
    $soundex_of_name = &main::soundex($first_name . $last_name);
    
    #then index into the hash with the value we got from the above step.
    #get all the line numbers in the name file which have the same soundex
    #hash. Remember we have used : to separate the many values for each key in 
    #the hash
    
    @line_array = split(/:/, $name_soundex_hash{$soundex_of_name});
    
    #open our file of names to report the names that are relevant 
    open (NAMES, "<$name_file")
	|| die "Could not open $name_file";
    
    #slurp in the whole file at once, memory be damned
    @all_names = <NAMES>;
    
    #clean out our return array in preparation for returning
    @return_array = ();
    
    #put all our names into the return array, one by one
    foreach $line (@line_array){
	
	#weed out the spurious line numbers
	if($line ne "") {
	    
	    push(@return_array, ($all_names[$line]));

	}
    }
	
    
    return (@return_array);
}
----------Main.PL-------------------------------
use ApproximateNameMatcher;

#For command-line parsing
use Getopt::Long;

#these are debug options; commented for now
#$Getopt::Long::debug = 1;

#allow for automatic abbreviations
$Getopt::Long::autoabbrev = 1;

#allow for case sensitivity
$Getopt::Long::ignorecase = 0;

#The level of tracing that is needed can be specified here
@options_list = ( 
		 "setup",      # for setting up the program initially
		 "matchName",    # for running in the match names mode
		 "databaseName=s", # for specifying the database name
		 "nameFileName=s", #for specifying the file of names to use
		 "passwdFileName=s" #for specifying the password file name
		 );

#quit if we do not get appropriate command
#line
&GetOptions(@options_list)
    || die "Usage $0 (-setup|-matchName) -databaseName = <file> -nameFileName = <File> -passwdFileName = <File>";

#check for correct arguments here
if(($opt_setup eq "") && ($opt_matchName eq ""))
{
     die "Usage $0 (-setup|-matchName) -databaseName = <file> -nameFileName = <File> -passwdFileName = <File>";
}

if(($opt_databaseName eq "") ||
   ($opt_nameFileName eq "") ||
   ($opt_passwdFileName eq "" ))
{
    print "DatabaseFileName = $opt_databaseName\n";
    print "NameFileName = $opt_nameFileName\n";
    print "PasswdFileName = $opt_passwdFileName\n";
    
    die "Usage $0 (-setup|-matchName) -databaseName = <file> -nameFileName = <File> -passwdFileName = <File>";
   
}   


#if we are in setup mode, then perform setup
if ($opt_setup) {

    #check for the correct arguments to matchName
    #parse the given passwd file
    &ApproximateNameMatcher::parse_passwd_file($opt_passwdFileName, $opt_nameFileName);
    #create the Soundex hash
    &ApproximateNameMatcher::create_soundex_hash($opt_nameFileName, $opt_databaseName);
    
}

#if we are in match name mode then do not perform
#setup but straight away go to matching names
if ($opt_matchName) {
    
    # go into a matching loop
    NAMELOOP: while(1)
    {
	print "Enter first name: ";
	chop($first_name = <STDIN>);
	
	if($first_name eq ".") {
	    last NAMELOOP;
	}

	print "Enter last name: ";
	chop($last_name = <STDIN>);
	
	@name_array = &ApproximateNameMatcher::get_matching_names
	    ( $first_name, $last_name, $opt_databaseName, $opt_nameFileName);

	print "--- Found the following matches for $first_name $last_name ---\n";
	
	foreach $name (@name_array) {
	    
	    print "Name: $name\n";
	    
	}
	
    }

  }

--------Soundex.pl------------------

package soundex;

;# $Id: soundex.pl,v 1.2 1994/03/24 00:30:27 mike Exp $
;#
;# Implementation of soundex algorithm as described by Knuth in volume
;# 3 of The Art of Computer Programming, with ideas stolen from Ian
;# Phillips <ian@pipex.net>.
;#
;# Mike Stok <Mike.Stok@meiko.concord.ma.us>, 2 March 1994.
;#
;# Knuth's test cases are:
;# 
;# Euler, Ellery -> E460
;# Gauss, Ghosh -> G200
;# Hilbert, Heilbronn -> H416
;# Knuth, Kant -> K530
;# Lloyd, Ladd -> L300
;# Lukasiewicz, Lissajous -> L222
;#
;# $Log: soundex.pl,v $
;# Revision 1.2  1994/03/24  00:30:27  mike
;# Subtle bug (any excuse :-) spotted by Rich Pinder <rpinder@hsc.usc.edu>
;# in the way I handles leasing characters which were different but had
;# the same soundex code.  This showed up comparing it with Oracle's
;# soundex output.
;#
;# Revision 1.1  1994/03/02  13:01:30  mike
;# Initial revision
;#
;#
;##############################################################################

;# $soundex'noCode is used to indicate a string doesn't have a soundex
;# code, I like undef other people may want to set it to 'Z000'.

$noCode = undef;

;# main'soundex
;#
;# usage:
;#
;# @codes = &main'soundex (@wordList);
;# $code = &main'soundex ($word);
;#
;# This strenuously avoids $[

sub main'soundex
{
  local (@s, $f, $fc, $_) = @_;

  foreach (@s)
  {
    tr/a-z/A-Z/;
    tr/A-Z//cd;

    if ($_ eq '')
    {
      $_ = $noCode;
    }
    else
    {
      ($f) = /^(.)/;
      tr/AEHIOUWYBFPVCGJKQSXZDTLMNR/00000000111122222222334556/;
      ($fc) = /^(.)/;
      s/^$fc+//;
      tr///cs;
      tr/0//d;
      $_ = $f . $_ . '000';
      s/^(.{4}).*/$1/;
    }
  }

  wantarray ? @s : shift @s;
}

1;
-- 
 /\/\ |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: Thu, 27 Feb 1997 01:41:43 +0300
From: Mike <blazer@mail.nevalink.ru>
Subject: Multipart/mixed MIME from Perl
Message-Id: <3314BC27.634E@mail.nevalink.ru>

I tried to send Multipart/mixed MIME to STDOUT (to browser, in fact) in
order to force first part to be saved to local disk and second
(text/html) to be shown in browser's window.
I just made a letter with attachement and copied MIME statements from it
to my Perl prog. Then I read docs-faqs and corrected smth and at home
(Win 95, FolkWEB server, Netscape 3.0) it works absolutelly fine. But
when I put it to NetBSD server it returns only first part (octet-stream,
or plain/text - in both cases) but no html! The downloading file is text
- so I needed to name it application/octet-stream for not to be
displayed.
 This is a part of code but really I tried a lot of modifications!

print qq~MIME-Version: 1.0\r\n~;
print qq~Content-Type: multipart/mixed;       
boundary="--------50DE7E7F7AC9"\r\n\r\n~;

print "\r\n----------50DE7E7F7AC9\r\n";
    print qq~Content-type: application/text; charset=us-ascii\r\n~;
    print qq~Content-Transfer-Encoding: binary\r\n~;
    print qq~Content-Disposition: attachment;                  
filename=<local-mashine-dos-name>\r\n\r\n~;
<first part to be saved to local disk>
print "\r\n\r\n----------50DE7E7F7AC9\r\n";
print "Content-type: text/html\r\n\r\n";

<html-output>
print "\r\n----------50DE7E7F7AC9--\r\n";

Some in this code is an act of despair: sure I tried \n\n before and
octet-stream befor application-text and no encoding before 'binary'.
  And the next problem is that leading '--' (two dashes) - I have it in
some lines of first part - completely crushes download. Just empty file
on local disk! But when I add some leading symbol, blank 4 ex., to all
lines - works.
  And again - on Win95 server (without any gateways) everything works.
  Please tell me how to workarownd this situation.
  Thanks in advance!

-- 

***************************
Mike Blazer
blazer@mail.nevalink.ru
***************************


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

Date: Wed, 26 Feb 1997 21:49:48 GMT
From: jgd@cix.compulink.co.uk ("John Dallman")
Subject: Perl for Win32: netresource.pm problems
Message-Id: <E68Cn0.5xE@cix.compulink.co.uk>

I have a fairly old build of Perl for Win32 - 106 - and "require"ing 
Win32::NetResource gives lots of warnings, mostly about constructs like 

    local $foo, $bar, $fred, $jim = @_;
    
Those were easy enough to fix (add parentheses), and the first function I 
tried to use (GetUNCName) appeared to work OK, but GetSharedResources was 
doubly 
broken: it initially attempted to compare 

   ref $_[0] == ARRAY

which simply made Perl scream about a string comparison and a numeric eq. 
I fixed that to 

   ref $_[0] eq "ARRAY"

and the warning went away, but Perl throws a runtime error when 
unpack()ing the structures that Windows NT supplies to GetSharedResources 
into Perl scalars.

I've downloaded builds 110 and 303 of Perl for Win32, but neither have 
anything about fixes to NetResource in the readme files, and diffing the 
current version of netresource.pm reveals that most of the warnings 
haven't been fixed - it appears that the developers didn't use the -w 
flag when testing.

Has anyone used this module successfully?


John Dallman, jgd@cix.co.uk. A micro-FAQ on things I keep getting asked: 
#!perl is at ftp://.../CPAN/ports/msdos/tips-tricks/hbp_403.zip, BigPerl 
for MS-DOS can be found in CPAN via http://www.perl.com, Perl for NT/Win 
95 can be found at http://www.activeware.com, with an excellent FAQ file 
at http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html and 
no, I don't have the slightest idea what's wrong with your CGI script.


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

Date: Wed, 26 Feb 1997 15:32:13 -0600
From: sevenup@endirect.qc.ca
Subject: Perl script
Message-Id: <856991852.19210@dejanews.com>

I'd like to make a litlle script that will compare two colums in a line
(check in var/spool/mail for inactive users or closed accounts) it is my
first try at perl and cant seem to make this work...
If that can help i made a little shell script that identify these
colums... cat mailist |while read ligne
          do
              Col1=`echo $ligne |cut -c15-23`
              Col2=`echo $ligne |cut -c56-75`
              echo "$Col1 $Col2 \n"
          done


If possible i'd like to know how to make that in perl and add the rm Col2
if the colums are diffrent .....

thanks

sevenup@endirect.qc.ca

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Wed, 26 Feb 1997 19:25:25 GMT
From: tjordan@ns15.cca.rockwell.com (Terence Jordan)
Subject: Re: Perl Software
Message-Id: <33148dee.1998312@news>

On Fri, 21 Feb 1997 09:33:22 -0500, fl_aggie@hotmail.com (I R A Aggie)
wrote:

><url:http://www.perl.com/perl/>

or

http://www.perl.hip.com/
ActiveWare Perl

I have been using it for months without a hitch.



+--Terence Jordan(x7233)----------------+----------------------------+
|TJordan@NS15.CCA.ROCKWELL.COM          | "When in danger,     <O>   |
|(parenthesis)                          |  Or in doubt,         |    |
|---------------------------------------|  Run in circles,    _/ \   |
|Views expressed are Terence's          |  Scream and shout!"    /   |
+-----and of no other.------------------|----------------------------+


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

Date: 26 Feb 1997 22:30:19 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl Software
Message-Id: <5f2dhr$c77@fridge-nf0.shore.net>

Terence Jordan (tjordan@ns15.cca.rockwell.com) wrote:
: or

: http://www.perl.hip.com/
: ActiveWare Perl

Going to http://www.activeware.com grabs you the new version by default.
This site links back to hip.

--
Nathan V. Patwardhan
nvp@shore.net
"What is the wind speed of a sparrow?"


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

Date: 26 Feb 1997 23:12:03 GMT
From: "Jeff Peck" <peck@csc.smsu.edu>
Subject: perl-system call-security++
Message-Id: <01bc243a$1628b180$8a0e0792@flipbits>

Hi:

I needed to add to the previous message.

Hi:

I webmaster a small college webserver. I am concerned that hackers slipping
"system" calls into cgi scripts on this server.

The server has Linux 2.0.27 using perl version 5.001

Can anyone help me to prevent this.

--Jeff

jmp426s@cnas.smsu.edu


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

Date: 26 Feb 1997 22:57:33 GMT
From: "Jeff Peck" <peck@csc.smsu.edu>
Subject: perl-system call-security
Message-Id: <01bc2438$103e0600$8a0e0792@flipbits>

Hi:

I webmaster a small college webserver. I am concerned that hackers slipping
"system" calls into cgi scripts on this server.

Can anyone help me to prevent this.

--Jeff

jmp426s@cnas.smsu.edu


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

Date: 26 Feb 1997 23:08:38 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: QUESTION about multilpe filehandles
Message-Id: <5f2fpn$sak@neocad.xilinx.com>

admin www(-intern)/proxy/news (WWWAdmin@amc.uva.nl) wrote:
: Does anyone know how to open an INPUT and OUTPUT filehandle/pipe at the
: same time to the same application?

My understanding is that you can't via standard perl functions (ie, see
man perlfunc and read the open section).  However, you may be able to
accomplish your task with the IPC::Open2 module (unless this has been 
superceded by another module that I don't know of).

Cheers,
Jeff

--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: 26 Feb 1997 21:30:26 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Using a variable for mode in chmod and mkdir
Message-Id: <5f2a1i$3la$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Robert A. Goff" <ragoff@sandia.gov> writes:
:I need help using a variable for the mode parameter in chmod and mkdir,
:e.g.
:
:$dirmode = '0777';
:$filemode = '0755';
:mkdir("$FORM{'cwd'}/$FORM{'dirname'}", $dirmode);
:chmod($filemode, "$FORM{'cwd'}/$FORM{'filename'}");
:
:which results in a file/directory with the wrong mode.  Using the
:literal octal numbers gets me the right mode, so I obviously don't know
:how to cast a variable to an octal value.  Any help appreciated,
:including telling me which part of TFM to R.

Get rid of those very silly quotes there that you have
on those would-have-been-octal numbers.  You're defeating
the whole automatic conversion of numeric literals in
differing bases by making them string literals instead.
Of, if you're reading these in as strings, then you'll
have to use the oct() function on them.


--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
I have made this letter longer than usual because I lack the time to
make it shorter.
                --Blaise Pascal


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

Date: 26 Feb 1997 23:15:25 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Windows95
Message-Id: <5f2g6d$sak@neocad.xilinx.com>

ben (wildkat@primenet.com) wrote:
: Having trouble installing Perl for Windows 95.  It tells me I need to
: update my register.  What is the regitsry?  Has to do with command.com I
: believe.  Can anyone tell me where I can get a Windows95 version with
: all the bugs worked out so I won't have to update anything?  Or maybe a
: DOS version of Perl?

there is no perl for DOS...

As far as for Win95 goes, running the install script should make all
the Registry hacks and path changes that it needs...If you don't know
about the Registry, you're better off...a little knowledge can be a
dangerous thing.



--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: 26 Feb 1997 16:05:13 -0500
From: Jim Anderson <jander@ml.com>
Subject: Re: Writting file to server
Message-Id: <wkb67zfs2gm.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

Adrian <apinter@ptd.net> writes:

> I am trying to write a file to my ISP using perl.  I have not previously
> done any work with perl, but I am in the middle of a Java program in
> which I need to write a binary file to a server, by POSTing data to it. 
> I wrote the program below (in spite of the fact that I don't know perl)
> to try and accomplish this, but it did not work correctly.  When I ran
> the program while logged in with the "perl" command, it ran fine.  But
> when I tried actually posting data to it, I got no where.  I set the
> permissions to the necessary values; I even made a directory with
> read/write permission for all, but nothing worked.  The file did not
> write when I called the script from my java program no matter what. 
> Please tell me what you think of this code and what you think my problem
> is.  Thanks in advance.
> 
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> 
> open(STDOUT, ">test/test.txt");
> print("file sucessfully writen");
> print($buffer);
> 
> exit 0;

Try this. If the open fails, the error condition should appear in your
httpd error log.

[...]

my $file = 'test/test.txt';
open OUT, ">$file" or die "open failed for $file: $!\n";
print OUT $buffer;
close OUT  or die "close failed for $file: $!\n";
print "file successfully written";

-- 
Jim Anderson			jander@ml.com
Consultant-at-large		jander@jander.com
				(212) 449-1598


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

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 V8 Issue 20
************************************

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