[6291] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 913 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 7 19:13:17 1997

Date: Fri, 7 Feb 97 16:00:21 -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           Fri, 7 Feb 1997     Volume: 7 Number: 913

Today's topics:
     Re: ANNOUNCEMENT: Perl documentation and FAQ discontinu <ljnelson@unix.amherst.edu>
     Re: ANNOUNCEMENT: Perl documentation and FAQ discontinu (Charles DeRykus)
     Re: ANNOUNCEMENT: Perl documentation and FAQ discontinu (Piotr Piatkowski)
     Re: ANNOUNCEMENT: Perl documentation and FAQ discontinu (Tad McClellan)
     Database search: Perl or C++ <amehta@deans.umd.edu>
     Re: Division and Rounding (Lynn Wilson)
     Re: DNS lookups in perl (Michael Fuhr)
     Re: environment variables <dean@tbone.biol.sc.edu>
     Re: fcntl() in v4 (Charles DeRykus)
     File::Find vs. find.pl (Frans Postma)
     Help: $| does not flush stream (swapna ganashyam samant)
     How MS Explorer And Navigator Handle CGI - Web Review MikeChang@aol.com
     Re: Inserting \n inside the string (Dave Thomas)
     need a simple script (scott mcgrew)
     PERCEPS: The Perl C++ Surveyor, New Version 1.2 availab <mpeskin@mail.utexas.edu>
     Re: perl HTTP proxy? <aas@bergen.sn.no>
     perl install problem <matylonj@ccmail.orst.edu>
     Perl on local win95 system <markmelch@melchiorre.com>
     Perl on SunOS 4.1.3 <jwarner@mitre.org>
     Re: Perl on SunOS 4.1.3 <dean@tbone.biol.sc.edu>
     Re: Perl vs Korn Shell (Ilya Zakharevich)
     Re: Perl vs Korn Shell <nw@hydaspes.if.org>
     Re: Perl vs Korn Shell <ali@axian.com>
     Re: regexps challenge - movies.txt (0/1) (Tad McClellan)
     Removing extra spaces (Lynn Wilson)
     Re: Simple simple question <rootbeer@teleport.com>
     Re: Variables in ?modules? or included files. <bignell@netcom.ca>
     why can't "system" return a long? (Ellen Paik)
     Re: why can't "system" return a long? (Dave Thomas)
     Re: why can't "system" return a long? (Mike Stok)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Fri, 07 Feb 1997 15:47:51 -0500
From: "Laird J. Nelson" <ljnelson@unix.amherst.edu>
Subject: Re: ANNOUNCEMENT: Perl documentation and FAQ discontinued
Message-Id: <32FB94F7.76A2@unix.amherst.edu>

Mark Allman wrote:
> We pray that Tom's post is laced with sarcasm.

What post of his isn't?  :-)

Cheers,
Laird


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

Date: Fri, 7 Feb 1997 19:12:23 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: ANNOUNCEMENT: Perl documentation and FAQ discontinued
Message-Id: <E58yoo.8pv@bcstec.ca.boeing.com>

In article <5de9vt$a5r@nova.dimensional.com>,
Michael Fuhr <mfuhr@dimensional.com> wrote:
>Tom Christiansen <tchrist@mox.perl.com> writes:
>
>>As of the next release of Perl, no documentation or examples will
>>be shipped, since no one reads them anyway.  Furthermore, the FAQ
>>is also discontinued.  Please remove copies of any of this documentation
>>wherever you may find it, since it's obvious from the postings in this 
>>group that it has never done a bit of good.
>
>Excellent!  I was getting really tired of telling people to RTFM; now
 >I won't have to.  Say, could we recall all the unread Camels and have a
 >weenie-roast to celebrate?

Tom's a vegetarian I think. 

I'll bet he'll agree to roast something though...


--
Charles DeRykus
ced@carios2.ca.boeing.com


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

Date: 7 Feb 1997 21:51:39 +0100
From: kompas@galaxy.uci.agh.edu.pl (Piotr Piatkowski)
Subject: Re: ANNOUNCEMENT: Perl documentation and FAQ discontinued
Message-Id: <5dg4kr$cek@galaxy.uci.agh.edu.pl>

