[8949] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2567 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 12 14:09:55 1998

Date: Tue, 12 May 98 11:00:36 -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           Tue, 12 May 1998     Volume: 8 Number: 2567

Today's topics:
    Re: A regex teaser that ALMOST works! (Greg Bacon)
        associative array of arrays (dwc)
        Catch Blat failure on NT <kliou@ichat.com>
        converting non-printable characters <matthewg@bu.edu>
        Dealer locator with zipcodes <channell@southbay.com>
    Re: Does Perl have a IDE?I don't like command line. (Greg Bacon)
    Re: Does Perl have a IDE?I don't like command line. (Greg Bacon)
    Re: Does Perl have a IDE?I don't like command line. (Michael J Gebis)
    Re: Does Perl have a IDE?I don't like command line. (Michael J Gebis)
    Re: Does Perl have a IDE?I don't like command line. (Ilya Zakharevich)
    Re: Does Perl have a IDE?I don't like command line. (Ilya Zakharevich)
        exiting background perl program (Enrique Terrazas)
    Re: exiting background perl program <jmscott@ainet.com>
        File type sniffer <johnh@partnersweb.com>
    Re: File type sniffer <rootbeer@teleport.com>
    Re: Help!  Launching Perl from C (Ken Fox)
    Re: Help! Perl for Win32 Build 316 socket 'connect' que <ngai@att.com>
        matching outside ASCII range (reg. ex.) (Matthew Rapaport)
    Re: matching outside ASCII range (reg. ex.) (Mike Stok)
    Re: matching outside ASCII range (reg. ex.) <rootbeer@teleport.com>
        Msql-Perl <agro@xures.ei.uvigo.es>
        Passing Filehandle to subroutine. <mr_hellas@hotmail.com>
    Re: Passing Filehandle to subroutine. <rootbeer@teleport.com>
    Re: Passing non-standard characters to scripts. <rootbeer@teleport.com>
    Re: Perl as a compiled executable? <rootbeer@teleport.com>
    Re: Perl for Non-programmers (was Re: Does Perl have a  (Greg Bacon)
    Re: Perl for Non-programmers (was Re: Does Perl have a  <sowmaster@juicepigs.com>
    Re: Program to give day of the week from given date <tkil@scrye.com>
    Re: Recursive find <rootbeer@teleport.com>
    Re: removing last line from file <rootbeer@teleport.com>
        Small Perl quick-reference? (Kevin Reid)
    Re: Small Perl quick-reference? <due@murray.fordham.edu>
        string to hex conversion <I.M.Hay@wg.icl.co.uk>
    Re: string to hex conversion (Mike Stok)
    Re: string to hex conversion <rootbeer@teleport.com>
    Re: win32 - test for binary <rootbeer@teleport.com>
    Re: writing simple XS functions (Ken Fox)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 12 May 1998 15:50:35 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: A regex teaser that ALMOST works!
Message-Id: <6j9r4b$10i$1@info.uah.edu>

In article <1d8wx5l.rq2osj12ks9bqN@slip-32-100-246-98.ny.us.ibm.net>,
	kpreid@ibm.net (Kevin Reid) writes:
: My pointer code does that!

 ...but it loses in speed efficiency.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Tue, 12 May 1998 17:41:19 GMT
From: dwc@davewc.mv.com (dwc)
Subject: associative array of arrays
Message-Id: <355d875b.355924081@news.ultranet.com>


I am using this example from the PerlFAQ (5.2) and I don't understand how to
reference an array.  I would like to reference the whole array (alphabet) at
$T{key2}->{k3}.  For the sake of this example, I would like to print out all the
elements in this array.


%T = ( key0, { k0, v0, k1, v1 }, key1, { k2, v2, k3, v3 }, key2, { k2, v2, k3,
['a' .. 'z'] } );

# Trying to pull out a copy of the array.
@myarr = $T{key2}->{k3};

# I don't understand this, but the output is correct
print "myarr[0][0] = [$myarr[0][0]]\n";
print "myarr[0][1] = [$myarr[0][1]]\n";

# This is what i'd like to do, but I only get 1 item,
# the actual array:  ARRAY(0x83cb10)
foreach $itm ( @myarr )
{
  print "itm = [$itm]\n";
}

Thanks.
-dwc
dwc@davewc.mv.com



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

Date: Tue, 12 May 1998 11:16:44 -0500
From: "kll" <kliou@ichat.com>
Subject: Catch Blat failure on NT
Message-Id: <6j9o1e$9bv$1@nntp.smartdna.com>

I am very new in Perl/CGI and working on some old code prepared by others.
The code uses Blat to send email.  What we observed on NT4.0 is that once in
a while the email sending would fail (Why? left a code 16 in Windows event
log).  I am trying to enhance the code to resend the email if its sending
did not go through.  The question is how to catch the failure?  I was
thinking about using Fork to start a monitoring process, but it's not
supported on NT.  If there are sample code on some web sites, please give me
some guidances.
If you know the possible reasons why Blat fails once in a while on NT,
please let me know.
Thank you very much.

Kan




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

Date: Tue, 12 May 1998 13:50:47 -0400
From: Matthew Glogowski <matthewg@bu.edu>
Subject: converting non-printable characters
Message-Id: <35588BF6.334B7767@bu.edu>

hi,

i've got a quick question.  this is related more to MacPerl.  i'm
converting files and folders in an NT appleshare volume to be DOS/Win/NT
compatible, stripping out and replacing characters like / and \ in the
file and folder names.

but i can't seem to get rid of some of the option key and {letter}
combinations that the macintosh creates, like the folder character
(option key + f). i also seem to have a lot of hidden characters that
people have put into files accidentally.


how do i tell perl to get rid of the non-printable characters--the ones
other than the 7-bit ascii chars that are compatible between OS's?


i've used $newfile =~ s/$original/$replacement/g;  to replace characters
that i specify, but 
this will only work for the ones i supply.  tr also does not seem to do
it.  i've tried $newfile =~ tr/[\W]/$replacement/; but it doesn't work.


thanks in advance,

-matt

-----------------------------------------------------------------------------
Matthew Glogowski                      Email:  matthewg@bu.edu
Systems Analyst/Consultant II            Web: 
http://web.bu.edu/DCG/matthewg
Distributed Consulting Group          Direct:  617-353-8231
Office of Information Technology        Main:  617-353-2780
Boston University               	 Fax:  617-353-6260
                                       Snail:  111 Cummington Street
                                               Boston MA 02215
-----------------------------------------------------------------------------


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

Date: Tue, 12 May 1998 09:27:22 -0700
From: "Brian Channell" <channell@southbay.com>
Subject: Dealer locator with zipcodes
Message-Id: <35587796.0@inout.beachnet.com>

Has anyone created a Perl script that can parse a Zipcode to find a dealer
in a directory (flatfile format). My client wants to have this function in
their website so that potential customers can enter in their Zipcode to find
the nearest dealer. Any pointers or directions would be helpful thanks.

Brian


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

Date: 12 May 1998 16:32:36 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6j9tj4$10i$3@info.uah.edu>

In article <ltemy048jl.fsf@asfast.com>,
	Lloyd Zusman <ljz@asfast.com> writes:
: (1) I think that Perl is a wonderful language and it pleases me
:     to see lots of people using it.

Popularity and quality are independent.  Witness Java.  Witness
Microsoft.

: (2) I love helping people when I have time.

So do I, but I resent people trying to take advantage of the generosity
of others.

: (3) I have given this kind of technical help to people for over
:     20 years and I have never had even one of these people become
:     dependent on my help or to develop some sort of "the world
:     owes me a living" attitude.  On the contrary, to the best of
:     my knowledge, 100 percent of the people who have received 
:     help from me would have been ashamed to have to be dependent
:     on others for learning and are proud of what they have been
:     able to learn on their own.

I'm railing against the people who already have the ``handouts,
please?'' attitude.

: As for why I am not categorically opposed to a Perl IDE:
: 
: (1) I truly believe that most people who would want to use an
:     IDE would not use it instead of man, perldoc, or grep, but
:     rather, in conjunction with these tools.

Why?  We're not trapped on DOS machines these days.  Keep two xterms
open; one for hacking, one for man and grep.

: (2) Even though I personally do not generally use IDE's, I know
:     a lot of people who are more productive using such things
:     to help develop code.

It's all a matter of what you're used to.  Perl was fathered by a Unix
hacker, after all.  Had Larry been a Microsoft weenie, Perl would
probably be full of wizards and menus and general protection faults.

: (3) It is quite possible for a person to use an IDE and still learn
:     the language in question to the same level of proficience and
:     compentency as those people who shun IDE's.

Crutches are best used only in the case of injury.  I don't know of
anyone who advocates learning to walk using crutches.

: > Perl would cease to be the language we know and love if we watered it
: > down to meet the needs of the least common denominator.  An army of Ken
: > Thompsons couldn't fully idiot-proof even the simplest program.
: 
: The language need not change one iota simply due to someone's choice
: of writing an IDE.  IDE's did not water down C++.  IDE's did not water
: down Smalltalk.  IDE's did not water down APL.  IDE's did not water
: down Java.

I'd rather the tuits of the capable few be spent on improving the
language itself and not in creating crutches to attract even more FAQ
askers.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 12 May 1998 16:38:52 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6j9tus$10i$4@info.uah.edu>

In article <1d8vlqy.e1xil01v1oakcN@slip-32-100-246-98.ny.us.ibm.net>,
	kpreid@ibm.net (Kevin Reid) writes:
: However, it would be nice if either:
: 1. The Jump To... item, when no text is selected, would bring up a
: dialog box asking for a line number to jump to, OR
: 2. The editor window optionally showed line numbers.

Hmm.. vi solves both problems:

    1. ESC:<line>
       or
       ESC<line>g
       or
       /regex

    2. ESC:set number

: Also, it woulld be nice if there was some way of adding to the items
: that Cmd-H recognizes so that, say, if I wrote a module I can set it up
: so that if I select the module's name and press Cmd-H, the module's POD
: comes up in Shuck, like it does for the standard modules.

Command line rich environments allow things like

    % xterm -e vi mod.pm

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 12 May 1998 17:05:55 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6j9vhj$8v@mozo.cc.purdue.edu>

gbacon@cs.uah.edu (Greg Bacon) writes:

}In article <6j7u8v$e29@mozo.cc.purdue.edu>,
}	gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
}: 1) To save yourself the inevitable frustration of having to read 
}:    the same questions again and again from folks who don't "get"
}:    perldoc, man, or grep.

}By ``get'', I'm assuming you mean software is unavailable. 

