[22708] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4929 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 3 03:05:46 2003

Date: Sat, 3 May 2003 00:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 3 May 2003     Volume: 10 Number: 4929

Today's topics:
    Re: Forms structure <flavell@mail.cern.ch>
    Re: Forms structure <spamtrap@nowhere.com>
    Re: Forms structure <spamtrap@nowhere.com>
    Re: Forms structure (Sam Holden)
        haiku <serge.john.swilting@wanadoo.fr>
    Re: Help: Save Search Terms in an Array? (Tad McClellan)
    Re: Is it possible to pass @somethig and $something_els <michael.p.broida@boeing.com>
    Re: Is it possible to pass @somethig and $something_els <tassilo.parseval@rwth-aachen.de>
    Re: Is there any way to debug PerlScript used in ASP? <usenet@dwall.fastmail.fm>
    Re: locating module NetCDF <kalinabears@hdc.com.au>
        Perl CGI on Windows XP <danmurph@att.net>
    Re: Perl CGI on Windows XP <priede@panix.com>
    Re: Perl Editor : Whats Recommended <REMOVEsdnCAPS@comcast.net>
    Re: Perl Editor : Whats Recommended <michael.p.broida@boeing.com>
    Re: Perl Editor : Whats Recommended (Thaddeus L. Olczyk)
    Re: Perl Editor : Whats Recommended <apsyrtes@rogers.com>
    Re: Perl Editor : Whats Recommended <spam@thecouch.homeip.net>
    Re: Perl Editor : Whats Recommended <krahnj@acm.org>
    Re: Perl Editor : Whats Recommended <mpapec@yahoo.com>
        reading/writing other programs IO <juha.jantunen@pp2.inet.fi>
    Re: reading/writing other programs IO <serge.john.swilting@wanadoo.fr>
    Re: reading/writing other programs IO (Tad McClellan)
    Re: regex with /\G .. /gc (Malcolm Dew-Jones)
    Re: regex with /\G .. /gc <skuo@mtwhitney.nsc.com>
    Re: What is the best software to run for an aspiring Pe <usenet@dwall.fastmail.fm>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 2 May 2003 23:55:17 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Forms structure
Message-Id: <Pine.LNX.4.53.0305022343010.27944@lxplus069.cern.ch>

On Fri, May 2, Andrew Lee inscribed on the eternal scroll:

> Perl is often used, also, to create CGI programs

CGI programs are written in a wide range of languages (I've seen
perfectly serious discussions of CGI programs written in COBOL, for
example).

> -- that is, programs
> that sit between a webserver and a web browser.

Your mental picture is seriously adrift here.  The CGI program
interfaces to the web server.  The web server receives requests from
some client (e.g a browser), identifies that the request calls for a
CGI invocation, and calls the CGI program across the specified
interface.  The CGI program returns its results across the specified
interface to the server, which in turn creates its response to the
client.

> One does not need to really understand the protocols involved

There's some truth in what you say, but many of the confusions
exhibited by over-ambitious implementers who shovel HTML, images,
javascript, CGI scripting and who knows what into their solutions,
could have been avoided if the authors had kept a clearer head about
the protocols involved.

So I'd say that at least a cursory familiarity with the protocols (e.g
HTTP as well as the CGI interface itself) is a sine qua non.  I still
wouldn't prefer to program it myself instead of using appropriate
module(s), I should stress.

> -- just that CGI.pm (also on
> CPAN as well as in the standard distribution) can handle requests to the
> webserver.  To do 'cool' things with CGI requires good knowledge of HTML
> and possibly JavaScript.

Well, there you go.  The man who manages the Javascript FAQ for c.l.j
(Hi, Jim) understands not only how to use it, but also how to avoid
making a web page critically dependent on it.  My counsel would be
that until a developer has reached that stage with Javascript, they
would do better not to use it yet.

all the best

-- 

        The difficulty arises because the kind of people who can sell to
        your powers-that-be are incompatible with those of us with a clue
        on technical subjects.       - Nick Kew on c.i.w.a.stylesheets


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

