[7967] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1592 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 6 22:07:39 1998

Date: Tue, 6 Jan 98 19:00:23 -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           Tue, 6 Jan 1998     Volume: 8 Number: 1592

Today's topics:
     .exe files on server <programmer@games.com>
     Re: Arrgghhhhh! There must be a simple solution to this (Cliff High)
     Re: Help on C++ extension <cxiong@internetMCI.com>
     Re: how I can extract n character in x position on a st <wtansill@erols.com>
     INNER JOIN in DBI::ODBC <igor@iprint.com>
     Re: Lexical scope and embedded subroutines. (Clay Irving)
     Re: Looking for way to download files to browsers using (William Byrd)
     Re: Looking for way to download files to browsers using (William Byrd)
     Re: Looking for way to download files to browsers using (Cliff High)
     Re: newbie question: install perl on solaris 2.5.1 <joseph@5sigma.com>
     ok what am I doing wrong? (Ted Fiedler)
     Re: ok what am I doing wrong? (Cliff High)
     Re: ok what am I doing wrong? <ebohlman@netcom.com>
     Re: ok what am I doing wrong? (Matthew Cravit)
     Re: ok what am I doing wrong? (Matthew Cravit)
     Re: Perl and Eggdrop (Martien Verbruggen)
     Re: Q: search matching "(" and ")" (Craig Berry)
     Re: Q: search matching "(" and ")" (Ilya Zakharevich)
     Re: Querying info from other server (Joshua J. Kugler)
     Re: redirection & perl <ebohlman@netcom.com>
     Re: Sorting on the xth position in a ascii file. (Joshua J. Kugler)
     Re: Sorting on the xth position in a ascii file. <ebohlman@netcom.com>
     Re: Storing A Text File Into A Variable -- How?? <ebohlman@netcom.com>
     Re: Tech writer lifts burden from programmers (Cliff High)
     Re: Testing for valid RegExps? <*@qz.to>
     Re: UNIX commands via FTP on a MACINTOSH -- HAY-ELP! (Avram Grumer)
     Would yo explain the Perl "pack" command to me? <dperdue@vec.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 6 Jan 1998 19:11:54 -0500
From: "programmer" <programmer@games.com>
Subject: .exe files on server
Message-Id: <34b2c94c.0@208.136.0.6>

can perl be used to make .exe files that can be placed
on a server instead of .pl or .cgi files? if perl doesn't do this, then what
does?




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

Date: 7 Jan 98 02:32:13 GMT
From: chigh@vallier.com (Cliff High)
Subject: Re: Arrgghhhhh! There must be a simple solution to this script error
Message-Id: <34b2e92d.0@poobah.olywa.net>

Try 

print NEWFILE "  <body bgcolor=\#B4BCCD text=\#000000 
link=\#000066 vlink=\#990000>\n";



In article <01bd1ad1$10f7bc40$13e288a8@PC83610221.kpt.emn.com>, 
bowens@eastman.com says...
>
>I think it's getting confused by the double-qoutes. Remove them from the
>bgcolor, etc. specifications (they really aren't necessary), or enclose the
>entire string in single quotes.
>-- 
>Blaine Owens
>bowens@eastman.com
>
>James Robshaw <james@NoSpamrobshaw.zynet.co.uk> wrote in article
><68trcv$fj2$1@sol.zynet.net>...
>Can anyone please point me in the right direction.
>
>I have a perl script that works fine until I try to edit this particular
>line from 
>
>print NEWFILE "  <body >\n";
>
>into
>
>print NEWFILE "  <body bgcolor="#B4BCCD" text="#000000" link="#000066"
>vlink="#990000">\n";
>
>Is it the repetition of the "#" that causes the error?
>Can I place a default character in front of the # to prevent the error?
>
>The script doesn't actually generate an error code, I just get the default
>Server Error 500.
>
>I have tried a couple of things, but none have worked. I'm going potty,
>especially as at the moment, I can only test the script on-line.
>
>All suggestions gratefully received.
>
>James.
>
>
>james@NOSPAMrobshaw.zynet.co.uk
>
>----------
>



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

Date: Wed, 07 Jan 1998 01:56:32 GMT
From: Chuyu Xiong <cxiong@internetMCI.com>
Subject: Re: Help on C++ extension
Message-Id: <34B2E197.755D@internetMCI.com>

I just posted this to comp.lang.perl. I forgot comp.lang.perl.misc.
So, here goes. 
> 
> We have a large C++ library. I want to build some perl objects
> to drive those C++ objects. Perl has XS utilities, which is
> helpful. But, if in the library there are some static C++ classes,
> then, I can noly get segment fault.
> 
> I think this is a quite foundamental problem: since perl is compiled
> by C compiler, it has no way to handle static C++ classes, so do any
> extensions of perl. Maybe I am wrong. So, how can I get around this
> problem? Of course, I can consider to get rid of all static C++ classes,
> which is very hard (cout, for example, needs static classes), or, I
> can consider to compile perl by using CC (can I do it?). These are
> not good solutions. Any help?
> 
> Please email me a copy of your post to cxiong@internetmci.com. 
> Thanks a lot.


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

Date: Tue, 06 Jan 1998 19:19:45 -0500
From: "William B. Tansill, III" <wtansill@erols.com>
Subject: Re: how I can extract n character in x position on a string?
Message-Id: <34B2CA21.5980@erols.com>

Claudio Villa Santa wrote:
> 
> Hi all;
> 
> I have a little problem:
> 
> I need a function like visualbasic 'mid'.
> 
> I'll need to extract n character in x position on a string.
> 
> For example:  "this is string" I need "str"  n=3 x=8.
> 
> And how I can now number of string? (visualbasic function 'len')
> 
> Tanks
> 
> Claudio

1) $x = substr( <string>, <starting pos>, <length> );
2) length();
-- 