Nope, I wouldn't have put it in quotes if I had meant that.  I mean
that that some people just don't think "I need help, thus I
should go the the command line, or a separate program, or whatever."  

Look, I'm not trying to deny that the existing documentation is
excellent, because quite frankly, it is.  I can't understand why you
fail to see value in spreading that documentation in a way that many
newbies expect.  (I have to be careful here--we shouldn't "dumb down
the language" in any respect, but when a new perl programmer runs into
a problem, he's already frustrated.  If he's got to deal with a help
system on the command line (which he's not used to) and search with
strange tools, he becomes more frustrated.)

I feel I shouyld once again state that the efforts of the perl
documentation authors are not in question here.  I just think that
categorically denying the value of an IDE is short-sighted.

}: One lesson I've taken away from Donald Norman (_The Design of Everyday
}: Things_) is that if you've got to keep telling people something over
}: and over again ("Push to Open") you're doing something wrong.

}Programming languages aren't and should never be everyday things.

That's a very witty but content-free response.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: 12 May 1998 17:11:51 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6j9vsn$f7@mozo.cc.purdue.edu>

fl_aggie@thepentagon.com (I R A Aggie) writes:

}No, we aren't. We're _requiring_ people to get smart. 

It's been a smashing success so far.

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: 12 May 1998 17:28:57 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6ja0sp$41b$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Greg Bacon
<gbacon@cs.uah.edu>],
who wrote in article <6j9jue$p90$6@info.uah.edu>:
> By ``get'', I'm assuming you mean software is unavailable.  For one
> thing, perldoc comes with every standard Perl distribution.  Any
> installation without perldoc is a broken installation.  All ports have
> the capability to generate HTML versions of the docs.  It's the
> responsibility of whoever installs perl to make sure that the docs are
> available.
> 
> Other platforms have different help systems.  For example, Ilya actively
> maintains OS/2 book versions of the Perl docs.  This is not a case of
> bad design; it's a case of being unable to compel the equine to imbibe.