Tom Christiansen <tchrist@mox.perl.com> wrote:
: As of the next release of Perl, no documentation or examples will
: be shipped, since no one reads them anyway.  Furthermore, the FAQ
: is also discontinued.  Please remove copies of any of this documentation
: wherever you may find it, since it's obvious from the postings in this 
: group that it has never done a bit of good.

Well, what about writing a perl script which will automagically find 
FAQ's in this group, then reply with FAQ copy and cancel them? :-)

-- 
Piotr Pi1tkowski, Uczelniane Centrum Informatyki, AGH Krakow, POLAND


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

Date: Fri, 7 Feb 1997 15:43:43 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: ANNOUNCEMENT: Perl documentation and FAQ discontinued
Message-Id: <fm7gd5.rg.ln@localhost>

Charles DeRykus (ced@bcstec.ca.boeing.com) wrote:
: In article <5de9vt$a5r@nova.dimensional.com>,
: Michael Fuhr <mfuhr@dimensional.com> wrote:
: >Tom Christiansen <tchrist@mox.perl.com> writes:
: >
: >>As of the next release of Perl, no documentation or examples will
: >>be shipped, since no one reads them anyway.  Furthermore, the FAQ
: >>is also discontinued.  Please remove copies of any of this documentation
: >>wherever you may find it, since it's obvious from the postings in this 
: >>group that it has never done a bit of good.
: >
: >Excellent!  I was getting really tired of telling people to RTFM; now
:  >I won't have to.  Say, could we recall all the unread Camels and have a
:  >weenie-roast to celebrate?

: Tom's a vegetarian I think. 

: I'll bet he'll agree to roast something though...


A book burning for anything with three or less camels  ;-)


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


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

Date: Fri, 07 Feb 1997 16:02:54 -0800
From: Amit Mehta <amehta@deans.umd.edu>
Subject: Database search: Perl or C++
Message-Id: <32FBC2AE.7CD7@deans.umd.edu>

I am attempting to rewrite a database searching engine.  I am trying to 
figure out how much the efficency would be decreased by using perl 
instead of C++.  If anybody can give me any info ideas I'd be grateful!

Sean Holman
sholman@deans.umd.edu


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

Date: 7 Feb 1997 22:12:57 GMT
From: lynn@swcp.com (Lynn Wilson)
Subject: Re: Division and Rounding
Message-Id: <5dg9d9$3ra@sloth.swcp.com>

: > There are some numbers that can't be accurately represented in a
: > typical floating point format, and sometimes

The way that I remember all of this is that there are only 2^32
unique ways that you can set the bits in a 32 bit machine register.

As a floating point number, these bit are interpreted with some of the
bits being the mantissa and some being the exponent.  There are still
ONLY 2^32 unique combinations!

This means that you only accurately represent 2^32 of the entire
range of floating point numbers.  This is not infinite range since most
standard formats limit it to something in the range of about
+/- E +/-128.  It's still much larger than 2^32.

If you're using a 64 bit machine the argument still holds.  Which
of the 2^64 numbers do you want to represent acurately?

smile,
Lynn



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

Date: 7 Feb 1997 15:55:51 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: DNS lookups in perl
Message-Id: <5dgbtn$s0v@nova.dimensional.com>

 [cc to author]

"Gregory I. Scher" <Gregory.Scher@sgw.com> writes:

 [48 lines of quoted text about Net::DNS omitted]

>Where can this DNS library be found?

Net::DNS and other useful modules can be found on the Comprehensive
Perl Archive Network (CPAN):

    http://www.perl.com/CPAN/modules/01modules.index.html

-- 
Michael Fuhr
http://www.dimensional.com/~mfuhr/


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

Date: 07 Feb 1997 18:07:35 -0500
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: environment variables
Message-Id: <x0d8uccj0o.fsf@tbone.biol.sc.edu>