Date: Sat, 03 May 2003 01:13:53 GMT
From: Andrew Lee <spamtrap@nowhere.com>
Subject: Re: Forms structure
Message-Id: <3i46bvsbp7iuiendcjs88vk9oocjk7urvq@4ax.com>

On Fri, 2 May 2003 23:55:17 +0200, "Alan J. Flavell"
<flavell@mail.cern.ch> wrote:

>On Fri, May 2, Andrew Lee inscribed on the eternal scroll:
>
>> Perl is often used, also, to create CGI programs
>
>CGI programs are written in a wide range of languages (I've seen
>perfectly serious discussions of CGI programs written in COBOL, for
>example).

I never said cgi's weren't written in other languages ... I was
responding to the OP question about building interfaces.  Certainly Perl
can be used to write CGI programs -- I would prefer it to, say, Java.
But that's me.

>
>> -- that is, programs
>> that sit between a webserver and a web browser.
>
>Your mental picture is seriously adrift here.  The CGI program
>interfaces to the web server.  The web server receives requests from
>some client (e.g a browser), identifies that the request calls for a
>CGI invocation, and calls the CGI program across the specified
>interface.  The CGI program returns its results across the specified
>interface to the server, which in turn creates its response to the
>client.

I was trying for a simplistic explanation ... but I should have said
"works with the webserver."  I actually misstated the nature of cgi
totally ... as though it were HTTP.  Your explanation is accurate and
simple.

>
>> One does not need to really understand the protocols involved
>
>There's some truth in what you say, but many of the confusions
>exhibited by over-ambitious implementers who shovel HTML, images,
>javascript, CGI scripting and who knows what into their solutions,
>could have been avoided if the authors had kept a clearer head about
>the protocols involved.
>
>So I'd say that at least a cursory familiarity with the protocols (e.g
>HTTP as well as the CGI interface itself) is a sine qua non. 

I totally agree.

> I still
>wouldn't prefer to program it myself instead of using appropriate
>module(s), I should stress.

In my experience, writing a cgi in Perl without CGI.pm requires more
than cursory familiarity with the CGI interface.  My advice to a newbie
would always be "use CGI.pm and avoid the gotchas"

>
>> -- just that CGI.pm (also on
>> CPAN as well as in the standard distribution) can handle requests to the
>> webserver.  To do 'cool' things with CGI requires good knowledge of HTML
>> and possibly JavaScript.
>
>Well, there you go.  The man who manages the Javascript FAQ for c.l.j
>(Hi, Jim) understands not only how to use it, but also how to avoid
>making a web page critically dependent on it.  My counsel would be
>that until a developer has reached that stage with Javascript, they
>would do better not to use it yet.
>
>all the best



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

Date: Sat, 03 May 2003 01:14:54 GMT
From: Andrew Lee <spamtrap@nowhere.com>
Subject: Re: Forms structure
Message-Id: <su56bvkt2808avbgpe6tlsmjra1jrsapbl@4ax.com>

On Fri, 02 May 2003 20:39:07 GMT, "Jürgen Exner" <jurgenex@hotmail.com>
wrote:

>Andrew Lee wrote:
>> Perl is often used, also, to create CGI programs -- that is, programs
>> that sit between a webserver and a web browser.
>
>Pardon me but that is nonsense.

It is ... my brain was on pause.  :-)

>A web browser sends a request to a web server, the web server in turn may
>call a CGI program.
>The CGI program returns a result to the server which in turn forwards the
>result to the web client.
>
>The CGI program sits at the back end of the chain, not between client and
>server.
>At least in the standard scenario. I'm sure you can come up with some odd
>applications, where a web browser communicates directly with a CGI program.
>
>jue
>



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

Date: 3 May 2003 05:58:24 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Forms structure
Message-Id: <slrnbb6mk0.ict.sholden@flexal.cs.usyd.edu.au>

On 2 May 2003 12:19:17 GMT,
	Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