Sorry if my idioms are off the line, but let me clarify things:

OS/2 distribution comes with

     a1) library of scripts including perldoc and 
     a2)					  a complete set of PODs;
     b)  Complete set of manpages;
     c)	 ALL the available Perl documentation wrapped as OS/2 online book;

(I do not supply precompiled HTML - since I consider HTML almost as
broken as manpages), but pod2html is there.  (Note that all the 4
components above are optional, you do not download them if you do not
want to.)

I support "OS/2 online book" format since it is the best format for
docs I have used in my life (comparing to - in a particular order -
GNUinfo, PDF, CDEbooks, HTML, man, latex).  You do not need grepping
for docs - search is builtin (with an amazing speed due to compression
algorithm - you search through 100M docs from a 6x CDROM in a minute),
you have reformating-to-the-current-size, heirarchical
table-of-contents, great index, and fantastic command-line interface:
typing 

       view perl mirror

brings GUI (which may be already running, or is started) you exactly
to the page you wanted (and if you still "want more", you may search
for "mirror*" - RE expression are primitive, but most the time are
adequate).

Ilya


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

Date: 12 May 1998 17:42:08 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6ja1lg$5ab$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Christiansen 
<tchrist@mox.perl.com>],
who wrote in article <6j9kbt$q6e$1@csnews.cs.colorado.edu>:
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, 
>     ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> :Negative.  Perl requires these abominations only on systems which do
> :not have a clue what a good documentation is.  Witness Perl-OS/2's
> :distribution.
> 
> Ilya, just because you have no clue how to grep the mantree
> doesn't mean others are also that stooopid.