How do I set my laser printer to "stun"?


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

Date: Tue, 06 Jan 1998 15:06:21 +0000
From: igor <igor@iprint.com>
Subject: INNER JOIN in DBI::ODBC
Message-Id: <34B2486D.90B@iprint.com>

I have two quries:

1. SELECT ProductID
FROM Product, Size
WHERE Product.ProductID = Size.ProductID AND Product.Product = 'some
product' 

2. SELECT ProductID
FROM Product INNER JOIN Size ON Product.ProductID = Size.ProductID
WHERE Product.Product = 'some product' 

They both work and return the same result if I paste them in MA Access
or MS SQL server, also both work from the code if I use Win32::ODBC.
But, If I use DBI with DBD::ODBC, the second one (with INNER JOIN) is
failing in $sth->execute().

The error is:  [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect
syntax near the keyword 'SET'. (SQL-37000)(DBD:
dbd_describe/SQLNumResultCols err=-1)
What keyword 'SET' is it talking about?!

Did anybody have the same problem? My guess DBI::ODBC driver for DBI
does not understand INNER JOIN but isn't it the same driver with the one
Win32::ODBC is using?

Thank you. 
Igor


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

Date: 6 Jan 1998 20:30:56 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Lexical scope and embedded subroutines.
Message-Id: <68ulsg$amo@panix.com>

In <68tj81$da9$1@news.pop-stuttgart.de> "Ronald G\"oggel" <r.goeggel@atos-group.de> writes:

>>    What_is_the_temp($temp);

>Here you'd better use
>    &What_is_the_temp($temp);

Just out of curiousity - Why? perlsub indicates:

  To call subroutines: 

    NAME(LIST);    # & is optional with parentheses.
    NAME LIST;     # Parentheses optional if pre-declared/imported.
    &NAME;         # Passes current @_ to subroutine.

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: Wed, 07 Jan 1998 02:37:20 GMT
From: wcb4@erols.com (William Byrd)
Subject: Re: Looking for way to download files to browsers using PERL
Message-Id: <68ujs5$79b$1@winter.news.erols.com>

On 6 Jan 1998 22:07:54 GMT, "Juan Vega" <juan@vibrant.com> wrote:

>Folks,
>
>I am trying to execute a download in my PERL script and cannot find the
>method for doing so. This seems like a relatively simple task to me...is
>it?
>
>The desired result is:
>1) User fills in html form in favorite browser and posts it to CGI script
>(no problem)
>2) CGI script parses information and writes to database (no problem)
>3) CGI script sends *.exe to browser such that browser asks user where file
>should be saved (big problem - I am lost)

have your perl script do something like (an I amnot an expert, so I
hope I am pointing you right)

&sendfile # to call the routine to send the file


sub sendfile {
    print "application/octet-stream\n\n"; #header for executable files
    open (file,"filnemae.exe");
    while <file> {
        print $_;
    }
}
close(file);