Randal Schwartz <merlyn@stonehenge.com> writes:
> >>>>> "Nathan" == Nathan V Patwardhan <nvp@shore.net> writes:
> Nathan> L. Ted Nocella (tnocella@outland.cyberwar.com) wrote:
> Nathan> :: I'm trying to identify users' e-mail addresses when they post
> Nathan> :: a form which is processed by my perl script. 
> Nathan> Short answer: you can't, really.
> Nathan> Some servers support REMOTE_IDENT which I've been told is "reliable,"
> Nathan> but I have my doubts.
> 
> It's available only when the client's machine runs identd and you have
> ident checking enabled on your web server (which makes EVERYTHING much
> slower, so it's generally turned off).
> 
> Now, as to its reliability... hey, you gotta trust the root (or
> root-equiv) at the client's machine.  Anyone can run a hacked daemon
> on the identd port with sufficient priv's.

Hmmm... well, how about if I get hold of whatever email address ident
gives, or have the user type one in.  All I'd need to do then is
confirm that it's a valid email address to which delivery will
succeed.  Where can I find a pearl module to do that?

[Just kidding.  Really.  Reading Tom's... ah... postings today just
 got me on a roll...]

-Dean
-- 
N. Dean Pentcheff   <pentcheff@acm.org>   WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83  A0 BF CB C0 D1 0E 76 C0 
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"


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

Date: Fri, 7 Feb 1997 18:56:28 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: fcntl() in v4
Message-Id: <E58xy6.6zH@bcstec.ca.boeing.com>

In article <sasrmd.855270037@sas.com>, Bob Dixon <sasrmd@unx.sas.com> wrote:
 >   I'm somehow not getting all the pieces right.  In C, I do this:
 > 
 > 
 >         struct flock lock;
 > 
 >         lock.l_type = F_WRLCK;
 >         lock.l_start = 0;
 >         lock.l_whence = SEEK_SET;
 >         lock.l_len = 0;
 > 
 >         fcntl(fd, F_SETLKW, &lock);
 > 
 >   and it works.
 > 
 >   In perl, I'm doing this:
 > 
 > fcntl(OUTFILE, &F_SETLKW, 0) || die "fcntl failed";
 > 
 > and 
 > 
 > fcntl(OUTFILE, &F_SETLKW, &F_WRLCK) || die "fcntl failed";
 > 
 > and getting "fcntl failed" both ways.
 > 
 > Any suggestions?  I even tried reading the book, i.e. p. 144 of the
 > Camel book, and I'm still not getting the idea.
 > 

You'll need to pass a flock structure:


  use Fcntl;

  $lock = pack("s s l l s",&F_WRLCK,0,0,0,0);
  fcntl(OUTFILE, &F_SETLKW, $lock) || die "fcntl failed: $!";
  ....




HTH,

--
Charles DeRykus
ced@carios2.ca.boeing.com


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

Date: Fri, 07 Feb 1997 23:27:22 GMT
From: F.Postma@inter.NL.net (Frans Postma)
Subject: File::Find vs. find.pl
Message-Id: <32fbae69.9608114@news.Nl.net>

Hi there,

I'm having trouble using the module Find::File.

Problem is as follows; until recently we used the output of 
"find2pl / -xdev -print" in several scripts to create an index *per
filesystem*. 

Since find2pl still produces output for find.pl (although the pod's of
File::Find claim otherwise and we've just installed 5.003_23) we used
that.

We now want to use File::Find instead of find.pl and I ran into the
problem that I don't know how to get Find::File NOT to cross any
filesystems. 

We use perl5.003 on production-servers (can't put a beta perl version
on those) and the File::Find on those does a my($topdev) which
prevents a check like $dev eq $topdev in &wanted.  Had to copy the
File::Find module from 5.003_23 to those machines to get it working:(

Since the 5.003 File::Find had my($topdev) I assume that comparing
$topdev with $dev from a stat() in &wanted is not the 'proper' way to
do what I want?? (after all, it's only localized in _23 to make it
backward compatible, right?)
 
Anyway, the following questions remain:
1) What is the prefered method to prevent File::Find from crossing 
	file-systems? Or is the $dev eq $topdev in &wanted the 'right' way
	to do it, it works for now...(we don't use NFS)
2) Will find2pl be update to produce File::Find output



Frans Postma
	(fpostma@inter.nl.net)


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

Date: 7 Feb 1997 18:23:25 -0500
From: samant@badlands.cis.ohio-state.edu (swapna ganashyam samant)
Subject: Help: $| does not flush stream
Message-Id: <5dgdhdINNbda@badlands.cis.ohio-state.edu>
Keywords: $|, Hot pipes, flush stream, IPC

-------------Please reply to jmohan@lan.nsc.com--------------
Hi!

Problem: Run a program (SQL database querry, in this case) from a perl
script and communicate using some form of IPC from the Perl 4.0 script.

Approach: (Assuming sybperl and Perl 5.0 are not available and the 
           program to be run cannot be modified)

What I am trying to achieve is to send queries to this
interface program (isql) by opening it for reading as a pipe with its
input piped to from a UNIX pipe file and output piped to the perl
script which starts it. 

I have attached the script(+output) I wrote for doing this. The problem
I am having is that the output when writing to the UNIX pipe file
(which forms STDIN for the isql program) does not go through unless I
close the filehandle. I tried setting "select(QUERRY); $| = 1" but it
did not help. I also tried using "flush()" subroutine without success.
I do not want to close the Filehandle as that causes the other process
(isql) to terminate. 

Any kind of help with this is very appreciated. I am new to Perl, so
maybe I am just missing something obvious. If there is a better way of
doing this, please let me know.

Thanks,
Jitendra

PS: The following script uses "cat" instead of "isql" for testing the 
    concept. 

PPS: Please reply to jmohan@lan.nsc.com I am using a friend's account.

==============================================================
#!/usr/local/bin/perl

# mknod myPipe p
# ls -l myPipe
# prw-rw-r--  1 jmohan          0 Feb  7 13:51 myPipe

push(@INC, "/usr/local/lib/perl/");
require("flush.pl");

$pid = open(RESULT, "-|"); # Fork with output redirected to RESULT
 
defined($pid) || die "Fatal Error: Could not fork!\n";

if(!$pid) {      ############ CHILD ############
    exec "/bin/cat -u myPipe" || die "Fata Error: Can't exec process\n";
    exit 1; # Never reaches this point.
} else {         ############ PARENT ###########
    open(QUERY, ">myPipe") || die "Fata Error: Could not open myPipe\n";

#   &flush(QUERY);  # Flushes QUERY, supposedly!!!
    select(QUERY); $| = 1;

    print QUERY "select Name from hierarchy\n"; print QUERRY "go\n";

#   &flush(QUERY);  # Flushes QUERY, supposedly!!!
    select(STDOUT); $| = 0;

#   close(QUERY); # This causes the output to be written out and the 
   # following read works without problem.

    warn "Done writing!\n";
    @in = <RESULT>;  print "Result:\n", @in;
    close(RESULT);
    exit;
}
============================================================
Output:  (Hangs after "Done writing!)
 
dream:~/Perl> ./pipe.pl
Done writing!
^C
dream:~/Perl> 
=============================================================
Output: (With close(QUERY) uncommented)
 
dream:~/Perl> ./pipe.pl
Done writing!
Result:
select Name from hierarchy
go
dream:~/Perl> 






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

Date: Fri, 07 Feb 1997 21:42:50 GMT
From: MikeChang@aol.com
Subject: How MS Explorer And Navigator Handle CGI - Web Review
Message-Id: <32fba1cc.549127750@netnews.worldnet.att.net>


How MS Explorer And Navigator Handle CGI - Web Review 

Find this article at:

NewsLinx Daily Web News (2/7/97)

http://www.newslinx.com/


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

Date: 7 Feb 1997 20:57:37 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Inserting \n inside the string
Message-Id: <slrn5fn5lm.343.dave@fast.thomases.com>

On Fri, 07 Feb 1997 12:09:24 -0800, Vadim Parizher <Vadim.Parizher@jpl.nasa.gov> wrote:
> I have a very long perl-generated string separated by semicolons inside.
> 
> very:very:long:string
> 
> I need to insert a line break at about every 200 characters or less.  A
> line break can only be inserted right after a semicolon.
> 
> Does anybody knows how to do it *efficiently*?

I don't know aboutneffiently, but...

You could do it with a regex:

   $str =~ s/(.{190,}?;)/$1\n/g;

That's the shortest sequence of at least 190 characters followed by a
semi-colon, which gets replaced by itself followed by a newline.


On REALLY BIG STRINGS however, it might be better to split into a list and
then join, keeping track of the length.

Dave


-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: 7 Feb 1997 22:24:29 GMT
From: scotkris@aros.net (scott mcgrew)
Subject: need a simple script
Message-Id: <5dga2t$3fa@news.xmission.com>

could anyone tell me where to get a script that does the following.

takes form input and writes it to a txt file.

I want to update a java applet text ticker without going in and
writing the new data in notebook, ftp'ing etc.

it would be simpler to just go to a webpage and type it in.
but I don't write cgi.

anyone help?

scott
scotkris@aros.net



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

Date: Fri, 07 Feb 1997 16:15:12 -0500
From: Mark Peskin <mpeskin@mail.utexas.edu>
Subject: PERCEPS: The Perl C++ Surveyor, New Version 1.2 available
Message-Id: <32FB9B60.2781@mail.utexas.edu>

PERCEPS 
                       The Perl C++ Surveyor
                           Version 1.2

  PERCEPS is a Perl script designed to parse C++ header files and
automatically generate documentation in a variety of formats based on
the class definitions and comment information found in those files. 
This allows you to comment your code and generate useful documentation
at the same time with no extra effort. PERCEPS can be useful as a
documentation tool for C++ class libraries or as a simple but effective
collaboration tool for other projects.

  Unlike some other documentation generation systems, PERCEPS does not
produce a fixed output format.  Instead it uses "template" files that
can be freely modified to produce an almost unlimited variety of output.
The example template files included with the distribution produce html
( and now HotSauce/mcf )pages, but Tex, RTF, plain text, man page, or
other formats are also possible.  PERCEPS also includes a Class
Navigator java applet for use with html output.

  Version 1.2.0 is here.  This version contains several important
new features as well as numerous bug fixes.  You should definitely get
this new version.  PERCEPS now handles a MUCH broader range of syntax. 
Many thanks to Brad Stuart for pointing out most of the problems that
have been fixed in this version.


  If you're interested you can see PERCEPS at work and get a copy at

       http://friga.mer.utexas.edu/mark/perl/perceps.html

     ITS COMPLETELY FREE (no spam here), so go ahead & try it.

PERCEPS is a tool I wrote for my own use while developing a C++ Monte
Carlo simulation library, but I though other folks might find it useful.

Mark

__________________________________
Mark Peskin                              \_______   _______/
University of Texas @ Austin                   \ . . /
Electrical and Computer Engineering             \   /     Procrastinate
Microelectronics Research Center                |^ ^|         Now!!
http://friga.mer.utexas.edu/mark/                \_/


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

Date: 07 Feb 1997 22:51:27 +0100
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: perl HTTP proxy?
Message-Id: <hafpgi8tc.fsf@bergen.sn.no>

terry jones <terry@teclata.es> writes:

> Is there source available somewhere for a simple perl HTTP proxy? I'd
> be happy with any bare bones implementation, I just want to fiddle
> with what my browser sends and receives (cookies, images etc.) in the
> manner of WebFilter (http://www.math.ucsb.edu/~boldt/NoShit/) etc.

Take a look at Randal's implementation of an "anonymous proxy server in
100 lines of Perl".  It should be a good start.

  http://www.ics.uci.edu/pub/websoft/libwww-perl/archive/1996h2/0404.html

-- 
Gisle Aas <aas@sn.no>


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

Date: Fri, 07 Feb 1997 15:49:01 -0800
From: John Matylonek <matylonj@ccmail.orst.edu>
Subject: perl install problem
Message-Id: <32FBBF6D.655D@ccmail.orst.edu>

I'm running BSDI unix on a 486, using following Configure options for
the Dougherty distribution perl install. Using the following to create
the Configure.sh file:

sh Configure -des Dprefix=/gopher-nfs/perl

These options except the defaults and set up the perl in the noted
directory

I run make and get the follwing error and subsequent "stop"

ranlib: libperl.a Inappropriate file type or format **** Error code 1

I am running this installation program as root superuser and the program
did give me some warnings about 
having to use dots in filenames. I don't know whether this has to do
with the problem.

This is my first attempt at installing a unix program of any kind so
what may be perplexing to me may be obivious to you. Hope you can help
me.

John Matylonek
matylonj@ccmail.orst.edu


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

Date: 7 Feb 1997 23:03:55 GMT
From: "Mark Melchiorre" <markmelch@melchiorre.com>
Subject: Perl on local win95 system
Message-Id: <01bc154c$39c46000$3803d9cf@markmelch>

I have installed perl5 on my win95 system.

I can run scripts from the command line, but I when I try to invoke them
from an html document the browser treats it like a file download and just
give me the option to "save to disk" or "open." What do I need to do to
make them executable.

Thanks in advance.
-- 
Mark Melchiorre
markmelch@melchiorre.com
http://home.earthlink.net/~markmelch


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

Date: Fri, 07 Feb 1997 14:53:25 -0500
From: Jason Warner <jwarner@mitre.org>
Subject: Perl on SunOS 4.1.3
Message-Id: <32FB8835.41C67EA6@mitre.org>

To anyone who can help.

I am trying to compile perl5.002 on a SunOS 4.1.3 machine and it keeps
giving me this error:

ar rcu libperl.a perl.o malloc.o gv.o toke.o perly.o op.o regcomp.o
dump.o util.o mg.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o
pp_sys.o doop.o doio.o regexec.o taint.o deb.o globals.o 
gcc  -L/usr/local/lib -o miniperl miniperlmain.o libperl.a -lnsl -lgdbm
-ldbm -ldl -lm -lc -lposix 
/usr/local/gnu/ld: No such file or directory for libdl.a
collect2: ld returned 1 exit status
make: *** [miniperl] Error 1


everytime I try to make it. I have no idea what is going on. I also
tried to take out the references to libdl.a etc and that didn't make a
difference. 

If anyone out there has had a similiar problem or knows what I should
do, please post it here or email me at:

jwarner@xpletive.mitre.org

Thank you in advance,
Jason Warner


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

Date: 07 Feb 1997 18:17:08 -0500
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: Perl on SunOS 4.1.3
Message-Id: <x0bu9wcikr.fsf@tbone.biol.sc.edu>

Jason Warner <jwarner@mitre.org> writes:
> I am trying to compile perl5.002 on a SunOS 4.1.3 machine and it keeps
> giving me this error:
 ...
> /usr/local/gnu/ld: No such file or directory for libdl.a

I think (but this is not firm knowledge) that you may be missing a
library for dynamic linking.  You might try redoing the Perl configure
and specifying static linking for whichever modules you'd like to
include.  

-Dean
-- 
N. Dean Pentcheff   <pentcheff@acm.org>   WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83  A0 BF CB C0 D1 0E 76 C0 
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"


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

Date: 7 Feb 1997 20:40:03 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl vs Korn Shell
Message-Id: <5dg3v3$76b$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Dave Stagner 
<david_stagner@ncs.com>],
who wrote in article <32FB57F5.41C6@ncs.com>:
> Whether perl or korn shell is better depends largely on what you're
> doing.  Korn shell is much more effective as an interactive command line
> than perl.  :}

Hmm, apparently you did not use 
	perl -de 0
recently ;-). (Of course, this supposes that you installed either
T;:R::Perl or T::R::GNU.)

Ilya


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

Date: Fri, 07 Feb 1997 14:51:42 -0600
From: Nathan Wagner <nw@hydaspes.if.org>
Subject: Re: Perl vs Korn Shell
Message-Id: <32FB95DE.3E2D@hydaspes.if.org>

Abigail wrote:

> I agree perl is "better" than sed or awk. Yet I still use awk for
> two reasons:
> 
> - Sometimes awk is less typing (or less thinking) than perl.
>   I just can't beat "| awk '{print $2}'" in perl.

I suppose you realize this, but how about
| perl -pe '(split)[1]'

-- 
nathan wagner
nw@hydaspes.if.org


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

Date: 07 Feb 1997 11:24:54 -0800
From: Ali Corbin <ali@axian.com>
Subject: Re: Perl vs Korn Shell
Message-Id: <uohdw7721.fsf@co.intel.com>

kinge@oklahoma.net (Ed King) writes:

> 
> I'm at the point where I want to write some simple programs for my
> private use.  I bought the Bolsky book entitled "The New Korn Shell" and
> the author maintains the Korn shell is the greatest thing since sliced
> bread.  I want to know if Korn shell scripting or Perl is more
> versatile.  If I just want to invest time learning one which one should
> it be and why.

When I used ksh I had problems in moving my scripts from platform to
platform.  Every Unix box that we owned came with ksh, but unfortuneately
they didn't all come with the same version of ksh.  I had to dumb down the
scripts so they would work with the oldest shells. On the other hand, 
I could load the "correct" version of Perl on all of our platforms.

Ali


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

Date: Fri, 7 Feb 1997 14:30:24 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: regexps challenge - movies.txt (0/1)
Message-Id: <0d3gd5.hn.ln@localhost>

Abigail (abigail@ny.fnx.com) wrote:
: On Thu, 06 Feb 1997 20:50:57 GMT, Helen wrote in comp.lang.perl.misc:
: ++ I wish to pull the url's, links, and descripive text out of an html
: ++ page and place them in a colon delimited text file; like so:
: ++ 
: ++ www.byte.com:Byte Magazine:Cross-platform computer magazine:0
: ++ (the 0 needs to be on the end for later programming)
: ++ 
: ++ The code below will take out url's and their ensuing links, giving me
: ++ the following table:
: ++ www.byte.com:Byte Magazine: :0
: ++ 
: ++ But  ff I try to take out the descriptive text as well, I get nothing.
: ++ 
: ++ Any suggestion as to why this is happening would be greatly
: ++ appreciated.
: ++ 
: ++ I've attached the html document I'm trying to get this to work on.
: ++ 
: ++ __________________________________________________
: ++ 
: ++ #!/usr/bin/perl -w
: ++ 
: ++ #match url's     
: ++ $url = "http:\/\/(.+?)(?=\">)";                 
: ++ 
: ++ #match links between url and </a>
: ++ $link = "\">(.+?)(?=<\/a>)";
: ++  
: ++ #match descriptive text between</a> and next markup
: ++ #This one doesn't work!
: ++ $descr = "<\/a>\b(.*?)<";
:                   ^
:                   You want the \b to appear in your regex. However, 
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I see that her code showed that she wanted \b in there.

But, I suggest she may *not* want the \b in her regex.

For \b to match in must have a 'word character' (\w) on one side,
and a 'non-word character' (\W) on the other side.

Helen's regex already _has_ a non-word character on the left of the
\b (>).

So, the _only_ way this will match is if the character after the </a>
is a 'word character'. I expect she still _does_ want to match, even
if it is not a word character (like a space, see below).


:                   "" does variable substitution. This includes any
:                   \ processing. You are escaping the b from appearing
:                   special to "". What you need is to escape the \
:                   itself. Use one of:

: $descr = "</a>\\b(.*?)<";
: $descr = '</a>\b(.*?)<';

: And note that there is no reason to escape the /.


Try the script below. Which do you want it to do? The first or second
match?


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

$_ = '</a> what now?<p>another paragraph</p>';
#         ^ a space here


# with word boundary
$descr = '</a>\b(.*?)<';
print "descr '$descr'\n";  # print it to be sure

$matched = $1 if /$descr/;
print "'$matched'\n";


# withOUT word boundary
$descr = '</a>(.*?)<';
print "descr '$descr'\n";  # print it to be sure

$matched = $1 if /$descr/;
print "'$matched'\n";
-----------


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


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

Date: 7 Feb 1997 21:54:07 GMT
From: lynn@swcp.com (Lynn Wilson)
Subject: Removing extra spaces
Message-Id: <5dg89v$3ra@sloth.swcp.com>

I want to remove extra spaces in a piece of text as part of
a normalization process.  I know how to remove leading and
trailing spaces using seperate regular expressions.  How do
I remove a variable number of spaces embedded in the middle
of the text?

$input_text = "  big   long line     of text with leading+trailing+middle  ";

$output = "big long line of text with leading+trailing+middle";

I want to retain a single internal space where called for.

Is there a nice perlish way of doing this?

I'm going to use this as a key to an assocative array hoping to locate
duplicate records.  In reality the input strings will contain
business names (ie; "Sam's Club"  "Super Hardware Stores" );

Thanks.
Lynn@swcp.com



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

Date: Fri, 7 Feb 1997 12:40:44 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Joe Schulte <kirel@earth.execpc.com>
Subject: Re: Simple simple question
Message-Id: <Pine.GSO.3.95.970207123207.3726e-100000@linda.teleport.com>

On 7 Feb 1997, Joe Schulte wrote:

> I'm reading a number from a file. Only thing in the file is that number.
> No problem. Except when I use 'chop' to read it, it becomes a string. I
> want to now manipulate this as a number. How? 

Just Do It. If you use it as if it were a number, Lo! it IS a number. For
example... 

   $foo = "3.14159 is a string";
   $bar = 0 + $foo;	# $bar is a number.
   print "$bar\n";	# ...but it can become a string for output.
   $foo = 0 + $foo;	# Now $foo is a number, too.
   $foo += 0;		# An easier way to do that last line.
   print $foo, "\n";	# Yep, that's a number all right.

Note that -w should warn you when you do something as suspicious as
converting a string with trailing non-whitespace into a number. Hope this
helps! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Fri, 07 Feb 1997 16:52:50 -0500
From: Graham Bignell <bignell@netcom.ca>
Subject: Re: Variables in ?modules? or included files.
Message-Id: <32FBA432.795D@netcom.ca>

Graham Bignell wrote:
> 
> This question is being asked because I haven't really
> used the module functionality of Perl to any degree. (shame on
> me). Anyway:

	I solved the problem by defining the multi-line scalars 
as functions, thus of course, changing what they are and
how they behave, but anyway, if in the conf file something like:
----
sub foo {
"
Blah blah blah \
blah $foo blah \
blah $bar blah 
";
}
-----

I can just 

$foo = "12345"
print &foo;

Not exactly what I was looking for, but functionally it 
does the job.

---
Graham


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

Date: 7 Feb 1997 18:57:10 GMT
From: epaik@deans.umd.edu (Ellen Paik)
Subject: why can't "system" return a long?
Message-Id: <5dftu6$jv5@hecate.umd.edu>

Hello,

Can someone clarify what I need to do in order to get a call to a 
C program using the "system" function to return a value of type long?
Whenever the program returns an integer larger than type int, the 
return value gets messed up.

Thanks,

Ellen


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

Date: 7 Feb 1997 21:01:49 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: why can't "system" return a long?
Message-Id: <slrn5fn5tg.343.dave@fast.thomases.com>

On 7 Feb 1997 18:57:10 GMT, Ellen Paik <epaik@deans.umd.edu> wrote:
> Can someone clarify what I need to do in order to get a call to a 
> C program using the "system" function to return a value of type long?
> Whenever the program returns an integer larger than type int, the 
> return value gets messed up.

Because the exit status is defined to be an int:

    NAME
       exit - terminate the current process
       
       SYNOPSIS
              #include <unistd.h>
	      
	      void _exit(int status);

Your C compiler shouldn't have let you return a long - maybe you aren't
enforcing warnings or using prototypes?

Anyway, to get something else back to your Perl script you could always
write it to STDOUT and have Perl pick that up

     $ret_long = `system myprog`
     
 myprog.c:
 
       ....
       printf("%ld\n", some_status);
       ....
       
 Dave
 

-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: 7 Feb 1997 22:32:09 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: why can't "system" return a long?
Message-Id: <5dgah9$c1r@news-central.tiac.net>

In article <5dftu6$jv5@hecate.umd.edu>, Ellen Paik <epaik@deans.umd.edu> wrote:
>Hello,
>
>Can someone clarify what I need to do in order to get a call to a 
>C program using the "system" function to return a value of type long?
>Whenever the program returns an integer larger than type int, the 
>return value gets messed up.

On a traditional unix system you get to have 8 bits to return, so ints
bigger than 255 get truncated or otherwise mutilated.  This is because the
process which is collecting the return status uses a variant of wait which
uses 16 bits of an int as 2 8 bit fields the "high order" 8 bits are the
exit status from the program, and the low order 8 bits are used by the
operating system to let the process collecting the status know if a signal
killed the process.  You might see macros like these in the
/usr/include/sys/wait.h header for pulling apart the status returned from
wait (or some member of the wait family...)

#define WEXITSTATUS(stat)       ((int)(((stat)>>8)&0xFF))
#define WTERMSIG(stat)          ((int)((stat)&0x7F))
#define WSTOPSIG(stat)          ((int)(((stat)>>8)&0xFF))

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: 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 913
*************************************

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