Is somebody twisting your hands to force you make fool of yourself?
Next time you will recommend me use pfind to read DOCs...

Yes, when I'm on Solaris, I'm forced to use some broken way like
pfind'ing (grep is absolutely useless unless you know how deep you
need to search) if I need to lookup DOCs.

When on home machine, I have the online book, which will do all the
trivial tasks like searching much better (and *hundreds* times
quickier).

Ilya


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

Date: Tue, 12 May 1998 10:15:46 -0700
From: terrazas@labmed.ucsf.edu (Enrique Terrazas)
Subject: exiting background perl program
Message-Id: <terrazas-1205981015480001@asgard.ucsf.edu>

Hello,

I have a perl program to listen to socket that runs pretty much
continuously.  This is on a unix machine running Solaris 2.6.  To exit the
program, I issue the "kill" command, but this is not ideal since the
program doesn't get a chance to do some clean up, like close the socket
connection and close any open filehandles.  I run the program in
background mode.  Does anyone have any suggestions on how to get a
background unix perl program to exit gracefully?

the shell of the program is as follows:

##################
use IO::Socket;

$sock = new IO::Socket::INET (LocalHost => 'host',
                                   LocalPort => port#,
                                   Listen    => SOMAXCONN,
                                   Proto     => 'tcp',
                                   Reuse     => 1,
                                  );
unless ($sock) {
   die ("Socket could not be created. Reason: $!\n");
}

while ($new_sock = $sock->accept()) {
   $new_sock->autoflush(1);

   ###process incoming connections

}
close ($sock);
##################

TIA.


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

Date: Tue, 12 May 1998 10:35:30 -0700
From: "Joseph M. Scott" <jmscott@ainet.com>
To: Enrique Terrazas <terrazas@labmed.ucsf.edu>
Subject: Re: exiting background perl program
Message-Id: <35588862.4CEF@ainet.com>

You should be able to buy the time you need to clean up by catching the
signal that's being sent to the program.  From page 139 in Programming
Perl, 2nd ed. it looks like signal handling would look something like :

$SIG{'INT'} = \&shutdown;

sub shutdown {
	print("$0: Exiting . . . ");
	close(SOME_FILE_HANDLE);
	print("done\n");
	exit(1);
}

	I can't really claim great knowledge in regards to how perl and signals
work, but I do have something similar to this working in a couple of
scripts with perl5.00404 on a FreeBSD 2.2.5 machine.

Joseph Scott
jmscott@ainet.com

Enrique Terrazas wrote:
> 
> Hello,
> 
> I have a perl program to listen to socket that runs pretty much
> continuously.  This is on a unix machine running Solaris 2.6.  To exit the
> program, I issue the "kill" command, but this is not ideal since the
> program doesn't get a chance to do some clean up, like close the socket
> connection and close any open filehandles.  I run the program in
> background mode.  Does anyone have any suggestions on how to get a
> background unix perl program to exit gracefully?
> 
> the shell of the program is as follows:
> 
> ##################
> use IO::Socket;
> 
> $sock = new IO::Socket::INET (LocalHost => 'host',
>                                    LocalPort => port#,
>                                    Listen    => SOMAXCONN,
>                                    Proto     => 'tcp',
>                                    Reuse     => 1,
>                                   );
> unless ($sock) {
>    die ("Socket could not be created. Reason: $!\n");
> }
> 
> while ($new_sock = $sock->accept()) {
>    $new_sock->autoflush(1);
> 
>    ###process incoming connections
> 
> }
> close ($sock);
> ##################
> 
> TIA.


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

Date: Tue, 12 May 1998 11:56:26 -0400
From: John Henson <johnh@partnersweb.com>
Subject: File type sniffer
Message-Id: <35587129.A9E9F8E6@partnersweb.com>

Howdy,

Anyone know of a utility to determine file types..i.e. image files,
Quark Xpress files from the headers? 

Thanks in advance.

John Henson
j:wq


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

Date: Tue, 12 May 1998 17:16:17 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: John Henson <johnh@partnersweb.com>
Subject: Re: File type sniffer
Message-Id: <Pine.GSO.3.96.980512101503.21974B-100000@user2.teleport.com>

On Tue, 12 May 1998, John Henson wrote:

> Anyone know of a utility to determine file types..i.e. image files,
> Quark Xpress files from the headers? 

Yes, it's the 'file' command, available on many Unix-type systems. If you
need help with it, people in a newsgroup about Unix systems may be able to
help you. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 12 May 1998 17:51:38 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Help!  Launching Perl from C
Message-Id: <6ja27a$rb66@eccws1.dearborn.ford.com>