> Also sprach Sam Holden:
> 
>> On 2 May 2003 06:15:19 GMT,
>> 	Tassilo v. Parseval <tassilo.parseval@rwth-aachen.de> wrote:
>>> Also sprach Sam Jesse:
>>> 
>>>> and what is the differnet between CGI and GUI? 
>>> 
>>> The former stands for 'common gateway interface'. It is a convention how
>>> two (or possibly more) networked computers interact with each other.
>>> Most commonly this is a client machine with a webbrowser on one side and
>>> the webserver on the other.
>> 
>> No it isn't.
>> 
>> CGI defines the interface between two processes. Essentially it defines
>> the values of some environment variables, the command line of the process,
>> and the formatting/content of standard input and output for the process.
> 
> There is no contradiction between your and my explanation (so far).
> Anything that works for a network will also work locally between
> processes. A process is not much different from a program so if two
> programs (or processes) agree on using the CGI specs for communication,
> they are free to do so.

Well there is.

You said it involves two (or more) *networked* computers.

However, CGI itself does not require networked computers, and only requires
one machine. It doesn't disallow them of course. Saying it requires them is
incorrect. Just like saying that CGI requires a perl script would be incorrect
(even though it can involve one). Or like saying perl requires Windows XP, which
it doesn't, but it doesn't disallow it either.

And a program is a process, in the usage I used anyway.

But this is miles off topic :)

-- 
Sam Holden



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

Date: Sat, 03 May 2003 00:59:55 +0000
From: "serge.john.swilting" <serge.john.swilting@wanadoo.fr>
Subject: haiku
Message-Id: <b8ut82$i09$2@news-reader12.wanadoo.fr>

je pense tout le monde

answer2 


le carre a plusieurs cotes
c est une sorte de base dynamique
ecrit tres petit


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

Date: Fri, 2 May 2003 23:09:47 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help: Save Search Terms in an Array?
Message-Id: <slrnbb6g8b.44o.tadmc@magna.augustmail.com>

Andrew Lee <spamtrap@nowhere.com> wrote:

> The correct answer to many Perl programming questions is : "use a hash"


Message-ID: <slrn95u8og.1cr.rgarciasuarez@rafael.kazibao.net>

        I don't know what your original problem is,
        but I suggest to use a hash.  --Rafael Garcia-Suarez


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 3 May 2003 00:23:55 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Is it possible to pass @somethig and $something_else to sub
Message-Id: <3EB30C1B.F205B12A@boeing.com>

Tad McClellan wrote:
> 
> Michael P. Broida <michael.p.broida@boeing.com> wrote:
> > 
> >       Umm, what is the actual REASON for not using & there?
> 
>    perldoc perlsub
> 
>        To call subroutines:
>        ...
>        &NAME(LIST);   # Circumvent prototypes.
>        &NAME;         # Makes current @_ visible to called subroutine.

	Ah!  Thus far in my Perl usage, I haven't used function
	prototypes.  I --WANTED-- to use them, but that's when
	I was having the problem with/without the "&" and the
	only way I could get rid of it was to USE the "&".  I
	was trying to set them up similar to C/C++ forward
	references to functions; I may have been specifying
	the prototypes incorrectly or something equally dumb.
	<grin>

	From the above, it appears that as long as I use () with
	the "&", I WON'T have problems with the callers "@_".
   -->	Am I reading that correctly?  Yes, it's much better to
	NOT circumvent the prototype facility.

	Well, I'll play with using () and NOT using & and try to
	figure out the prototypes so I'm "clean".  <grin>

		Thanks!
			Mike


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

Date: 3 May 2003 05:42:30 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Is it possible to pass @somethig and $something_else to sub
Message-Id: <b8vks6$coi$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Michael P. Broida:

> Tad McClellan wrote:
>> 
>> Michael P. Broida <michael.p.broida@boeing.com> wrote:
>> > 
>> >       Umm, what is the actual REASON for not using & there?
>> 
>>    perldoc perlsub
>> 
>>        To call subroutines:
>>        ...
>>        &NAME(LIST);   # Circumvent prototypes.
>>        &NAME;         # Makes current @_ visible to called subroutine.
> 
> 	    Ah!  Thus far in my Perl usage, I haven't used function
> 	    prototypes.  I --WANTED-- to use them, but that's when
> 	    I was having the problem with/without the "&" and the
> 	    only way I could get rid of it was to USE the "&".  I
> 	    was trying to set them up similar to C/C++ forward
> 	    references to functions; I may have been specifying
> 	    the prototypes incorrectly or something equally dumb.
> 	    <grin>

