[6311] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 933 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 12 10:17:23 1997

Date: Wed, 12 Feb 97 07:00:39 -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, 12 Feb 1997     Volume: 7 Number: 933

Today's topics:
     Re: "-i" switch is unsafe! (Jason C Austin)
     Re: ANNOUNCEMENT: Perl documentation and FAQ discontinu (I R A Aggie)
     Re: Avoiding *massive number of pattern matches <jander@jander.com>
     Re: CGI Script <nmljn@wombat.staff.ichange.com>
     Re: Code refs not first class? <jander@jander.com>
     Re: Code refs not first class? <nmljn@wombat.staff.ichange.com>
     Re: DNS Lite? (Doug Wegscheid)
     Re: FORK :( (Scott McMahan - Softbase Systems)
     Re: getprpwent Perl library? <jander@jander.com>
     grep in `command|grep pattern` seems not to work ???? <rfi@uebemc.siemens.de>
     Re: grep in `command|grep pattern` seems not to work ?? (Mike Stok)
     Re: Help for a perl program (small and simple) <jander@jander.com>
     Help: Ioctl for serial I/O <hapkejs@cig.mot.com>
     Re: HELP: Pattern Matching Problem (Mike Stok)
     Re: How to Determine operating system type? <tchrist@mox.perl.com>
     How to make perl work with forms <hotraja1@pilot.msu.edu>
     Re: How to tell if Perl is run in debug mode <jander@jander.com>
     How To <hotraja1@pilot.msu.edu>
     Locking mechanism (Bob Coret)
     Re: optimization of binary data operations. <jander@jander.com>
     Re: Pasting between apps question <jander@jander.com>
     Re: Pattern matching and regular expression (Tad McClellan)
     Re: Perl and Crontabs (I R A Aggie)
     perl in varied environment (Terry Gorby)
     Perl module manual pages causing problem with man -k <d.white@surrey.ac.uk>
     perl ulimit -c 0 ? <steveg@metrosol.demon.co.uk>
     Pointer to 4-arg select examples? (Peter Bierman)
     Re: Pointer to 4-arg select examples? (Mike Heins)
     read and write +> at the same time - HOW? <lnussat.mavila@eds.com>
     Re: read and write +> at the same time - HOW? (Tad McClellan)
     Re: read and write +> at the same time - HOW? <jander@jander.com>
     Re: read and write +> at the same time - HOW? <tchrist@mox.perl.com>
     Re: regexp help <jander@jander.com>
     Re: Regexp question... <jander@jander.com>
     Re: sgmlstripper not stripping (or how to turn html to  (Len Wilson)
     Re: Sourcing files from my perl script <jander@jander.com>
     undump? <janjoris@acm.org>
     Re: undump? (Mike Heins)
     Uploading cgi script (with perl?) <dimakop@cti.gr>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 10 Feb 1997 17:38:06 GMT
From: jason@daffodil.cs.odu.edu (Jason C Austin)
Subject: Re: "-i" switch is unsafe!
Message-Id: <JASON.97Feb10123806@daffodil.cs.odu.edu>

In comp.lang.perl.misc, Joe Bednorz <bednorz@mail.net-connect.net> writes:
> The other day someone on comp.lang.c tried to explain why 0 was true and
> all other integer values were false.  "Well, there's only one way for a
> program to succeed, but many ways for it to fail."
>
> Horse-puckey.  What about deletion?  Of anything?  If the object isn't
> there is that an error?  Of course not.  The desired objective has been
> achieved.

	Actually, in C zero is false and non-zero is true just like
perl.  The standard Unix process exit status is 0 for success and
non-zero for an arbitrary error code, but it's not set in stone.  If
your process needs to indicate other things back the parent, it can
define the exit status anyway it wants.  The zero/non-zero exit status
works the best for most applications, since you usually just want to
indicated if it worked, and if not, what happened.

	On the second point, I would consider deletion of non-existed
object an error.  If I try to rm a file that doesn't exist, I want to
know, because it could indicate another error.  If I don't care, I'll
just tell rm I don't care with the -f option.
--
Jason C. Austin
austin@visi.net



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

Date: Fri, 07 Feb 1997 11:51:11 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: ANNOUNCEMENT: Perl documentation and FAQ discontinued
Message-Id: <fl_aggie-ya023180000702971151110001@news.fsu.edu>

In article <geoffE57sor.BHJ@netcom.com>, geoff@netcom.com (Geoffrey Leach)
wrote:

+ Now Tom, put down that Fortran book.

Smile when you say that, partner.

James - yeah, I do fortan...wanna make something of it?

-- 
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: 12 Feb 1997 09:28:20 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Avoiding *massive number of pattern matches
Message-Id: <afpayu7v.fsf@jander.com>

> On Wed, 12 Feb 1997 04:24:37 GMT, Douglas Burbury <dburbury@vision.net.au> wrote:
> 
> e.g.O"[@_000123_@]"ring
>    ->  This tag represents a wrapping hyphen. The reconstituted text
> would be O-ring.
> 
> So I need to replace each tag code with the equivalent text or
> attribute code. The initial way I thought of to do it is to run
> *every* single pattern match on *every* single paragraph.

How about building the code for all the regex's as a string and then
evaling it?

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: 12 Feb 1997 09:54:38 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: CGI Script
Message-Id: <w10n2tahy6p.fsf@wombat.staff.ichange.com>

"Darrell LaRock" <rockhead@camalott.com> writes:

> Does Anyone have a CGI script I can use to send the output of a form into a
> file on my system.  (unix based).

#!/usr/local/bin/perl -w
require 5.003;
use strict;
use CGI;
eval {
 my($cgi) = new CGI;
 my(%params) = ();
 for($cgi->param()) {
  $params{$_} = $cgi->param($_);
 }
 my($file) = $cgi->param("file") || "/var/tmp/form_output.txt";
 my($name) = ''; my($value) = '';
 open(OUT,">>$file") || die "$0: Couldn't open $file for writing: $!";
 print STDOUT $cgi->header;
 print STDOUT $cgi->start_html(-title=>"&quot;CGI&quot; ne &quot;Perl&quot;",);
 print STDOUT <<EOF;
<h1>Form Output (also saved to $file)</h1>
<p align=center><blink>For more questions on the Common Gateway Interface,
a <b>language independent interface specification</b>,
please turn to <a href=news:comp.infosystems.www.cgi>the right
newsgroup</a>.</blink></p>
<p align=center>Please note that perl has nothing to do with the
Common Gateway Interface, contrary to the opinions of the
mass media.  CGI-compliant programs can be written in any language, hence
a language-specific newsgroup is probably not where you want to ask your
Common Gateway Interface-related question.</p>
EOF
 print OUT "### Beginning at " . scalar(localtime) . "\n";
 while(($name,$value)=each(%params)) {
  print STDOUT "Parameter name: <tt>$name</tt><br>\n";
  print STDOUT "Parameter value:<tt>$value</tt><br><br>\n";
  print OUT "Parameter name: $name\tParameter value: $value\n";
 }
 print OUT "### Ended at " . scalar(localtime) . "\n";
 close(OUT);
 print STDOUT $cgi->end_html;
 exit(0);
};
if ($@) {
 print STDOUT "Content-type: text/plain\n\n";
 print STDOUT "Error: $@";
}
__END__

--
<laird.nelson@netsinc.com> perl FAQ: http://www.perl.com/perl/faq Perl manual:
http://www.perl.com/CPAN/doc/manual/html/frames.html. If CGI/web appears in
your comp.lang.perl.* post, see news:comp.infosystems.www.authoring.cgi. CGI
stands for Common Gateway *Interface*, not Language or Program or Script.
Consolidated perl reference page: http://www.amherst.edu/~ljnelson/perl.html


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

Date: 12 Feb 1997 09:09:59 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Code refs not first class?
Message-Id: <hgjiyv2g.fsf@jander.com>

jason@ampersand.com (Jason Brazile) writes:

> 
> 
> Fellow Perl folks,
> 
> Hmmm. It seems as if either code references are not really first class
> or there is some inconsistent syntax on how to get at it that I am 
> failing to grasp. I am still relatively new to the language.

[...]

> #	&{sub {print "foo\n"}};			# syntax error

This works fine on my system, perl5.003_25. What version of perl are you using?

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: 12 Feb 1997 09:16:17 -0500
From: nelson <nmljn@wombat.staff.ichange.com>
Subject: Re: Code refs not first class?
Message-Id: <w10ohdqhzym.fsf@wombat.staff.ichange.com>

jason@ampersand.com (Jason Brazile) writes:
> Hmmm. It seems as if either code references are not really first class
> or there is some inconsistent syntax on how to get at it that I am 
> failing to grasp. I am still relatively new to the language.

You need to do some disambiguation.  If you say this:

    perl -e '&{ sub { print "Hello!\n" } };'

 ...then poor perl can't figure out whether you're trying to subscript
a hash, or what:

    Can't use subscript on subroutine entry at -e line 1, near
    ""Hello!\n" }"
    (Did you mean $ or @ instead of &?)
    Execution of -e aborted due to compilation errors

So you need to disambiguate what you mean by sub { print...}.  The
following works fine, suggesting that code references are indeed first
class:

    perl -e '&{ +sub { print "Hello!\n" } };'

Cheers,
Laird

--
<laird.nelson@netsinc.com> perl FAQ: http://www.perl.com/perl/faq Perl manual:
http://www.perl.com/CPAN/doc/manual/html/frames.html. If CGI/web appears in
your comp.lang.perl.* post, see news:comp.infosystems.www.authoring.cgi. CGI
stands for Common Gateway *Interface*, not Language or Program or Script.
Consolidated perl reference page: http://www.amherst.edu/~ljnelson/perl.html


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

Date: Wed, 12 Feb 1997 12:49:11 GMT
From: wegscd@whirlpool.com (Doug Wegscheid)
Subject: Re: DNS Lite?
Message-Id: <3301bb5b.547274@news.whirlpool.com>

On 7 Feb 1997 19:07:21 GMT, samuell@cahaba.cis.uab.edu (R L Samuell)
wrote:

>
>I have a fixed IP address with one ISP and a dynamic IP address
>with another.  I would like to setup a simple DNS server at the
>fixed location that would need to do only two things:  Provide
>my current dynamic address to anyone doing a DNS query to it and
>allow me to easily and remotely, but with some security, update 
>that dynamic address when it changes.  I really do not want to 
>install BIND or learn the details of DNS.
>
>I am familiar with James Brown's CGI Perl script for registering
>dynamic IPs on the Web but I want to have something that would 
>be more DNS-like, even transparent to the service.
>
>I would be very surprised if something like a "DNS Lite" server
>didn't already exist somewhere, possibly in Perl.

the load balacing DNS server might be a good place to start modifying;
it has a bunch of stuff you don't need, but the basic server stuff is
in there.

http://www-leland.stanford.edu/~schemers/dist/lb.tar

good luck.


--
Doug Wegscheid
wegscd@whirlpool.com

Q. How many bassists does it take to screw in a light bulb?
A. None, the keyboardists left hand does it for them.


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

Date: 12 Feb 1997 13:21:36 GMT
From: softbase@mercury.interpath.com (Scott McMahan - Softbase Systems)
Subject: Re: FORK :(
Message-Id: <5dsg50$5gp@redstone.interpath.net>

laurent (laurent@mars.fer.uni-lj.si) wrote:
: Is there any Perl port for Win95 that supports fork and socket
: functions?

fork as we know it from UNIX is impossible in the VMS-inspired Win32
architecture. I haven't ever had time to write up the essay about
why.

Socket support seems to work fine in the Win32 port -- I've written
single-client server apps in it.

Scott



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

Date: 12 Feb 1997 09:04:10 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: getprpwent Perl library?
Message-Id: <iv3yyvc5.fsf@jander.com>

eq6@ornl.gov (Ishee J A) writes:

> I have been using the getpwent function in various system admin. scripts
> with generally good results, but on Digital Unix with enhanced security 
> enabled, getpwent is unable to extract users' passwords from the password
> database file. I notice that DEC includes a C function, getprpwent, to
> obtain the password information. Does anyone know of a perl module which
> duplicates this function? I haven't had any luck on CPAN or in the various
> docs and FAQS. Thanks,

Sounds like a good excuse for learning how to write perl5 extensions :)

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: 12 Feb 1997 13:54:56 +0100
From: Ronald Fischer <rfi@uebemc.siemens.de>
Subject: grep in `command|grep pattern` seems not to work ????
Message-Id: <xz2afpachgf.fsf@uebemc.siemens.de>

I want to get the names of all files from a remote host, that reside in
a certain directory and do NOT end in certain characters. To do this, I
tried
        @files = `(rsh -l $remoteUser $remoteMachine 'ls -1adp $dir/* $dir/.*')|grep -v '[,/~%]$'`;

When I invoke the command inside the backquotes manually, it works as expected. Under
Perl, it does not:
    - as given, @files does not contain any file
    - removing the "-v" switch causes @file to contain all filenames
    - omitting the |grep part causes @file to contain all filenames (as one would expect)
This observations indicate that the rsh works fine, but the grep does not. Of course,
an alternative would be to use Perl's grep instead, but nevertheless I am curious to
know why the statement does not work in the form I put it.

-- 
Ronald Otto Valentin Fischer
business:	ronald.fischer@uebemc.siemens.de
private:	ronald.fischer@acm.org
http://ourworld.compuserve.com/homepages/ronald_fischer


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

Date: 12 Feb 1997 14:34:19 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: grep in `command|grep pattern` seems not to work ????
Message-Id: <5dskdb$re1@news-central.tiac.net>

In article <xz2afpachgf.fsf@uebemc.siemens.de>,
Ronald Fischer  <rfi@uebemc.siemens.de> wrote:
>I want to get the names of all files from a remote host, that reside in
>a certain directory and do NOT end in certain characters. To do this, I
>tried
>        @files = `(rsh -l $remoteUser $remoteMachine 'ls -1adp $dir/* $dir/.*')|grep -v '[,/~%]$'`;

Have you tried putting the command into a string and printing the string
to see what's actually being executed by ``?  One thing that upsets the
shell is an un-chomp'ed \n at the end of an interpolated variable...

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: 12 Feb 1997 09:29:53 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Help for a perl program (small and simple)
Message-Id: <914uyu5a.fsf@jander.com>

toto1@netaphore.com (JACKO1) writes:

You've posted to the wrong newsgroup. Repost to

	comp.infosystems.www.authoring.cgi

> I'm a newbie in Perl and am trying to do the following ...
> 
> I want to create a dynamic page which allows ...
> 
> By clicking on the link to this page a new page is created on the fly
> (by passing arguments through a post  (type of page + page number).
> 
> This page must allow :
> - to include a .txt file (ie. 12.txt)
> - to include navigation facilities as go previous page or next page
> (it'll be a call to the script with -1 +1 page numbers) (ie. 11.txt
> and 13.txt)
> 
> That's all but that's enough for me at this stage ..

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: Tue, 11 Feb 1997 10:19:58 -0700
From: Jeff Hapke <hapkejs@cig.mot.com>
Subject: Help: Ioctl for serial I/O
Message-Id: <3300AA3E.73B9@cig.mot.com>

I am trying to use the Ioctl.pm module to set up a serial port to
9600,N,8,1.
I've also tried to require 'ioctl.ph' per examples in the camel book,
etc.
I am running solaris 2.4 x86, perl5.003, compiled w/gcc 2.6.0.
This is what I get with Ioctl.pm:

(root): perl
use Ioctl;
Can't find loadable object for module Ioctl in @INC
(/usr/local/lib/perl5/i86pc-solaris/5.003 /usr/local/lib/perl5
/usr/local/lib/perl5/site_perl/i86pc-solaris
/usr/local/lib/perl5/site_perl .) at /usr/local/lib/perl5/Ioctl.pm line
97
BEGIN failed--compilation aborted at - line 1.
(root):

line 97 of Ioctl.pm looks like this:
bootstrap Ioctl $VERSION;

How do I go about "rolling my own" Ioctl stuff, I'm not sure it is set
up correctly.
Any help in setting up the serial port would be appreciated.


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

Date: 12 Feb 1997 14:25:39 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: HELP: Pattern Matching Problem
Message-Id: <5dsjt3$qke@news-central.tiac.net>

In article <3302045D.3D4D@fys.kuleuven.ac.be>,
Geert Nijs  <geert.nijs@fys.kuleuven.ac.be> wrote:

>Again a pattern matching problem:
>
>String= "these!are!all!words!geert@fys.kuleuven.ac.be"
>
>Goal: extract everything after the last ! sign
>	so I want to get 'geert@fys.kuleuven.ac.be'
>
>The number of ! signs is highly variable and unknown.

  unless (($stuff) = $string =~ /^.*!(.*)$/) {
    ... no stuff matched
  }

might be one way to do it (remembering that . doesn't match \n by
default...,) or maybe something like:

  $stuff = (split /!/, $string)[-1];

would be more to your taste.

In perl there are generally lots of ways to do a task, and you can pick
whichever you like (as long as you keep in mind that some may be faster,
some may be more memory hungry, some may be more obscure etc.)

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: 12 Feb 1997 13:49:42 GMT
From: <tchrist@mox.perl.com>
Subject: Re: How to Determine operating system type?
Message-Id: <5dshpm$oek$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Kin Cho <kin@sampras.isi.com> writes:
:Is there a builtin subroutine or a package call for this?

Use the $^O variable, at least recently.

--tom
-- 
	Tom Chrisiansen	tchrist@jhereg.perl.com
    If I allowed "next $label" then I'd also have to allow "goto $label",
    and I don't think you really want that...  :-) [now works in perl5!]
            --Larry Wall in <1991Mar11.230002.27271@jpl-devvax.jpl.nasa.gov>


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

Date: Wed, 12 Feb 1997 09:14:16 -0500
From: Jason Hotra <hotraja1@pilot.msu.edu>
Subject: How to make perl work with forms
Message-Id: <3301D038.4F37@pilot.msu.edu>

I just put a message out but its gone now so heres my problem:
I have specified in my form under action the full URL for the perl
script I wish to use. WHen I do this, it just outputs the written text
file for the script.  What can I do to make the program run instead of
display the code?

jason


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

Date: 12 Feb 1997 08:51:05 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: How to tell if Perl is run in debug mode
Message-Id: <n2tayvxy.fsf@jander.com>

Brett Denner <dennerbw@lmco.lmtas.com> writes:

> I would like to add some code to my perl script that is executed only
> when perl is started with the -d flag (either via the command line or
> the #!/usr/bin/perl line).  I envision something like this:
> 
> if ($DEBUG_MODE)
>     {
>     # do something
>     }
> 
> where $DEBUG_MODE (or some other such variable) is true only in debug
> mode.
> 
> Does such a variable exist?  Is there another way to tell if my script
> is being run in debug mode?

if ($^P) {
}

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: Wed, 12 Feb 1997 09:02:49 -0500
From: Jason Hotra <hotraja1@pilot.msu.edu>
Subject: How To
Message-Id: <3301CD89.3704@pilot.msu.edu>

I don't know what I'm doing wrong, but every time I reference a form in
HTML to a perl script, it gives me an error. So when I specify the
entire URL (including http://), it just outputs the whole stinkin
script.  What am I doing wrong?

Jason


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

Date: Wed, 12 Feb 1997 13:10:39 +0100
From: b.coret@myself.com (Bob Coret)
Subject: Locking mechanism
Message-Id: <3301B33F.2781E494@myself.com>

I have a question regarding locking mechanisms. I am building a system
which uses a flatfile database. Users can add/edit/remove records. Of
course testing it at home shows no problems. But what will happen if a
couple of people simultaneously try to add/edit and remove record...
How will Unic and Perl react, are there standard locking mechanism, or
must I write these locking mechanism myself, obvious question: how? Are
there any good examples on the web?? Would breaking up de database in
files of say 100 records do the speed any good?

Bob Coret



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

Date: 12 Feb 1997 09:17:11 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: optimization of binary data operations.
Message-Id: <g1z2yuqg.fsf@jander.com>

duncan@isip05 (Richard J. Duncan) writes:

> 
> I am trying to do some really simple DSP in a perl script. It requires
> the swapping of word order for a stream of data. My current pathetic
> approach is:
> 
> 	while(($len = sysread(PIN,$_,4))>0){
> 		if (/(..)(..)/) {
> 			syswrite(POUT,"$2$1",$len);
> 		}
> }
> 
> Where PIN and POUT are input/output file handles, respectively.
> 
> This is dog slow, I would like to be able to work on 8k of data at a
> time in a memory buffer. Does Perl have anything like a pointer for
> memory?

substr

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: 12 Feb 1997 08:52:50 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Pasting between apps question
Message-Id: <lo8uyvv1.fsf@jander.com>

Richard Arnesen <rdarnese@nortel.ca> writes:

> [ Article reposted from comp.windows.x ]
> [ Author was Richard Arnesen <rdarnese@nortel.ca> ]
> [ Posted on 11 Feb 1997 17:12:52 GMT ]

Why repost this to a perl newsgroup??? Makes no sense.

> What I want to do is have a script or whatever send it's output
> to another X application via whatever utility available within X to do 
> this.  
> 
> I had been pointed to xmh as an example.  However upon looking through
> it's docs it appears that that is just a function of xmh.
> 
> What I need to know is there a way to by X-windows standards send
> output from a script into another X-window (through a buffer or whatever).

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: Wed, 12 Feb 1997 07:43:58 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Pattern matching and regular expression
Message-Id: <uehsd5.2v.ln@localhost>

Fred Adorno (fadorno@mail.gte.net) wrote:
: Gentlemen,

: I like to be able to find every word that begins with a character and
: ends with that same character in my dictionary using perl.  I can do it
: using vi, ed and shell scripting but I can't seem to get it to work with
: perl.  Any suggestions?

: This is how it works with the editors:

: ^\(.\).*\1$


Parenthesis in perl regexs default to their meta-meaning (grouping, etc).
You only escape them when you want literal parens.

So, this should do it:


perl -ne 'print if /^(.).*\1$/' /usr/dict/words 



--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Fri, 07 Feb 1997 11:54:11 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Perl and Crontabs
Message-Id: <fl_aggie-ya023180000702971154110001@news.fsu.edu>

In article <5dflrc$3e6@news3.digex.net>, bliles@power.digex.net (Bryan C.
Liles) wrote:

+ This code snippet below works when I run it from the command line, but it
+ doesn't work from cron.  Do I need to define something somewhere?

Yes, your path. Or the location of 'date':

open(DATE, "/bin/date +\"%d%m%Y-%H%M\ |");

James - or where date happens to reside on your machine...

-- 
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: 12 Feb 1997 14:09:16 GMT
From: tgorby@emc.com (Terry Gorby)
Subject: perl in varied environment
Message-Id: <5dsiuc$qai@emcnews.emc.com>

I am using perl in a unix environmet
that is widely varied.  I have to live with for now.
Perl can reside in /usr/local/bin, /usr/local/SOLARIS/bin,
or in /home/bin.

I would like my perl scripts to execute the available
perl binary depending on the environment.
Is this possible? If so, may I see an example?

Thanks in advance

Terry



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

Date: Wed, 12 Feb 1997 12:15:27 +0000
From: "Duncan C. White" <d.white@surrey.ac.uk>
Subject: Perl module manual pages causing problem with man -k
Message-Id: <3301B45F.49FA@surrey.ac.uk>

Hello everyone,

Apologies if this is a FAQ - I can't find the problem mentioned anywhere
so far.  I've just installed Perl 5.003 on a Solaris 2.5.1 machine.  All
the manual pages for that are fine, and have gone in /usr/man/manl.

Now I'm trying to install lots of perl modules from CPAN, especially
Perl/Tk 400/202 and all its underlings (libnet, libwww, IO, MD5 etc)

All tests on all modules work fine.  All the manual pages got installed
into /usr/man/man3p, which is fine.  Then I run, as I always do after
installing a package with man pages in /usr/man:

catman -w -M /usr/man

This rebuild /usr/man/windex containing the man -k database.  When
I look at the windex file, or do a man -k perl search, I get lots of
lines like:

"NAME"          .IX (3p)        - Arbitrary length float math package
"NAME"          .IX (3p)        - Arbitrary size integer math package
"NAME"          .IX (3p)        - CGI Interface for Fast CGI
"NAME"          .IX (3p)        - CGI routines for writing to the HTTPD
error log
"NAME"          .IX (3p)        - Copy files or filehandles

Clearly, the man pages that pod2man has generated are completely
confusing Solaris' catman program.  Has anyone got a solution?
I've started looking at the program that catman invokes to do the
work, /usr/lib/makewhatis, and I can probably (eventually) work out
what is confusing it, but many other people must have found this
problem themselves already, and hopefully some have solved the problem!
Can pod2man be altered somehow?

        cheers,
        duncan
 
------------------------------------------------------------------------------
Duncan C. White, Senior Computing Officer, Dept of Maths and Computing
Science,
                 University of Surrey, Guildford, Surrey GU2 5XH, UK.
Email:  D.White@mcs.surrey.ac.uk                        Phone: +441 483
259632
URL:    http://www.mcs.surrey.ac.uk/showstaff?D.White   Fax: +441 483
259385
 
PGPkey: http://www.mcs.surrey.ac.uk/Personal/D.White/pgpkey.html
Key fingerprint = 91 93 0D 90 D0 5E 62 BF  57 39 08 56 43 FC E5 C8
------------------------------------------------------------------------------
"After all, this is a species whose principal means of population
control are
 famine, abortion, a high infant death rate and war."
                Intervention (page 442) - Julian May
------------------------------------------------------------------------------


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

Date: Wed, 12 Feb 1997 12:27:25 +0000
From: Steve Gailey <steveg@metrosol.demon.co.uk>
Subject: perl ulimit -c 0 ?
Message-Id: <3301B72D.5712@metrosol.demon.co.uk>

I have a perl script which is a wrapper for an application. Unfortunatly
the application is quite buggy and keeps dropping core leaving large
(10MB) core files around the place.

Is there a way to set the ulimit from perl which will carry forward to
the program I run with exec()? I tried `ulimit -c 0` prior to the exec,
but of course this had no effect.

Thanks,

Steve


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

Date: Wed, 12 Feb 1997 01:53:08 -0800
From: bierman@apple.com (Peter Bierman)
Subject: Pointer to 4-arg select examples?
Message-Id: <bierman-1202970153080001@bierpe3.apple.com>

After trying for an hour to find any examples of 4 arg select socket
programming I'm hoping someone here will know of some.

Doing an altavista serarch on "+perl +code +example +select" turns up too
many useless hits, because of select's more common form.

-pmb

-- 
bierman@apple.com 
http://www.upl.cs.wisc.edu/~lunatic/   "This is MASS MADNESS you MANIACS!"


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

Date: 12 Feb 1997 14:12:26 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: Pointer to 4-arg select examples?
Message-Id: <5dsj4a$92p@vixen.cso.uiuc.edu>

Peter Bierman (bierman@apple.com) wrote:
: After trying for an hour to find any examples of 4 arg select socket
: programming I'm hoping someone here will know of some.
: 
: Doing an altavista serarch on "+perl +code +example +select" turns up too
: many useless hits, because of select's more common form.
: 

It is pretty simple.  Here is the typical sequence, assuming you
have already bound and are listening on a socket with the filehandle
SOCKET:

 $tick = 1;
 my $Signal_Terminate;

 $SIG{'INT'}  = sub { $Signal_Terminate = 1; };
 $SIG{'TERM'} = sub { $Signal_Terminate = 1; };

 for (;;) {

        $rin = '';

        vec($rin, fileno(SOCKET), 1) = 1;

        # You can monitor as many as you want, here we
	# just look at one socket
        #vec($rin, fileno(NEXTSOCKET), 1) = 1;

        $n = select($rout = $rin, undef, undef, $tick);
        print DEBUG "select $n\n";

        if ($n == -1) {
            if ($! =~ m/^Interrupted/) {
                if ($Signal_Terminate) {
                    last;
                }
                #print DEBUG "interrupted $n\n";
            }
            else {
                die "select: $!\n";
            }
        }
        elsif (vec($rout, fileno(SOCKET), 1))		{
		# Fork your child/do your work here
	}
        #elsif (vec($rout, fileno(NEXTSOCKET), 1))	{
		# If monitoring more than one descriptor, 
		# do whatever here
	#}
	else {
		die "Select returned $n?\n";
	}

	last if $Signal_Terminate;
 }

The tick is to give you a chance to do occasional processing,
or handle terminates from operating systems that don't have interruptible
select calls.  Here it is set to one second -- you could make it most
anything that suits your purpose, including 0 for never.


-- 
Regards,                                                      ___       ___
Mike Heins     [mailed and posted]  http://www.iac.net/~mikeh|_ _|____ |_ _|
                                    Internet Robotics         | ||  _ \ | |
This post reflects the              Oxford, OH  45056         | || |_) || | 
opinion of my employer.             <mikeh@iac.net>          |___|  _ <|___|
                                    513.523.7621 FAX 7501        |_| \_\   


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

Date: 11 Feb 1997 17:02:11 GMT
From: "Michael Avila" <lnussat.mavila@eds.com>
Subject: read and write +> at the same time - HOW?
Message-Id: <01bc183d$7ecf0760$e672b182@j00524176.try.sat.gmeds.com>

I cannot find any examples of how to read and write to a file at the same
time.  I have the open as follows:

open (IDDBFILE, "+>../../../company/carclub/reports/iddb") || die "Error:
$!";

I'd sure appreciate any help.  I've looked at 2 PERL books I have and they
do not have any examples asside from how to code the open statement.  I
also searched the web and did not find any good information.

TIA

Mike






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

Date: Wed, 12 Feb 1997 07:32:10 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: read and write +> at the same time - HOW?
Message-Id: <qogsd5.st.ln@localhost>

Michael Avila (lnussat.mavila@eds.com) wrote:
: I cannot find any examples of how to read and write to a file at the same
: time.  I have the open as follows:

: open (IDDBFILE, "+>../../../company/carclub/reports/iddb") || die "Error:
  ^^^^
: $!";

: I'd sure appreciate any help.  I've looked at 2 PERL books I have and they
                                      ^^^^^^^^^^^^^^^^^^^^^^
: do not have any examples asside from how to code the open statement.  I
: also searched the web and did not find any good information.
       ^^^^^^^^^^^^^^^^


You missed a valuable resource right under your nose!

Included with the perl distribution are a bunch of files with a
 .pod (Plain Old Documentation) filename extension. These are known 
as 'man pages'. They are easily converted into many formats by 
(what else) perl scripts also included with the perl distribution.

Find out where they are on your system, and consult them frequently.

[ You may want to do this soon. It is rumored that the next perl
  distribution will NOT include any documentation because it is very
  seldom read anyway! Squirrel them away somewhere while they are
  still available (better get the helpful perl FAQ lists too).
]


As you have a question about open(), looking it up in the man pages
should be the _first_ place you look. You would have found this in
the very first paragraph of the section about open() in the 
helpful perlfunc man page:

-----
You can put a '+' in front
of the '>' or '<' to indicate that you want both read and write access to
the file; thus '+<' is usually preferred for read/write updates--the '+>'
mode would clobber the file first.
           ^^^^^^^^^^^^^^^^^^^^^^
-----


But,

You probably don't want to do it that way. You'll have to use seek(),
tell()  (helpful perlfunc man page again) and manage where you
are in the file.


The much easier, and, by far, the most used method is to write to
a temp file and then rename()  (helpful perfunc man page again, again)
to move the temp file over the original.

Is some cases perl will do all this temp file/renaming business (and
create a backup of the original file, if you ask it to) for you!

Check out the -i command line switch in the helpful perlrun man page.



--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 12 Feb 1997 09:35:54 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: read and write +> at the same time - HOW?
Message-Id: <7mkeytv9.fsf@jander.com>

"Michael Avila" <lnussat.mavila@eds.com> writes:

> I cannot find any examples of how to read and write to a file at the same
> time.  I have the open as follows:

It doesn't exactly mean "at the same time". The way you're using it
means, "first I want to write the file, later I want to read it". I
haven't done this for a while, but as I recall, you need to do a seek
between the writing and reading.

> open (IDDBFILE, "+>../../../company/carclub/reports/iddb") || die "Error:
> $!";
> 
> I'd sure appreciate any help.  I've looked at 2 PERL books I have and they
> do not have any examples asside from how to code the open statement.  I
> also searched the web and did not find any good information.

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: 12 Feb 1997 14:40:47 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: read and write +> at the same time - HOW?
Message-Id: <5dskpf$ps8$1@csnews.cs.colorado.edu>


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

In comp.lang.perl.misc, 
    "Michael Avila" <lnussat.mavila@eds.com> writes:
:I cannot find any examples of how to read and write to a file at the same
:time.  I have the open as follows:
:
:open (IDDBFILE, "+>../../../company/carclub/reports/iddb") || die "Error:
:$!";

that's the wrong way.  you want +< not +> there.

:
:I'd sure appreciate any help.  I've looked at 2 PERL books I have and they
:do not have any examples asside from how to code the open statement.  I
:also searched the web and did not find any good information.

$RECSIZE = 220; # pick a record size
$recno   = 37;  # pick a record to update
open(FH, "<+somewhere") || die "can't update somewhere: $!";
seek(FH, $recno * $RECSIZE, 0);
read(FH, $record, $RECSIZE) == $RECSIZE || die "can't read record $recno: $!";
# munge the record
seek(FH, $recno * $RECSIZE, 0);
print FH $record;

--tom
-- 
	Tom Chrisiansen	tchrist@jhereg.perl.com

    "A witty saying proves nothing."
		    --Voltaire


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

Date: 12 Feb 1997 08:48:56 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: regexp help
Message-Id: <ohdqyw1j.fsf@jander.com>

Phil Williams <williams@irc.chmcc.org> writes:

> 
> Sorry for the basic question but regexps are still very confusing to me.
> 
> Here's what I want to do.  I have a user input string of items that may
> be delimeted with spaces, commas, semicolons, carriage returns, etc. or
> any combination of those.  I want to substitute those with a single ,.
> 
> Here's what I do
> 
> $value =~ s/[,:; ][ \n]*/,/g;
> 
> Which works except that it leaves the last, sometimes unwanted character
> in place.  i.e. the user hit a <ret> at the end but did not enter
> anything afterwards.  How would I check and get rid of this last char in
> the same regexp?

Season to taste ;-)

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

while (<DATA>) {
  print "BEFORE: <$_>\n";
  s/[\s,:;]/,/g;
  print "AFTER : <$_>\n";
}

__DATA__
aa bbb :;ccc
dd;
eee
fff   
ddd;ddd

  eee:ff gg
===========================================================================

Produces:

===========================================================================
BEFORE: <aa bbb :;ccc
>
AFTER : <aa,bbb,,,ccc,>
BEFORE: <dd;
>
AFTER : <dd,,>
BEFORE: <eee
>
AFTER : <eee,>
BEFORE: <fff   
>
AFTER : <fff,,,,>
BEFORE: <ddd;ddd
>
AFTER : <ddd,ddd,>
BEFORE: <
>
AFTER : <,>
BEFORE: <  eee:ff gg
>
===========================================================================

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: 12 Feb 1997 09:02:24 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Regexp question...
Message-Id: <k9oeyvf3.fsf@jander.com>

jcostom@shaft.sjis.com (Jason Costomiris) writes:

> I've been given the wonderful (yeah, sure) task of coming up with a 
> program that will do some accounting type stuff.  Some of the files
> are in a priveleged area of the system, so I will use a C wrapper to run the 
> script setuid to root.  Of course, since it will be ordinary support
> lusers running it, I want to trap any naughty chars... For ex:
> 
> If I did soemthing like:
> 
> prog customer.com&&'cp /bin/sh ~/.foo'
> prog cust2.com&&'chmod 4755 ~/.foo'
> 
> I'd have a bit of trouble...
> 
> Suppose I store $ARGV[0] in a var called $domain.  I'd need to do something 
> like:
> 
> $domain =~ s/<some regexp here>//;
> 
> I'd like to be able to keep the first part (the customer domain), and
> potentially account for doing it with a hostname as well (host.domain.com)..
> 
> Thoughts?

My first thought is that it isn't clear, at least to mee, what it is
you want to do. But maybe you're asking for something like this:

my ($domain,$cmd) = split /&&/, $ARGV[0], 2;

-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: Wed, 12 Feb 1997 12:31:00 GMT
From: lbw@cougar.com (Len Wilson)
Subject: Re: sgmlstripper not stripping (or how to turn html to text)
Message-Id: <lbwE5HpFo.HGE@netcom.com>

Dave Thomas (dave@fast.thomases.com) wrote:

> On 9 Feb 1997 17:59:34 -0500, Phil Gross <philbo@bronze.lcs.mit.edu> wrote:

> >   while($char = getc(INPUT)) {
>            ^^^^^^^^^^^^^^^^^
> 	   
> This is a 'C' programmer writing Perl! In Perl, numbers and strings are
> (mostly) interchangable. The number zero is false in a logical context. So
> when the input comes across a zero (as in '1107 AM EST'), the loop terminates.

> Getc returns a null string at EOF.

> As an alternative, have you had a look at HTML::FormatText in the libwww
> package?

If all one wants is a simple script that does what sgmlstripper is
*supposed* to do, then here's one:

---
#!/usr/local/bin/perl
##  Use STDIN if no files are given
$ARGV[0] = "-" unless @ARGV;
foreach $file (@ARGV) {
  open(INPUT, $file) or die "* Can't open file" ;
  read(INPUT, $buffer, 60000) or die "* Unable to read file" ;
  $buffer =~ s(<.*?>)()gsx ;
  ## Print to STDOUT
  print $buffer ;
  close(INPUT) ;
}
---

Enjoy,
Len Wilson



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

Date: 12 Feb 1997 09:25:54 -0500
From: Jim Anderson <jander@jander.com>
Subject: Re: Sourcing files from my perl script
Message-Id: <bu9qyubx.fsf@jander.com>

dave@fast.thomases.com (Dave Thomas) writes:

> 
> On Tue, 11 Feb 1997 16:55:04 -0800, Charles Peri - EUCD ~ <cperi@pcocd2.intel.com> wrote:
> > Hi all,
> > 
> > 	I am trying to source a file which sets env variables
> > from inside my perl script. Since I need these env variables 
> > later in my program, I have to get the vaiables set by
> > the source command.
> > 
> > For example :
> > if file, "file_to_source" has
> > setenv NAME some_name
> > setenv VAR1 varable1
> > setenv VAR2 variable2
> 
> If you just want to set variables, then:
> 
>    my $input = 
>    'setenv NAME some_name
>    setenv VAR1 varable1
>    setenv VAR2 variable2
>    ';
> 
> 
>    for (split(/\n/, $input)) {   # equivalent to while (<IPFILE>)
>       my ($dummy, $name, $value) = split;
>       $ {$name} = $value;
>     }
>    
>    print "NAME=$NAME, VAR1=$VAR1, VAR2=$VAR2\n";
> 
> # or the somewhat more compact...
> 
>    undef $NAME;undef $VAR1;undef $VAR2;
> 
>    $input =~ s/setenv\s+(\w+)\s+(\w+)/$ {$1} = $2/gem;
>    print "NAME=$NAME, VAR1=$VAR1, VAR2=$VAR2\n";

It's not entriely clear what the original question is asking, but if
I'm interpreting it correctly, then not only does the above solution
not work, but there is no solution. It's not possible to invoke a
script to set environment variables that can be accessed by the
invoker of the script.
























-- 
Jim Anderson			jander@jander.com
PGP Public Key Fingerprint:	0A 1C BB 0A 65 E4 0F CD
				4C 40 B1 0A 9A 32 68 44


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

Date: 12 Feb 1997 14:01:03 +0100
From: Jan Joris Vereijken <janjoris@acm.org>
Subject: undump?
Message-Id: <5dseuf$2u5@wsinfm12.win.tue.nl>

Hi,

Is there anybody who got undump working with perl under SunOS?

I know the FAQ says I can try "unexec", but that's not an option for me.

Thanks in advance,

- Jan Joris -


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

Date: 12 Feb 1997 14:17:06 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: undump?
Message-Id: <5dsjd2$92p@vixen.cso.uiuc.edu>

Jan Joris Vereijken (janjoris@acm.org) wrote:
: Hi,
: 
: Is there anybody who got undump working with perl under SunOS?
: 
: I know the FAQ says I can try "unexec", but that's not an option for me.
: 

SunOS is the one OS where I know undump works, for I have successfully
used it myself.  I will send you the "Idiot's Guide to Undump", original
author unknown.  Don't be offended please -- I didn't name it.  It has
a complete procedure for using undump (from the standard undump distribution,
circa 1988) and it works -- for SunOS only.  Don't be thinking that means
Solaris 2. 8-)

-- 
Regards,                                                      ___       ___
Mike Heins     [mailed and posted]  http://www.iac.net/~mikeh|_ _|____ |_ _|
                                    Internet Robotics         | ||  _ \ | |
This post reflects the              Oxford, OH  45056         | || |_) || | 
opinion of my employer.             <mikeh@iac.net>          |___|  _ <|___|
                                    513.523.7621 FAX 7501        |_| \_\   


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

Date: Wed, 12 Feb 1997 13:41:55 +0200
From: <dimakop@cti.gr>
To: lstein@genome.wi.mit.edu
Subject: Uploading cgi script (with perl?)
Message-Id: <Pine.SOL.3.92.970212132824.101L-100000@hermes.cti.gr>

Hi,

	We are trying to set a service on our Web service where any
user can access a form through which he/she can upload a file to the
server. Although we have been able to write the html script to
implement the form and initiate the uploading we have problems with
the cgi script which runs on the server and receives the files.

	So my question is if there is anywhere any script that could
do this job? Or if there is any function in the Perl libraries that
could do or, at least help us in this direction?

Thank you in advance,

           ------------------------------------------------------
           | Panos Dimakopoulos             dimakop@cti.gr      |
           | COMPUTER TECHNOLOGY INSTITUTE                      |
           | P.O. Box 1122                                      |
           | 261 10 Patras, Greece                              |
           | Tel (+30) 61 994317            Fax (+30) 61 993973 |
           ------------------------------------------------------



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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

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


------------------------------
End of Perl-Users Digest V7 Issue 933
*************************************

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