"John Zenyuh" <jzenyuh@mindspring.com> writes:
> I can launch the Perl script as long as I start the 'C' process
> via command line with the Perl script filename included.

This has the advantage of looser coupling between the Perl script,
the perl interpreter and your C process.  It has the disadvantage
that it can be slower if you have to run the Perl script many times.

> I can't write a straight "int main(void)" because proto.h has
> prototyped main() to be "int main(int argc, char ** argv,
> char **env)".

Don't write a main(void) then?  It is annoying that perl uses a
prototyped main(), but it usually only causes a compile warning.
I write main(int argc, char *argv[]) and it works fine even though
I do get the warning.  Make sure *you* don't prototype main().

> Even if I get around this problem, perl_parse() is expecting
> a char **.  Is there a way to identify the script::module via
> perl_call_pv()?

Since you have to perl_parse() before you can perl_call_pv() it
won't help you.  You can always fabricate a fake char ** to
pass to perl_parse() -- in fact, you *should* fabricate a fake
arg list unless you really want your users to pass additional
arguments to the embedded perl interpreter.

Here's something that should get you going in the right direction:

    #define PERL_CODE "package Foo; sub your_code_here { } ... ; package main;"
    static char *argv[] = { "embedded_perl", "-e", PERL_CODE, 0 };
    PerlInterpreter *perl;
    ...
    perl_parse(perl, xs_init, 3, argv, 0);

- Ken

-- 
Ken Fox (kfox@ford.com)                  | My opinions or statements do
                                         | not represent those of, nor are
Ford Motor Company, Powertrain           | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section             | "Is this some sort of trick
                                         |  question or what?" -- Calvin


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

Date: 12 May 1998 15:59:15 GMT
From: "A Ngai" <ngai@att.com>
Subject: Re: Help! Perl for Win32 Build 316 socket 'connect' question
Message-Id: <6j9rkj$r7q@bgtnsc01.worldnet.att.net>

Thanks for the response!  You're right, I don't want to deal with the
low-level sockets if I can avoid it.  Do you know where I can get the LWP
package and any of its documentation?  I thought I hunt around the CPAN
pages for Win32 but I didn't see a reference to it... at least it wasn't
obvious to me.

Thanks again!


Martien Verbruggen <mgjv@comdyn.com.au> wrote in article
<6j82av$rv0$1@comdyn.comdyn.com.au>...
> In article <01bd7ca7$02a6a420$b5c02e87@outpost2.ciin.att.com>,
> 	"Andy" <ngai@att.com> writes:
> > Hi,
> > 	I've tried the following piece of code to connect an NT 4.0 client
running
> > Perl for Win32 Build 316 to an NT-based web server and it fails to
> > establish a connection to the server.  I've tried the same code on
HP-UX
> > running Perl 5.003 and it works fine.  I've isolated the problem to the
> > 'connect' call and would like to know if anyone had come across a
similar
> > problem with the 'connect' function and have a solution to this
problem. 
> > Did I overlook something or failed to install a required module?
> 
> You probably need to have a look at the Socket module, which is a bit
> more reliable way of using sockets (comes with perl). The code you
> provided won't work on my platform (Solaris 2.6) (fails on socket).
> You should also use the -w flag with perl, to get a few more warnings.
> 
> There is an example in the perlipc documentation that works well.
> 
> # perldoc perlipc
> # perldoc Socket
> 
> If all you need to do is connect to a web server, and retrieve some
> pages, you might be better off using the LWP package, and not worry
> about the low level socket operations. Of course, if you like playing
> with sockets, I'd advise you to read the above mentioned
> documentation.
> 
> Martien
> -- 
> Martien Verbruggen                  | 
> Webmaster www.tradingpost.com.au    | Inside every anarchy lurks an old
boy
> Commercial Dynamics Pty. Ltd.       | network - Mitchell Kapor
> NSW, Australia                      | 
> 


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

Date: 12 May 1998 09:50:08 -0700
From: mjr@crl.crl.com (Matthew Rapaport)
Subject: matching outside ASCII range (reg. ex.)
Message-Id: <6j9uk0$t8d@crl.crl.com>

Hello...

My intuition tells me this should be simple, but it doesn't appear to be.
I'm scanning file lines for characters outside the ascii range 32 (space)
to 126. That's chr(32) to chr(126). I want to find any characters in a
line OUTSIDE that range, that is BELOW chr(32) or above chr(126).

I thought the pattern match $x =~ /[^chr(32)-chr(126)]/ would do it for
me, but it does not. Is there anything anyone can suggest besides trying to
list EVERYTHING in the range that isn't accounted for by some special
symbol like \s\w\n, etc.?

Help appreciated. Email, or post here

Thank you.