I suspect that you declared the subroutines "too late" for any prototype
to have an effect. Before the first call to the subroutine, the
prototype must already be set up. You can do this with a
forward-declaration:

    sub func (\@);
    ...
    func(@array);

    sub func (\@) {
        # body
    }

Or you simply declare the functions on top of your programs:

    sub func (\@) { 
        # body
    }
    ...
    func(@array);

> 	    From the above, it appears that as long as I use () with
> 	    the "&", I WON'T have problems with the callers "@_".
>   --> Am I reading that correctly?  Yes, it's much better to
> 	    NOT circumvent the prototype facility.

Yes, you are. &FUNC() wont silently pass @_ to FUNC.

> 	    Well, I'll play with using () and NOT using & and try to
> 	    figure out the prototypes so I'm "clean".  <grin>

'perldoc perlsub' (subsection "Prototypes") shows how you can mimic the
behaviour of Perl built-ins with prototypes. With the help of this list
you should be able to set up the desired prototype.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Sat, 03 May 2003 05:47:16 GMT
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Is there any way to debug PerlScript used in ASP?
Message-Id: <Xns9370122C136CCdkwwashere@204.127.204.17>

"Andrew" <45724remove@yahoo.com> wrote:

> Is there any way to debug PerlScript used in ASP?

Yes.


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

Date: Sat, 3 May 2003 10:03:21 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: locating module NetCDF
Message-Id: <3eb30852$0$28251@echo-01.iinet.net.au>


"Ben" <ben_altman@deadspam.com> wrote in message
news:b8u4v8$dhj8q$1@ID-121117.news.dfncis.de...
> Hi,
>
> I am trying to take a perl script from HP-UX to Linux where the Linux
> system should (in theory) already be setup to handle this. When I run
> the script I get an error "Can't locate loadable object for module
> NetCDF in @INC". I did a perldoc perlvar and added a "use lib
> /path_to_library" line there but still got the same error. The directory
> listing of the path I added contains NetCDF.pm which I presume is what
> it is looking for so I am scratching my head trying to figure out what
> to do next. Any suggestions?
>
> Thanks,
> Ben
>

'NetCDF.pm' is being found ok. It's the shared library ('NetCDF.so') that
can't be located.
Where is it ?

Cheers,
Rob




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

Date: Sat, 03 May 2003 00:48:29 GMT
From: "dpm" <danmurph@att.net>
Subject: Perl CGI on Windows XP
Message-Id: <xlEsa.63580$cO3.4253347@bgtnsc04-news.ops.worldnet.att.net>

What is required to run a Perl/CGI script with IE on a Windows XP machine
locally?





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

Date: Sat, 3 May 2003 01:41:22 -0400
From: "Chris Priede" <priede@panix.com>
Subject: Re: Perl CGI on Windows XP
Message-Id: <b8vkq9$buc$1@reader1.panix.com>

"dpm" <danmurph@att.net> wrote:
> What is required to run a Perl/CGI script
> with IE on a Windows XP machine locally?