this may work. I know the content heder is correct for an exe file (as
per apache's mime.type configuration file)





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

Date: Wed, 07 Jan 1998 02:40:55 GMT
From: wcb4@erols.com (William Byrd)
Subject: Re: Looking for way to download files to browsers using PERL
Message-Id: <68uk2s$79b$2@winter.news.erols.com>


>&sendfile # to call the routine to send the file
should be &sendfile; (forgot the semi)
>
>
>sub sendfile {
>    print "application/octet-stream\n\n"; #header for executable files
	should read print "Content: application/............" forgot
an important part there.
>    open (file,"filnemae.exe");
>    while <file> {
>        print $_;
>    }
>}
>close(file);
>
>
>
>this may work. I know the content heder is correct for an exe file (as
>per apache's mime.type configuration file)
>
>
>




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

Date: 7 Jan 98 01:37:42 GMT
From: chigh@vallier.com (Cliff High)
Subject: Re: Looking for way to download files to browsers using PERL
Message-Id: <34b2dc66.0@poobah.olywa.net>

There are several ways to get this to occur (like you thought that there was 
only ONE way to do anything in perl). One method is to use the return value 
from the CGI script to return URI which was an ftp point. THis will trigger 
the desired response. Alternatively, the CGI could return some form of dynamic 
html page in which was a URL which was the desired *.exe. And then there are 
the new http terminology including the chunked encode function. It will depend 
on the browser and which version(s) of http is being supported. 

Have a look at hetmons treatment of the subject at:
http://www.manning.com/Hetmon/311.html

It is the best reference that I have found to this moving target. 

Cliff
Tenax Software Engineering
chigh@vallier.com
360.866.1686

ultimate http reference at: http://www.manning.com/Hethmon/311.html

Vortex is at http://www.halcyon.com/chigh/vortex.html
Cornix can be found at http://www.halcyon.com/chigh/cornix.html
Another Cornix demo is available at http://www.halcyon.com/chigh/corndemo.html

Screwy Ideas and other press releases are at: 
http://www.halcyon.com/chigh/press.html

-----------------------------------------------------------------------
One must learn by doing the thing;
for though you think that you know it
you have no certainty, until you try.

	Sophocles, c. 496-406 b.c.
	Greek playwright and thinker
		Trachiniae
------------------------------------------------------------------------

In article <01bd1aee$9064b6a0$4b3d61c7@hercules.vibrant>, juan@vibrant.com 
says...
>
>Folks,
>
>I am trying to execute a download in my PERL script and cannot find the
>method for doing so. This seems like a relatively simple task to me...is
>it?
>
>The desired result is:
>1) User fills in html form in favorite browser and posts it to CGI script
>(no problem)
>2) CGI script parses information and writes to database (no problem)
>3) CGI script sends *.exe to browser such that browser asks user where file
>should be saved (big problem - I am lost)
>4) CGI script send email to user with password for unlocking *.exe file (no
>problem)
>
>I have looked everywhere (Llama, net, Matt's place, etc.) and have found no
>relief. Granted I am new at this PERL stuff but sending a file to a browser
>ought to be easy enough. Please help!!!
>
>Many thanks,
>Juan
>
>-- 
>
>Juan Vega
>juan@vibrant.com



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

Date: Tue, 06 Jan 1998 19:37:08 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: newbie question: install perl on solaris 2.5.1
Message-Id: <34B2EA3F.A72B4FCF@5sigma.com>

It hangs, there, right?  It's not waiting for you to press
enter???

	-joseph

Achim Selz wrote:
> You may give one or more space-separated answers, or "none" if
> appropriate.
> If your OS version has no hints, DO NOT give a wrong version -- say
> "none".
> 
> Which of these apply, if any? [solaris_2]
> ------- snap -------
> 
> Does anyone have an idea why Configure hangs here? I can abort with ^C,
> but I'd rather continue the installation.


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

Date: 7 Jan 1998 00:40:56 GMT
From: budo@news.ncx.com (Ted Fiedler)
Subject: ok what am I doing wrong?
Message-Id: <FA99810F302ED63A.33A867AEB7F40B38.D55FC4416CE9C986@library-proxy.airnews.net>


ok why does this return 2 dirs and 1 file?? if I change the line $name(@name)
to while ($name(@name)) {
and include all in the while block down to right before right i get the correct
response otherwise i get crap... also i seem to need to be in this dir
/home/budo/perl for it to work??? anyone know why this is???

#!/usr/bin/perl -w

use strict;
my (
	@name,
	$name,
	$directory,
	$file_1,
);
 
opendir (BUDO, "/home/budo/perl") || die "cannot open directory: $!";
@name = readdir(BUDO); 
foreach $name(@name) {
	if (-d $name) {
		$directory++;
	}
	if (-f $name) {
		$file_1++;
	}
}
write;
closedir(BUDO);
format STDOUT =
there are @<<< directories and @<<< files
$directory, $file_1
 .


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

Date: 7 Jan 98 01:25:41 GMT
From: chigh@vallier.com (Cliff High)
Subject: Re: ok what am I doing wrong?
Message-Id: <34b2d995.0@poobah.olywa.net>

It is not wise programming practice in any language to give the 
compiler/interpreter variable name ambiguity with which to cope. You create an 
array (list) variable by the name of @name. Which within accepted perl 
practice could yield single scalular values by instructing it to return those 
as in:

$single_filename = $name(1);
WHat we are doing is to instruct perl that we want the data from the array at 
that position which we wish to see as a scalular value ($) rather than a list 
(@). 

Only you already have $name assigned. 

Cliff
Tenax Software Engineering
chigh@vallier.com
360.866.1686

ultimate http reference at: http://www.manning.com/Hethmon/311.html

Vortex is at http://www.halcyon.com/chigh/vortex.html
Cornix can be found at http://www.halcyon.com/chigh/cornix.html
Another Cornix demo is available at http://www.halcyon.com/chigh/corndemo.html

Screwy Ideas and other press releases are at: 
http://www.halcyon.com/chigh/press.html

-----------------------------------------------------------------------
One must learn by doing the thing;
for though you think that you know it
you have no certainty, until you try.

	Sophocles, c. 496-406 b.c.
	Greek playwright and thinker
		Trachiniae
------------------------------------------------------------------------

In article 
<FA99810F302ED63A.33A867AEB7F40B38.D55FC4416CE9C986@library-proxy.airnews.net>
, budo@news.ncx.com says...
>
>
>ok why does this return 2 dirs and 1 file?? if I change the line $name(@name)
>to while ($name(@name)) {
>and include all in the while block down to right before right i get the 
correct
>response otherwise i get crap... also i seem to need to be in this dir
>/home/budo/perl for it to work??? anyone know why this is???
>
>#!/usr/bin/perl -w
>
>use strict;
>my (
>        @name,
>        $name,
>        $directory,
>        $file_1,
>);
> 
>opendir (BUDO, "/home/budo/perl") || die "cannot open directory: $!";
>@name = readdir(BUDO); 
>foreach $name(@name) {
>        if (-d $name) {
>                $directory++;
>        }
>        if (-f $name) {
>                $file_1++;
>        }
>}
>write;
>closedir(BUDO);
>format STDOUT =
>there are @<<< directories and @<<< files
>$directory, $file_1
>.



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

Date: Wed, 7 Jan 1998 01:22:15 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: ok what am I doing wrong?
Message-Id: <ebohlmanEME3t3.n1u@netcom.com>

Ted Fiedler <budo@news.ncx.com> wrote:

: ok why does this return 2 dirs and 1 file?? if I change the line $name(@name)
: to while ($name(@name)) {
: and include all in the while block down to right before right i get the correct
: response otherwise i get crap... also i seem to need to be in this dir
: /home/budo/perl for it to work??? anyone know why this is???

[snip]

: opendir (BUDO, "/home/budo/perl") || die "cannot open directory: $!";
: @name = readdir(BUDO); 

At this point @name will contain all the file names and directory names 
in /home/budo/perl.  They will *not* be complete path names; if there's a 
file called /home/budo/perl/hello, one of the entries in @name will 
contain "hello."

: foreach $name(@name) {
: 	if (-d $name) {

Now let's suppose that $name has been set to "hello."  The test will be 
the same as
  if (-d "hello") {
which will test whether the name "hello" *in your working directory* is 
the name of a directory.  The -d operator has no way of knowing that you 
really want to test a name in some other directory.

: 		$directory++;
: 	}
: 	if (-f $name) {

Same here.

: 		$file_1++;
: 	}
: }

The moral of the story is that if you use readdir() to get a list of 
filenames in a directory other than your working directory, you need to 
prefix them with the path to that directory if you want to test them, 
open them, etc.



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

Date: 6 Jan 1998 17:53:49 -0800
From: mcravit@best.com (Matthew Cravit)
Subject: Re: ok what am I doing wrong?
Message-Id: <68un7d$qcd$1@shell3.ba.best.com>

In article <FA99810F302ED63A.33A867AEB7F40B38.D55FC4416CE9C986@library-proxy.airnews.net>,
Ted Fiedler <budo@news.ncx.com> wrote:
>
>ok why does this return 2 dirs and 1 file?? 

Well, without telling us what you expect it to return, you've made things
harder, but I can conjecture where you're getting confused. readdir returns
_all_ of the things in the directory. This includes the directories "." and
"..", which is where the 2 directories are coming from. If you want to filter
those out, you could put 

    next if $name eq ".." or $name eq ".";

at the top of your foreach loop.


>response otherwise i get crap... also i seem to need to be in this dir
>/home/budo/perl for it to work??? anyone know why this is???

Yes. See my comemnts below.

>my (
>	@name,
>	$name,

This is a bad idea, in this case. Creating a scalar variable and an array
variable with the same name, while legal, is confusing. Unless you have a
very good reason to do so, you should probably avoid doing this. This is
especially true in your case, since the $name variable is unnecessary as
you've used it. See below.

>foreach $name(@name) {

Since foreach uses $_ as its default, you should probably just say

foreach (@name) {

and then use $_ in your tests. Also, naming a variable which is an array
using a name which suggests the singular (@name) is probably a bad idea, as
it makes your code very confusing. It's probably more readable to call this
array @names, rather than @name.

>	if (-d $name) {

If you'd printed out the contents of $name at this point, you'd have found
out what your problem is. readdir returns only the name of the files and
directories it finds. It does not return their absolute path. So, if 
/home/budo/perl contains the file 'blarg', and you run the script from
/home/budo, then at the point the above line is reached, the contents of
$name is 'blarg', and your file test checks for the existance of the file
/home/budo/blarg. What you probably should do is to put the name of the
directory you're passing to readdir in a variable. Let's call it "$whichdir",
for example.

Then, you'd invoke readdir like this:

     @names = readdir $whichdir;

And your file test operations would look like this:

    if ( -d "$whichdir/$name" ) {
        $directory++;
    }

and so forth.

>		$file_1++;

It's also usually a bad idea, for readability reasons, to use numbers in the
names of variables. If you have variables called $file_1, $file_2, etc., and
they're used for similar purposes, it's probably time to think about using
an array.

You _can_ do this, but you should try to think about writing your code in
the most readable possible way, and that isn't it.

>write;
>closedir(BUDO);
>format STDOUT =

Another readability thing here. It's usually a good idea to put the format
that a write will use somewhere before the write, rather than after it. 
This becomes more important in large programs. Imagine if you had a line in
your code like

write BLARG;

and the format for the BLARG file handle was declared 2000 lines later, or in
a separate file (in a module, for example). That would dramatically complicate
debugging. So, although the format _can_ come after the write which uses it,
it's probably not a good idea.

Hope this helps.

/MC

-- 
Matthew Cravit, N9VWG               | Experience is what allows you to
E-mail: mcravit@best.com (home)     | recognize a mistake the second
        mcravit@taos.com (work)     | time you make it.


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

Date: 6 Jan 1998 18:03:19 -0800
From: mcravit@best.com (Matthew Cravit)
Subject: Re: ok what am I doing wrong?
Message-Id: <68unp7$123$1@shell3.ba.best.com>

In article <34b2d995.0@poobah.olywa.net>, Cliff High <chigh@vallier.com> wrote:

>compiler/interpreter variable name ambiguity with which to cope. You create an 

That's why values in perl have prefixes - to remove the ambiguity. There's
in fact no ambiguity where you indicate; @name is always an array context,
and $name is always a scalar context. ($name could also be an object, but 
that's a separate problem). There is an ambiguity to the reader of the code
in that @name is singular but refers to a value that is plural, but Perl has
no problem with that. It's only a bad idea (as I pointed out in my other
post in this thread) for readability purposes for the humans maintaining the
code.

>practice could yield single scalular values by instructing it to return those 

s/scalular/scalar/g;

>$single_filename = $name(1);

Close, but this is not quite right. What you're trying to say here is:

    $single_filename = $name[1];

The line as you give it above produces a syntax error in Perl.

>Only you already have $name assigned. 

Again, apart from the ambiguity to the reader, this is not a problem. In
fact, there's nothing whatsoever wrong with the following, except that it's
confusing to people trying to read your code:

    $foo = 1;
    @foo = (1,2,3);
    %foo = ( a => 1, b => 2, c => 3, );
    sub foo { print "Foo!\n"; }

    print $foo, "\n";
    print join(" ", @foo), "\n";
    print join(" ", keys %foo), "\n";
    foo();

It's poor programming practice because it's confusing to the reader, but
Perl has no problem with it.

/MC

-- 
Matthew Cravit, N9VWG               | Experience is what allows you to
E-mail: mcravit@best.com (home)     | recognize a mistake the second
        mcravit@taos.com (work)     | time you make it.


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

Date: 7 Jan 1998 01:55:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl and Eggdrop
Message-Id: <68unb7$9m0$1@comdyn.comdyn.com.au>

In article <34b2c1e7.3013247@roadrunner.micro-net.com>,
	peazant@internetaddress.com (Peazant) writes:
> Can Perl be used to made Eggdrop scripts with any amount of ease?

eggdrop? As in the IRC eggdrop bot? Isn't that thing written in c and
tcl?

> If you know how do do this, or you know a resource I could use to find
> more info, I'd appreciate it. 

Maybe you should ask on a group where they know about IRC bots, or
look in the eggdrop documentation. You could of course do a search on
Altavista and/or dejanews for 'eggdrop'.

-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


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

Date: 6 Jan 1998 23:58:37 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Q: search matching "(" and ")"
Message-Id: <68ugfd$4kl$1@marina.cinenet.net>

Hu_Yi_Kwang (ykhu@mtk.com.tw) wrote:
: My input file is something like:
:    ( A1 ....
:         (B2 ...
:               (C3 ....
:                 other text, may contain "(" and ")" pairs.
:               )
:          )
:     )
: 
: Q: How can I  easily find  the matching parir for "(" and ")" for A1?

You can't do it 'easily' (at least accordning to my own 'easiness' 
metric).  Just to save you some pointless hacking, you can't do it for 
arbitrary levels of nesting using regexes, and even doing it for a fixed 
nesting-depth limit greater than 2 or so is pointlessly hard and 
error-prone.

What you really need here is a parser.  Its complexity depends on the
complexity of the text and what you need to do with it.  In the simplest 
case, you can just track paren-nesting level (especially if they're one per 
line, as you've shown).  Add one for each (, subtract one for each ), 
start when you find "(A1", stop when level reaches zero.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 7 Jan 1998 00:49:34 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Q: search matching "(" and ")"
Message-Id: <68ujeu$msi$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Craig Berry
<cberry@cinenet.net>],
who wrote in article <68ugfd$4kl$1@marina.cinenet.net>:
> : Q: How can I  easily find  the matching parir for "(" and ")" for A1?
> 
> You can't do it 'easily' (at least accordning to my own 'easiness' 
> metric).  Just to save you some pointless hacking, you can't do it for 
> arbitrary levels of nesting using regexes

Yes you can with the latest RE engine, one of the tests in t/op/pat.t
is doing exactly this.  But this is still not "easily" - though very
quick.  To make it "easy" several other changes to RE engine should
materialize first.

Ilya


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

Date: Wed, 07 Jan 1998 00:51:52 GMT
From: jkugler@inreach.com (Joshua J. Kugler)
Subject: Re: Querying info from other server
Message-Id: <34b2d17c.24857187@news.inreach.com>

On Tue, 06 Jan 1998 16:44:03 GMT, !pbuckley@tiac.net (Phil Buckley)
wrote:

()How would I go about querying stock prices from Yahoo or another
()similar repository of stock info?

Look in CPAN for the libwww or LWP modules and retrieve them via HTTP.

()remove the "!" before replying via e-mail

Remove the "!" before posting.

j----- k-----

I read this group. Sometimes my ISP doesn't. Please e-mail too.

Joshua J. Kugler
Computer Consultant--Web Developer
jkugler@inreach.com
http://www.cwebpages.com/jkugler
Every knee shall bow, and every tongue confess, in heaven, on earth, and under the earth, that Jesus Christ is LORD -- Count on it!



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

Date: Wed, 7 Jan 1998 01:00:43 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: redirection & perl
Message-Id: <ebohlmanEME2t7.Lt5@netcom.com>

Neil Trenholm <webmaster@createyourweb.com> wrote:

: My problem:
: -----------
: I am using perl to redirect users using 

:      print "location:$url\n\n" 

: and get a 302-Temporarily moved. 

: My Questions:
: -------------
: What is a 302 and why do I get it ? 
: Does this mean redirection is not allowed on my server ?

[this isn't really a Perl question, so you should ask any further 
questions of this sort in comp.infosystems.www.authoring.cgi]

Most HTTP servers are set up to return a 302 status in response to a GET 
for a URL if the first header in the resource is a Location: header.  A 
properly-configured browser will take a 302 as an indication that it 
should go to the URL specified in the Location: header.  In other words, 
your redirection is working properly at the server end.



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

Date: Wed, 07 Jan 1998 00:58:34 GMT
From: jkugler@inreach.com (Joshua J. Kugler)
Subject: Re: Sorting on the xth position in a ascii file.
Message-Id: <34b2d31f.25275935@news.inreach.com>

On Tue, 6 Jan 1998 21:38:46 +0100, "Jan Van den heuvel"
<jan@skynet.be> wrote:

()I need to sort a large file starting with the 15 th position.
()What do I use ?
()
()Jan

On the line?

substr($var, 14,,)

15th line?

@arr=(<FILE>)

Then check $arr[14]

j----- k-----


I read this group. Sometimes my ISP doesn't. Please e-mail too.

Joshua J. Kugler
Computer Consultant--Web Developer
jkugler@inreach.com
http://www.cwebpages.com/jkugler
Every knee shall bow, and every tongue confess, in heaven, on earth, and under the earth, that Jesus Christ is LORD -- Count on it!



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

Date: Wed, 7 Jan 1998 00:55:46 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Sorting on the xth position in a ascii file.
Message-Id: <ebohlmanEME2Ky.LF8@netcom.com>

Jan Van den heuvel <jan@skynet.be> wrote:
: I need to sort a large file starting with the 15 th position.
: What do I use ?

The Perl FAQ (which should have come with your distribution; if not, go 
over to <http://www.perl.com>) has a section on sorting data based on 
subfields, complete with example code.



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

Date: Wed, 7 Jan 1998 01:12:45 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Storing A Text File Into A Variable -- How??
Message-Id: <ebohlmanEME3D9.MI0@netcom.com>

Tony K. Olsen <tkolsen@btinternet.com> wrote:
: 	while (<IP>) {
: 		print;
: 	}

: 	this works fine and displays it to the screen.  What I would like 
: is something along these lines:

: 	while (<IP>) {
: 		chop;
: 		$var = $_;
: 	}

: 	Then I could generate a perl file using the $var like such to 
: display the comments already written to the file:


: <TEXTAREA NAME="textdata" ROWS=15 COLS=69>
: $var
: </TEXTAREA>

You don't need to store the text in a variable if I understand you right, 
all you need to do is something like:

print OUTFILE qq(<TEXTAREA NAME="textdata" ROWS=15 COLS=69>\n);
while (<IP>) {
    print OUTFILE $_;
}
print OUTFILE qq(</TEXTAREA>\n);

This assumes that OUTFILE is a handle that's previously been opened for 
output.  If this is a CGI script, just take out OUTFILE since you want 
the output to go to STDOUT.

Note the use of qq() to allow a \n in a string that contains embedded 
double-quotes, and the absence of a chop() on the lines read in from the 
file.





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

Date: 7 Jan 98 02:01:33 GMT
From: chigh@vallier.com (Cliff High)
Subject: Re: Tech writer lifts burden from programmers
Message-Id: <34b2e1fd.0@poobah.olywa.net>

In article <68u4nd$7k$1@mainsrv.main.nc.us>, scott@softbase.com says...
>
>Eric D. Friedman (friedman@uci.edu) wrote:
>
>> I'd be pretty reluctant to engage a writer who can't differentiate
>> between "that" and "who."
>
>> One style guide I've got lying around says, "who refers to people, and
>> that and which refer to animals and things.  That may also be used to
>> refer to an anonymous group of people."
>
>This issue, like the command not to ever split infinitives, is mostly
>something invented by style guide writers that wanted more stuff to pad
>out their books. There's no particular reason for it. "That" can
>apply to people as well, and often sounds more natural.
>
>Scott
>--
Bullshit. That is not used in refering to people or other 'personified' 
elements 
within the writing. Your simplistic view that the that use rules originate 
with style 
guide authors betrays a lack of understanding of the grammar of the english 
language. 
That attitude (please note that we are not elevating the attitude to the state 
of 
humanity) also shows little understanding of the derivation of language and 
the 
influences upon it. 

Much of the grammar of the English language was influenced by the german and 
french 
from which it is crafted. As these languages often had the heavy hand of 
religious 
authoities shaping their development we find that (note that we are 
discovering a 
thing not a person) the view prevailing in the language is that anything (note 
that 
anything is a thing, in abstract) thought to have a 'soul' or to be possessed 
of 
'anima' which is to say, life,  cannot properly be referenced with 'that'. 
Those 
things thought to be without such can quite properly be called, 'that'. 

Of course, any Thing, regardless of abstraction or questions of anima, which 
is 
personified, which is to say, any Thing, raised to the level of human or 
considered to 
be alive, even conceptually or completely abstracted from its natual place no 
matter 
how low, must be referred to as who. 

Of course my judgement of your knowledge of the English language as being 
truely abysmal might be misplaced. All indications are that it is not your 
mother tongue. If the clues of professed ignorance are correct, then I 
apologize. English possesses a terrible learning curve for the new initiate. 
Welcome to America.
Cliff
Tenax Software Engineering
chigh@vallier.com
360.866.1686

ultimate http reference at: http://www.manning.com/Hethmon/311.html

Vortex is at http://www.halcyon.com/chigh/vortex.html
Cornix can be found at http://www.halcyon.com/chigh/cornix.html
Another Cornix demo is available at http://www.halcyon.com/chigh/corndemo.html

Screwy Ideas and other press releases are at: 
http://www.halcyon.com/chigh/press.html

-----------------------------------------------------------------------
One must learn by doing the thing;
for though you think that you know it
you have no certainty, until you try.

	Sophocles, c. 496-406 b.c.
	Greek playwright and thinker
		Trachiniae
------------------------------------------------------------------------



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

Date: 7 Jan 1998 00:03:36 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Testing for valid RegExps?
Message-Id: <qz$9801061848@qz.little-neck.ny.us>

Mark Hazen  <mhazen@franklin.uga.edu> wrote:
> Hi folks... please respond both via email and this group, if possible.

Posted and mailed.

> I'm looking for a way, in Perl, to test the validity of a regexp given by
> the user. I didn't find any such module on CPAN, but I'd really love to
> know if there's a way within Perl to do this without having to load
> another module (or with loading one of the standard modules).

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

$regexp=<STDIN>;
chomp $regexp;
$_="";

$result=eval '/$regexp/';

if (defined($result)) {
	print "Regexp is legal\n"
} else {
	print "Regexp is bad: $@\n"
}
__END__

:r! echo "**BAD**" | perl -x %
Regexp is bad: /**BAD**/: ?+*{} follows nothing in regexp at (eval 1) line 1,
<STDIN> chunk 1.

:r! echo "U*G*L*Y*" | perl -x %
Regexp is legal

Elijah
------
thinks he is going to be using -x a lot more in Usenet posts


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

Date: Tue, 06 Jan 1998 20:39:27 -0500
From: avram@interport.net (Avram Grumer)
Subject: Re: UNIX commands via FTP on a MACINTOSH -- HAY-ELP!
Message-Id: <avram-0601982039280001@avram.port.net>

In article <sean-0601981701050001@p5.ts1.white.ny.tiac.com>, sean@dcdX.net
(Sean O'Dwyer) wrote:

> I need to be able to set executability of scripts in my cgi-bin, using
> commands like chmod, but I can't do that using Anarchie or Fetch (that I
> know of).
> 
> Is there a way to do this from my Mac?

I've seen something called "Anarchist's Cookbook" that's supposed to let
MacPerl control Anarchie, but I've just done an AltaVista search and
failed to turn it up.  I'm being vague about exactly what it was because I
never used it and so don't remember any details.  

Something that did turn up in my search is Mac::Apps::Anarchie, a MacPerl
interface to Anarchie, at <http://pudge.net/macperl/anarchie/>.  

If you're not wedded to the idea of using MacPerl for this task, you could
try scripting your FTP client with AppleScript or Frontier
<http://www.scripting.com/frontier/>, but I shouldn't talk about things
like that in this group.
--
Avram Grumer  *  avram@interport.net  *  Finger for public key
http://www.users.interport.net/~avram/
Give a man a fish, and you feed him for a day. 
Teach him how to fish, and you can sell him equipment.


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

Date: Tue, 06 Jan 1998 19:08:59 -0500
From: David <dperdue@vec.net>
Subject: Would yo explain the Perl "pack" command to me?
Message-Id: <34B2C79B.5ABFB4D2@vec.net>

Hi, 

The subject line says it all. I don't no exactly what the pack command
does.
I don't konw when it might be used. I don't understand what the
templates are telling the program.
I read the man page, but still I don't get it. I an reading the llama
book and have gone thru it a number of times. This seems to be the only
area that I can't grasp.  I appreciate any insight that you can provide.
Thanks.

--dp


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

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

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