-- 
  matthew rapaport   The difference between theory and practice    KD6KVH
                     is that in theory there is no difference,   
  mjr@crl.com        but in practice, there is.             quine@dfw.net


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

Date: 12 May 1998 17:06:00 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: matching outside ASCII range (reg. ex.)
Message-Id: <6j9vho$fvd@news-central.tiac.net>

In article <6j9uk0$t8d@crl.crl.com>, Matthew Rapaport <mjr@crl.crl.com> wrote:
>Hello...
>
>My intuition tells me this should be simple, but it doesn't appear to be.
>I'm scanning file lines for characters outside the ascii range 32 (space)
>to 126. That's chr(32) to chr(126). I want to find any characters in a
>line OUTSIDE that range, that is BELOW chr(32) or above chr(126).
>
>I thought the pattern match $x =~ /[^chr(32)-chr(126)]/ would do it for
>me, but it does not. Is there anything anyone can suggest besides trying to
>list EVERYTHING in the range that isn't accounted for by some special
>symbol like \s\w\n, etc.?

You could match against [^ -~] or if you prefer [^\020-\376] (assuming
you're using ASCII and you've thought about "\t")

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: Tue, 12 May 1998 17:22:31 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Matthew Rapaport <mjr@crl.crl.com>
Subject: Re: matching outside ASCII range (reg. ex.)
Message-Id: <Pine.GSO.3.96.980512101738.21974D-100000@user2.teleport.com>

On 12 May 1998, Matthew Rapaport wrote:

> I'm scanning file lines for characters outside the ascii range 32 (space)
> to 126. That's chr(32) to chr(126). I want to find any characters in a
> line OUTSIDE that range, that is BELOW chr(32) or above chr(126).

If you merely wish to know whether there are any, tr/// should be able to
tell you. But if you want to locate them, you may need a pattern match.

> I thought the pattern match $x =~ /[^chr(32)-chr(126)]/ would do it for
> me, but it does not. 

Nooooo! You can't put a function call within a character class! :-)  Just
use the characters themselves (possibly by means of backslash escapes).

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 May 1998 19:15:34 +0200
From: Josi <agro@xures.ei.uvigo.es>
Subject: Msql-Perl
Message-Id: <355883B6.47BB@xures.ei.uvigo.es>

My question is :

	Once that I have established a conexion to a msql database from a perl
scritp with the command
	$dbh=Msql->connect($hostname,$databasename);
is there any command to close the conexion??????
Thanks for your help


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

Date: Tue, 12 May 1998 08:57:37 -0700
From: "Mr. Hellas" <mr_hellas@hotmail.com>
Subject: Passing Filehandle to subroutine.
Message-Id: <35587171.8C89915A@hotmail.com>

Okay.  Im new to perl so bear with me.

I need to pass a filehandle to a subroutine so I can output a form
header for a report, plus I need to return the filehandle so that I
don't lose track of my write position.  I thought something like this
would have worked.

	&foo(\*FILEHNDL);

	sub foo
	{
		my $fh = shift
		.
		.
		print fh "TEXT in HERE\n"
		.
		.
		return scalar <$fh>;
	}

Any help will be greatly appreciated.

Mr. H.

-- 
|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|
|-| Mr. Hellas                        "I don't make problems. |-|
|-| mr_hellas@hotmail.com                    I just fix them."|-|
|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|


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

Date: Tue, 12 May 1998 17:14:43 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: "Mr. Hellas" <mr_hellas@hotmail.com>
Subject: Re: Passing Filehandle to subroutine.
Message-Id: <Pine.GSO.3.96.980512101405.21974A-100000@user2.teleport.com>

On Tue, 12 May 1998, Mr. Hellas wrote:

> 		my $fh = shift
> 		.
> 		.
> 		print fh "TEXT in HERE\n"

Assuming I'm correctly reading your pseudo-code, you want $fh, not fh in
there. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 May 1998 16:00:26 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Luke Steele <ljs@cableinet.co.uk>
Subject: Re: Passing non-standard characters to scripts.
Message-Id: <Pine.GSO.3.96.980512085618.21974v-100000@user2.teleport.com>

On Tue, 12 May 1998, Luke Steele wrote:

> Now, I think I know how to convert spaces to %20's myself, but if I
> write code to cater for all possible characters I'm bound to mess it
> up, 

Right, so you want to use a module which should do that for you. I think
you want URI::Escape. I believe that it's part of the LWP package, but in
any case, you'll find it on CPAN. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 May 1998 15:55:36 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Robert Young <robyoung@mediaone.net>
Subject: Re: Perl as a compiled executable?
Message-Id: <Pine.GSO.3.96.980512085505.21974u-100000@user2.teleport.com>

On Tue, 12 May 1998, Robert Young wrote:

> passme
> approve

I don't think you're approved. :-)