1)A web server.  This could be IIS (which is included with XP Professional)
or Apache ( http://httpd.apache.org/download.cgi ).  There may even be some
other viable choices.

2)Perl.  I suggest ActiveState Perl (
http://www.activestate.com/Products/ActivePerl/ ).

-- 
Chris Priede (priede@panix.com)




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

Date: Fri, 02 May 2003 17:58:59 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <Xns936FC1162B2DCsdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote in
news:3eb2cc55@news.victoria.tc.ca: 

> Chris (chris_12003@yahoo.com) wrote:
>: Is there an editor that will allow me to clearly see code thats in
{
>: }.  I have a perl script that has lots of nested { } brackets and
its
>: hard for me to tell where the code stops and which else
statements
>: belong to which if. Will homesite do this or is there something
else
>: available? 

[anecdote snipped] 
> Every since then I virtually always align ny braces vertically. 
> (That's begin/end in pascal of course.)  It requires absolutely no
> support of any kind from any editor or other tool, and even allows
you
> to check the syntax when you have no tool at all, such as reading
a
> printout on the bus.  It's was a trivial change in my editing
style
> that virtually eliminates bugs due to misplaced braces.

I completely agree with Malcolm, plus I would like to suggest that if
you rearrange your code a bit, I'll bet that you could reduce the
level of nesting quite a bit.  Reading deeply-nested code is hard on
the head and bad for the soul.  Try these tactics:

1. Flip simple if, while, and for statements:

    if ($foo eq 'bar')
    {
        do_something;
    }

becomes

    do_something if $foo eq 'bar';

and

    foreach (@array)
    {
        s/foo/bar/;
    }

becomes

    s/foo/bar foreach @array;


2. Cut out early.

Instead of this:

    if (things_are('good'))
    {
        ...
        ...
        do lots and lots of stuff, deeper and deeper
        ...
        ...
    }
    else
    {
        print "The sky is falling";
    }

do this:

    if (things_are('bad'))
    {
        print "The sky is falling";
        return;
    }

    ...rest of program or function has one less indent level.

True story:  Yesterday I read a perl program, written by an unskilled
programmer, which had an if statement (along the lines of "if things
are good"), followed by an open brace, followed by over EIGHT HUNDRED
lines of code, followed by a close brace and an else block that
printed an error message.  Cripes!  Who wants to trace back 800 lines
to find out what condition would trigger the message?!  Don't let
this happen to you.


3. Refactor into subroutines.

Sometimes it just makes good sense to rip the guts out of a complex
block and put it into its own subroutine in order to reduce the
complexity of the block.  You have to be careful that the new
subroutine doesn't need gobs of data from the block to be passed back
and forth, otherwise you'll get tangled up in a mess of spaghetti
that will be more complex, not less.  You'll wish you were back
looking for that matching brace.

Good luck.
- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+svgfY96i4h5M0egRAg7EAJ48ySpVIVSwxXktDpSYpbcNUZMjMACfaRpv
lZ9VaqBM8EnQLHUfrXgwu9c=
=BtS0
-----END PGP SIGNATURE-----


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

Date: Sat, 3 May 2003 00:26:02 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <3EB30C9A.907E5D53@boeing.com>

Chris wrote:
> 
> Is there an editor that will allow me to clearly see code thats in { }.  I
> have a perl script that has lots of nested { } brackets and its hard for me
> to tell where the code stops and which else statements belong to which if.
> Will homesite do this or is there something else available?

	I like Emacs.  It has a Perl mode that can handle indentation
	(though you might not like its default style) and font coloring
	so you can see variables, comments, functionnames, etc. among
	the rest of the language elements.

		Mike


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

Date: Sat, 03 May 2003 01:54:28 GMT
From: olczyk@interaccess.com (Thaddeus L. Olczyk)
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <3eb31e33.269294593@nntp.interaccess.com>

n 2 May 2003 12:51:49 -0800, yf110@vtn1.victoria.tc.ca (Malcolm
Dew-Jones) wrote:

>Chris (chris_12003@yahoo.com) wrote:
>: Is there an editor that will allow me to clearly see code thats in { }.  I
>: have a perl script that has lots of nested { } brackets and its hard for me
>: to tell where the code stops and which else statements belong to which if.
>: Will homesite do this or is there something else available?
>
>Years ago I spent many hours debugging a complex numerical calculation in
>a pascal program.  As often in numerical analysis, it was not possible to
>check the answer from the program except by writing a program to find the
>answer, which makes it tricky to know if the answer was correct.  It was
>certainly very close.
>
>Eventually I found that an end statement was not correctly aligned with
>the appropriate begin within a nested calculation.
>
>Every since then I virtually always align ny braces vertically.  (That's
>begin/end in pascal of course.)  It requires absolutely no support of any
>kind from any editor or other tool, and even allows you to check the
>syntax when you have no tool at all, such as reading a printout on the
>bus.  It's was a trivial change in my editing style that virtually
>eliminates bugs due to misplaced braces.
>
>	while ( short simple expr, horizontal alignment )
>	{
>		block of code, or complex expressions
>		vertical alignment
>	}
>
>
>$0.02
It helps to have an editor  with context sensitive indenting.
Then if a statement is not in the right block then it sticks out like
a sore thumb ( along with missing delimiters ).

On top of that you have selective display.
The comand: esc-somenumber C-x $
will collapse any block indented somenumber lines to one line
C-x $ collapses it again.

It makes it much easier to edit outer layers.


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

Date: Sat, 03 May 2003 02:07:26 GMT
From: Apsyrtes <apsyrtes@rogers.com>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <lr86bvc2ea2el1fc874e2035fa1ls4jc46@4ax.com>

On Fri, 2 May 2003 11:51:03 -0700, "Chris" <chris_12003@yahoo.com>
wrote:

>Is there an editor that will allow me to clearly see code thats in { }.  I
>have a perl script that has lots of nested { } brackets and its hard for me
>to tell where the code stops and which else statements belong to which if.
>Will homesite do this or is there something else available?


I've used a lot of editors, and am currently *really* liking Komodo
for perl.  http://www.activestate.com  -- two features you may like in
particular.... whenever your cursor is next to a brace, both it and
the matching brace highlight.  Also, CTRL-B will select a the whole
block your cursor is in, from open to close bracket... successive
CTRL-B's will select the block that the block is in etc.


As other people have pointed out in this thread, though, you'll save
yourself a lot of hassle if you do this:

if (blah)
{
    code;
}


I just don't get people that put the opening brace on the same line as
the if... it's not like lines are at a premium... clarity, however,
offers significant advantages.



Jason W.



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

Date: Fri, 02 May 2003 22:58:35 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <xfGsa.17584$dB2.169866@wagner.videotron.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Chris wrote:
> Is there an editor that will allow me to clearly see code thats in { }.  I
> have a perl script that has lots of nested { } brackets and its hard for me
> to tell where the code stops and which else statements belong to which if.
> Will homesite do this or is there something else available?

Step 1. Re-cleanup the code (visually):
http://perltidy.sourceforge.net/

Step 2. Use a good editor with good auto-indent features, etc.. I'm 
hooked on:
http://www.vim.org/

Best of luck.

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+szBfeS99pGMif6wRAukeAKCHX9UzLaBHWs8DSOt6dGH/JXp8swCgq7xd
bZT5M7C6y1wMRrAd1ZRNFUE=
=md5R
-----END PGP SIGNATURE-----



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

Date: Sat, 03 May 2003 03:14:53 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <3EB33420.5CE26A5A@acm.org>

"Eric J. Roode" wrote:
> 
> True story:  Yesterday I read a perl program, written by an unskilled
> programmer, which had an if statement (along the lines of "if things
> are good"), followed by an open brace, followed by over EIGHT HUNDRED
> lines of code, followed by a close brace and an else block that
> printed an error message.  Cripes!  Who wants to trace back 800 lines
> to find out what condition would trigger the message?!  Don't let
> this happen to you.

I HATE it when that happens!  Been there, patched the code, got the
T-shirt.  :-)


John
-- 
use Perl;
program
fulfillment


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

Date: Sat, 03 May 2003 09:03:44 +0200
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <g5q6bvga0vcn1uglhumqoshine8cqmfi5b@4ax.com>

X-Ftn-To: Chris 

"Chris" <chris_12003@yahoo.com> wrote:
>Is there an editor that will allow me to clearly see code thats in { }.  I
>have a perl script that has lots of nested { } brackets and its hard for me
>to tell where the code stops and which else statements belong to which if.
>Will homesite do this or is there something else available?

Scite draws vertical lines for each matching block
http://www.scintilla.org/wscite152.zip


-- 
Matija


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

Date: Fri, 02 May 2003 22:08:12 GMT
From: "Juha Jantunen" <juha.jantunen@pp2.inet.fi>
Subject: reading/writing other programs IO
Message-Id: <g%Bsa.350$Ae1.312@read3.inet.fi>

Hi,

I'm trying to run some shell script from my perl script. This shell script
gives some output and in some cases it also requires answers (yes/no).

How can I send these answers to shell script?

So, what I would like to have is this:
 ....
start external program FOO #it is a shell script
while FOO is runnig
    catch output from FOO
    do some conclutions
    if output from FOO  /yes or no/
        send "yes" to FOO  #or maybe no
    fi
end while
 .....

Thanks
Juha




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

Date: Sat, 03 May 2003 00:56:46 +0000
From: "serge.john.swilting" <serge.john.swilting@wanadoo.fr>
Subject: Re: reading/writing other programs IO
Message-Id: <b8ut26$i09$1@news-reader12.wanadoo.fr>

moi 
answer2

yes

belle fille


Juha Jantunen wrote:

> Hi,
> 
> I'm trying to run some shell script from my perl script. This shell script
> gives some output and in some cases it also requires answers (yes/no).
> 
> How can I send these answers to shell script?
> 
> So, what I would like to have is this:
> ....
> start external program FOO #it is a shell script
> while FOO is runnig
>     catch output from FOO
>     do some conclutions
>     if output from FOO  /yes or no/
>         send "yes" to FOO  #or maybe no
>     fi
> end while
> .....
> 
> Thanks
> Juha



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

Date: Fri, 2 May 2003 23:11:11 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: reading/writing other programs IO
Message-Id: <slrnbb6gav.44o.tadmc@magna.augustmail.com>

Juha Jantunen <juha.jantunen@pp2.inet.fi> wrote:

> I'm trying to run some shell script from my perl script. This shell script
> gives some output and in some cases it also requires answers (yes/no).


   perldoc -q pipe

      "How can I open a pipe both to and from a command?"


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 2 May 2003 15:12:34 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: regex with /\G .. /gc
Message-Id: <3eb2ed52@news.victoria.tc.ca>

foobear@nospam.zoom.net wrote:
: Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:
: > 	m/^hello/ starts looking at the start of the string, and the word
: > hello must be the very first thing it finds.

: > 	m/\Ghello/ starts looking where it left of last time, and the word
: > hello must be the very first thing it finds.  (That description may not be
: > 100% correct).


: > If you say m/\GHello/gc then the H in Hello has to be the very next letter
: > after the last match.


: Hello Malcom and all,

: I think I understand, and now see my error.

: When I had my regex use \G like this. It would always fail finding
: my key, value pairs with the 2nd regex.  (But it works ok without it)

: LOOP: {
: 	$h{id} = $1,            redo if /\G^(S\d+)/gc;
: 	$h{$1} = $2,            redo if /\G(\S+)(?<!NOTES):\s([^,\s]+),?\s+/g
: 	$h{notes}{$1} = $2,     redo if /"([^"]+)"\s+"([^"]*)"/gc;
: }

: If I understand you correctly when using \G, the regex starts matching
: exactly where it left off and my pattern has to match the next character
: it scans

: I had ommited a trailing space in my first regex so without it the
: regex started matching on a \s and not a \S, thus failing  Adding a
: space at the end of my first regex makes \G on the 2nd regex work now
: (If I understood you correctly)

: 	$h{id} = $1,            redo if /\G^(S\d+)\s+/gc;
: 						  ^^^	

the above now *requires* the string to have at least one space after the
S\d+ to get that match, is that realy what you want? 

: Does it make sense for me to use \G here then? 

I didn't examine all your example well enough to tell you that.  If you
want to ensure the string has nothing extraneous between the things you
match then yes, \G is the way to do that.  If there can be unspecified
chaff between the things you are matching then you do not want \G.

I only want to scan the
: string once. I can acheive that with /gc alone, no?

Correct.

  Also is using a
: block with redo the proper way?  

There are various ways to do this.  If it works then it works...

(I would use a while loop but I'm not
: certain the order the items will appear in)

I don't think that would make a difference.
	while (not done)
	{	next if m/atch/
		next if m/atch2/
	}

: Finally on the 2nd regex you added a ,? at the end.

I don't think that was me was it?  Perhaps you mean the (.*?) in one of my
examples.  The ? says "match as few times as possible" - i.e. a non-greedy
match. 

  Is that really
: necessary it's always going to succeed anyways no?

I think you are thinking of "match 0 or one times", which can also use a
?, but here I think it meant non-greedy matching, so your question doesn't
quite make sense to me.



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

Date: Fri, 2 May 2003 15:37:49 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: regex with /\G .. /gc
Message-Id: <Pine.GSO.4.21.0305021535210.15869-100000@mtwhitney.nsc.com>

On Fri, 2 May 2003, Steven Kuo wrote:

> On Fri, 2 May 2003 foobear@nospam.zoom.net wrote:
> 
> > > }
> > [snipped]
> > 
> > Hi Steve,
> > 
> > The use of substr is clever to achieve the matches with one pattern :)
> > 
> > I am curious, is there a way to solve this without using a zero-width
> > negative lookbehind assertion. (?<!pattern) I dont think some tools
> > support that. (and older versions of perl)
> > 
> > -v
>  
> 
> Yes, of course.  Without lookbehind:
> 
> 
> #!/usr/local/bin/perl
> 
> use Data::Dumper;
> my %h;
> $_ =    'S89 Key: 255.255.255.255:319510, NAS: 1.1.1.1, NAS-Port: 666,
>         User-Name: foo@bar.baz, Time: 94:35:09, GSL 1,
>         NOTES: "Acct-Session-Id" "0048939656", "FooNote" "1.2.3.4",
>         "BarNote" "whee"';
> 
> 
> substr($_,0,0) = 'id: ';
> 
> 
> LOOP:
> {
>     next if /\G[^:]+NOTES:/;
>     
>     $h{$1} = $2, redo LOOP if m#\G(\S+):\s([^,\s]+),?\s+(?{print pos,$/;})#gc;
> 
> } continue {
>     print "Begin again at ", pos , "\n";
>     %{$h{'notes'}} = m/"([^"]+)"\s+"([^"]*)"/g;
>     last;
> }
> 
> print Dumper \%h;
> 




To the OP (foobear@nospam.zoom.net):

By the way, I don't recommend that you write your code this way.  The
examples I provided were meant to show how you can apply a design
pattern from the documentation (perlop) to the problem you posed.

The loop above is twisty if not obfuscated.

I think you can split you string in two and work on each part
separately:

substr($_,0,0) = 'id: ';
my ($first_part,$second_part) = split(/NOTES:/,$_,2);
my %h = $first_part =~ m/(\S+):\s([^,\s]+)/g;
%{$h{'notes'}} = $second_part =~ m/"([^"]+)"\s+"([^"]*)"/g;


-- 
Regards,
Steven



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

Date: Sat, 03 May 2003 05:46:13 GMT
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: What is the best software to run for an aspiring Perl programer?
Message-Id: <Xns937011FE4406Cdkwwashere@204.127.204.17>

Martien Verbruggen <mgjv@tradingpost.com.au> wrote:

> On Thu, 01 May 2003 19:33:45 GMT,
>      Thaddeus L. Olczyk <olczyk@interaccess.com> wrote:
>> 
>> Why do stupid people always try to be programmers?
> 
> Why do people who know too little to realise they don't know much,
> always act like they know everything?

Doesn't that sort of answer itself?  I recall my first post to clpm;  I 
wanted to help, I thought I was giving a correct answer, and Randal 
Schwartz pointed out that my answer was completely wrong.  Afterwards I 
checked my answers more thoroughly.  Many times I didn't post, but just 
compared the solutions I came up with on my own to the ones that were 
posted.  That was very informative.  Sometimes my answers were as good as 
those posted, sometimes mine sucked rocks, and on a few occasions I even 
liked mine better.

Maybe embarrassing yourself by being a know-it-all is one of those 
milestones on understanding your limitations.

-- 
David Wall - usenet@dwall.fastmail.fm
"Oook."


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.

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 V10 Issue 4929
***************************************


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