> I want to hide a portion of my distributed script.  

Seen the FAQ? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 12 May 1998 16:24:07 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: Perl for Non-programmers (was Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6j9t37$10i$2@info.uah.edu>

In article <6j9r0p$8ni$1@pace1.cts.mtu.edu>,
	mwmaurer@mtu.edu (Mark Maurer) writes:
: I think it could be wise to throw Perl in with C as a language NOT to teach
: to an aspiring programmer first...

You could probably get away with it grandly (many universities use C and
even *shudder* Java as teaching languages), provided that you're willing
to lie to your students initially and then uncover your lies where
appropriate.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Tue, 12 May 1998 12:19:41 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
Subject: Re: Perl for Non-programmers (was Re: Does Perl have a IDE?I don't like command line.
Message-Id: <3558769D.1D50@juicepigs.com>

Mark Maurer wrote:

> I think it could be wise to throw Perl in with C as a language NOT to teach
> to an aspiring programmer first...

I learned how to program in COBOL and Assembler. I wish perl was around
back then.

I honestly think that anyone with a head on their shoulders could easily
learn perl by reading "Learning Perl" from cover to cover a couple of
times.

The problem is that people are in too much of a hurry or too lazy these
days to sit down and learn on their own. And then there are those that
shouldn't be programming and get frustrated too easily.

-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


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

Date: 12 May 1998 10:06:15 -0600
From: Tkil <tkil@scrye.com>
Subject: Re: Program to give day of the week from given date
Message-Id: <gwwbrjwy0.fsf@scrye.com>

>>>>> "Hari" == Hari Patel <hari.patel@bt.com> writes:

Hari> Does anybody know how to output day of teh week for a given date in
Hari> perl

   http://www.hemi.com/~tkil/Weekday.pm

not a proper module (underdocumented, among other problems) but should 
do the trick.  a sample scriptthat uses this module is

   http://www.hemi.com/~tkil/wd.pl

if you need something more powerful, look at the Date:: modules on
CPAN.

t.
-- 
Tkil * <URL: http://www.scrye.com/~tkil> * hopelessly hopeless romantic.
  "So amplify this little one 	|   She hears as much as she can see
   She's a volume freak       	|   And what she sees, she can't believe."
        -- Catherine Wheel, _Happy Days_, "Judy Staring At The Sun"


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

Date: Tue, 12 May 1998 16:01:52 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Johannes Rest <rest@Extlap.bi.sdm.de>
Subject: Re: Recursive find
Message-Id: <Pine.GSO.3.96.980512090034.21974w-100000@user2.teleport.com>

On 12 May 1998, Johannes Rest wrote:

> I'm quite new to perl, and for a start I would like
> to program a recursive find in perl, 

If you're doing this for real, you should use the File::Find module. If
you're trying to learn, start with "hello world" and debug it until it
does what you want. :-)  Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 May 1998 16:05:06 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Baton <baton@vision.net.au>
Subject: Re: removing last line from file
Message-Id: <Pine.GSO.3.96.980512090326.21974x-100000@user2.teleport.com>

On 12 May 1998, Baton wrote:

> how would i go about removing the last line of a text file?

You may be able to do this with truncate, possibly in conjunction with
tell.

> also i need a way of displaying that line before it gets deleted

That sounds like print. 

If you're not sure how to use these functions after you've read their
docs, please ask about them here. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 May 1998 13:14:35 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Small Perl quick-reference?
Message-Id: <1d8x34q.7tbnvcp7mjysN@slip166-72-108-231.ny.us.ibm.net>

"Programming Perl" is a great book - with one problem: it is large and
heavy.

Does anybody know of a small (paperback-novel size) "quick reference"
book?

I want something that reminds me of the arguments to read() and lists
the s/// modifiers, and doesn't bother explaining what the different
contexts are (except briefly).

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 12 May 1998 17:46:28 GMT
From: "Allan M. Due" <due@murray.fordham.edu>
Subject: Re: Small Perl quick-reference?
Message-Id: <6ja1tk$eqb$0@206.165.146.138>

    Kevin Reid wrote in message
<1d8x34q.7tbnvcp7mjysN@slip166-72-108-231.ny.us.ibm.net>...

 [snip]
    I like "Perl 5 Desktop Reference" by Johan Vromans, OReilly and
Associates (list:$6.95).  Or not quite as good, slightly more detail, and
way too expensive:  "Perl 5 Quick Reference" by Micheal O Foghlu, Que
Corporation (list $19.95).  Just a couple.

Allan M. Due
Due@discovernet.net
Admin@WhiteCrow.net

The beginning of wisdom is the definitions of terms.
- Socrates

Still working on getting a less lame newsreader.




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

Date: Tue, 12 May 1998 18:02:23 +0100
From: "I.M.Hay" <I.M.Hay@wg.icl.co.uk>
Subject: string to hex conversion
Message-Id: <3558809F.52EA5975@wg.icl.co.uk>

I need to encode a string to pass it to a function as quoting it won't
work - off-hand we thought hex would do -  ie I'd pass a string of many
hex numbers instead of characters - anyone got a string-to-hex
conversion routine or a better idea of how to encode it?!
Thanks!
Is.



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

Date: 12 May 1998 17:18:22 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: string to hex conversion
Message-Id: <6ja08u$fvd@news-central.tiac.net>

In article <3558809F.52EA5975@wg.icl.co.uk>,
I.M.Hay <I.M.Hay@wg.icl.co.uk> wrote:
>I need to encode a string to pass it to a function as quoting it won't
>work - off-hand we thought hex would do -  ie I'd pass a string of many
>hex numbers instead of characters - anyone got a string-to-hex
>conversion routine or a better idea of how to encode it?!

Have you looked at pack & unpack?  In the debugger:

  DB<7> print unpack 'H*', "Larks' Tongues In Aspic"
4c61726b732720546f6e6775657320496e204173706963
  DB<8> print pack 'H*', '4c61726b732720546f6e6775657320496e204173706963'
Larks' Tongues In Aspic

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: Tue, 12 May 1998 17:31:41 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: "I.M.Hay" <I.M.Hay@wg.icl.co.uk>
Subject: Re: string to hex conversion
Message-Id: <Pine.GSO.3.96.980512102243.21974E-100000@user2.teleport.com>

On Tue, 12 May 1998, I.M.Hay wrote:

> anyone got a string-to-hex conversion routine

I think you can do what you want with either (s)printf or unpack. Hope
this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 12 May 1998 17:04:51 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Liza Linderman <lindermn@is4.nyu.edu>
Subject: Re: win32 - test for binary
Message-Id: <Pine.GSO.3.96.980512100348.21974y-100000@user2.teleport.com>

On Tue, 12 May 1998, Liza Linderman wrote:

> Is there a way to test a file for being a bin mode file prior to working
> with it? 

If you're just copying a file, or something similar, you should simply use
binmode. (If, of course, you're not using a module... :-)  But you may
want the -B filetest. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 12 May 1998 17:27:17 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: writing simple XS functions
Message-Id: <6ja0pl$rb65@eccws1.dearborn.ford.com>

ken@forum.swarthmore.edu (Ken Williams) writes:
> I'm trying to get my feet wet learning XS by translating a few functions
> in a module to XS.  ...
> 
> Here's a simple perl function:
> 
>  sub output_text {
>     # Usage: &TacoXS::Template::output_text( $text, $buffer );
>     $_[1] .= &interpret($_[0]);
>  }

This isn't a good candidate to convert to XS.  It will probably run
faster as a perl subroutine instead of an XS subroutine, and it is
much easier to write and maintain in Perl instead of C.

When looking to convert subs to XS, try to find things that C is
good at -- or at least things that can improve performance.  (You'll
almost never be able to improve correctness or maintainability in C.)

> Also, could I use perl_call_argv instead?  That seemed simpler, since
> I'm passing a string to &interpret.  Couldn't get it to work, though.

That should work fine.  It's a bit slow though -- much slower than
just using Perl.  There are good examples of how to use the perl_call_*
functions given in the perlcall man page.

> package TacoXS::Template;
> my $DEPTH = 0;
>
> ...
> 
> Can I access the $DEPTH variable in XS code?  I haven't been able
> to so far.

You can use perl_get_sv() to lookup a package variable, i.e. one
created with "use vars".  That routine doesn't work on lexical
variables though.  If you want to share access to a package variable
between Perl code and XS code, you'll either have to:

 (1) declare the package variable with "use vars" and remove
     the "my" declaration:

     Perl code:

        package Foo;
        use vars qw($global);

     XS code:

        SV *global = perl_get_sv("Foo::global", FALSE);

or

 (2) register the variable (either lexical or dynamic) with
     an XS routine that saves the variable for future use.

     Perl code:

        package Foo;
        my $global;
        register_global(\$global);

     XS code:

        SV *global = 0;

        MODULE = Foo   PACKAGE = Foo

        void
        register_global(var)
             SV *        var
             CODE:
                global = SvRV(var);

I'd suggest the first approach to begin with and then grow into
the second.  The second approach can be faster and more flexible,
but you'll have to understand perl internals more thoroughly.

- Ken

-- 
Ken Fox (kfox@ford.com)                  | My opinions or statements do
                                         | not represent those of, nor are
Ford Motor Company, Powertrain           | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section             | "Is this some sort of trick
                                         |  question or what?" -- Calvin


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 2567
**************************************

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