[22709] in Perl-Users-Digest
Perl-Users Digest, Issue: 4930 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 3 11:05:39 2003
Date: Sat, 3 May 2003 08: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: 4930
Today's topics:
basic doubts.. (Rajesh M A)
Re: basic doubts.. <chang0@adelphia.net>
Re: basic doubts.. <jurgenex@hotmail.com>
Re: basic doubts.. <abuse@mweb.co.za>
Re: basic doubts.. <abuse@mweb.co.za>
Differences between versions of Perl <look@my.signature>
Re: Differences between versions of Perl <noreply@gunnar.cc>
FreeTDS and DBD on Windows/Cygwin ??? <abuse@mweb.co.za>
Re: Is it possible to pass @somethig and $something_els <bart.lateur@pandora.be>
Re: Is there any way to debug PerlScript used in ASP? <45724remove@yahoo.com>
Re: Is there any way to debug PerlScript used in ASP? <denshimeiru-sapmctacher@durchnull.ath.cx>
Re: Perl Editor : Whats Recommended <abuse@mweb.co.za>
Re: Perl Editor : Whats Recommended <denshimeiru-sapmctacher@durchnull.ath.cx>
Re: Perl Editor : Whats Recommended <REMOVEsdnCAPS@comcast.net>
Re: Perl Editor : Whats Recommended <jurgenex@hotmail.com>
Perl Socket Question <imarinejt@hotmail.com>
string checking, before using in SENDMAIL -> 'één' has <tunmaster@hotmail.com>
Re: What is the best software to run for an aspiring Pe <no@spam.for.me.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 3 May 2003 05:18:57 -0700
From: viijv@rediffmail.com (Rajesh M A)
Subject: basic doubts..
Message-Id: <bf3db5a0.0305030418.668437f3@posting.google.com>
Hello Group,
This is my class assignment... there was more than a dozen of them,
and i fixed all other except these few... i feel like stucked, so i am
here...
I dont want any 'ready made' answer to make life simple for me... i
want to do all the below myself, but i feel stucked up with the
resources available to me. So if you people can help me by explaining
the real meaning of these questions or by giving some relavant
links.... it will be a great help for me.
#)Write a program that outputs "Hello World" but using both system()
and backticks.
I didnt understand anything after reading the system() functions
documentation :-( and what are backticks?
#)Write a statement using map() that will create a new array
consisting of only the words with the character w prepended. The input
array is @items = qw(ant hat ren hen ell)
Hmm... what is the meaning of 'prepend w'?
#)The intersection of two lists is the set of elements that they have
in common. Write a subroutine that takes two references to arrays as
its arguments, and returns the list of elements in the intersection if
called in array context and returns the number of elements in the
intersection if called in scalar context.
What is the meaning of... 'references to arrays as its arguments'?
i can only pass variables to an subroutine, right? something like
&my_sub($var1,$var2,$var3);
and if its an array, then only one array.
&my_sub(@array);
how can i send two arrays? what do they mean by 'reference to arrays'?
Can some one explain this to me ?
#)Rewrite the following fragment of code to use a dispatch table:
If ($answer eq "y"){
Print "Yes";
}
If ($answer eq "n"){
Print "No";
}
If ($answer eq "m"){
Print "Maybe";
}
My doubt is simple...what is a dispatch table? i searched the internet
a lot, but failed to find any promising information.
Thanking you all
Vinod.
------------------------------
Date: Sat, 03 May 2003 13:19:24 GMT
From: ebchang <chang0@adelphia.net>
Subject: Re: basic doubts..
Message-Id: <Xns93705ED799449chang0adelphia.net@24.48.107.53>
viijv@rediffmail.com (Rajesh M A) wrote in
news:bf3db5a0.0305030418.668437f3@posting.google.com:
> Hello Group,
>
> This is my class assignment... there was more than a dozen of them,
> and i fixed all other except these few... i feel like stucked, so i am
> here...
I am very curious to know what class you are taking -- and what textbook
you are using for it.
> I dont want any 'ready made' answer to make life simple for me... i
> want to do all the below myself, but i feel stucked up with the
> resources available to me. So if you people can help me by explaining
> the real meaning of these questions or by giving some relavant
> links.... it will be a great help for me.
The indicated questions are all exercises from the textbook "Practical Perl
with CGI Applications" from Scott/Jones Publishers
(http://www.scottjonespub.com/changperl.html). It is currently in press,
and should be in print in about two weeks. All of the information needed
to solve the exercises is explained in detail in the chapters which the
exercises accompany.
>#)Write a program that outputs "Hello World" but using both system()
> and backticks.
>
> I didnt understand anything after reading the system() functions
> documentation :-( and what are backticks?
Read Chapter 5. Backticks are the same as backquotes (``). There are
examples of both in the chapter - you use them to run your first "Hello
World" program exercise from Chapter 2.
>#)Write a statement using map() that will create a new array
> consisting of only the words with the character w prepended. The input
> array is @items = qw(ant hat ren hen ell)
>
> Hmm... what is the meaning of 'prepend w'?
Read Chapter 6. The final version of the question said "create a new array
consisting of the words with the character w added to the beginning of
each." Does that help?
>#)The intersection of two lists is the set of elements that they have
> in common. Write a subroutine that takes two references to arrays as
> its arguments, and returns the list of elements in the intersection if
> called in array context and returns the number of elements in the
> intersection if called in scalar context.
> What is the meaning of... 'references to arrays as its arguments'?
> i can only pass variables to an subroutine, right? something like
> &my_sub($var1,$var2,$var3);
> and if its an array, then only one array.
> &my_sub(@array);
Read Chapter 4 - where, incidentally, you will *NOT* be advised to use the
&sub form of calling a subroutine. What outdated text are you using? Then
read Chapter 7 to learn more about context.
> how can i send two arrays? what do they mean by 'reference to arrays'?
> Can some one explain this to me ?
Chapter 4 introduces references sufficiently to solve this exercise. Read
Chapter 7 for a deeper explanation.
>#)Rewrite the following fragment of code to use a dispatch table:
> If ($answer eq "y"){
> Print "Yes";
> }
> If ($answer eq "n"){
> Print "No";
> }
> If ($answer eq "m"){
> Print "Maybe";
> }
>
> My doubt is simple...what is a dispatch table? i searched the internet
> a lot, but failed to find any promising information.
Read Chapter 7. Specifically Section 7.3 Subroutine References and
Dispatch Tables.
Why are you searching the internet? If you are given these exercises in a
class, your instructor should have required or recommended at least some
textbooks or other resources that would provide the necesary information.
(Apologies for sounding like an advertisement, but the OP did quote the
exercises, and the information is all in the textbook, even if he couldn't
possibly have it yet.)
--
EBC
------------------------------
Date: Sat, 03 May 2003 13:40:38 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: basic doubts..
Message-Id: <qFPsa.5405$gf3.4606@nwrddc03.gnilink.net>
Rajesh M A wrote:
> This is my class assignment... there was more than a dozen of them,
> and i fixed all other except these few... i feel like stucked, so i am
> here...
Normally homework questions are very much frowned up here ...
> I dont want any 'ready made' answer to make life simple for me... i
> want to do all the below myself, but i feel stucked up with the
> resources available to me.
... but this makes it a legitimate quest I guess
> So if you people can help me by explaining
> the real meaning of these questions
This part may prove difficult because we didn't create those questions
> or by giving some relavant
> links.... it will be a great help for me.
I'll try my best
> #)Write a program that outputs "Hello World" but using both system()
> and backticks.
>
> I didnt understand anything after reading the system() functions
> documentation :-( and what are backticks?
Neither do I. This task doesn't make much sense at all. Both system() as
well as backticks start an external program. But that has nothing to do with
printing some text. You may want to ask your teacher for clarification.
Oh, backticks are the those single quotes that point backward, e.g. this
character: `
The are described in "perldoc perlop", section "Quote and Quote-like
operators" and are the same as qx{}.
> #)Write a statement using map() that will create a new array
> consisting of only the words with the character w prepended. The input
> array is @items = qw(ant hat ren hen ell)
>
> Hmm... what is the meaning of 'prepend w'?
That I can explain. "Prepend" is the same as "append" but at the beginning
of the string instead of at the end.
The wanted result is
@items = qw(want what wren when well)
> #)The intersection of two lists is the set of elements that they have
> in common. Write a subroutine that takes two references to arrays as
> its arguments, and returns the list of elements in the intersection if
> called in array context and returns the number of elements in the
> intersection if called in scalar context.
>
> What is the meaning of... 'references to arrays as its arguments'?
> i can only pass variables to an subroutine, right? something like
> &my_sub($var1,$var2,$var3);
> and if its an array, then only one array.
> &my_sub(@array);
Hmmm, sort of. You can pass only scalars to a functions.
For the different data types please see "perldoc perldata".
If you pass arrays as arguments they will be flattened into a single list of
scalars. Therefore if you pass two arrays then inside of your function you
won't be able separate the elements into two arrays again.
> how can i send two arrays? what do they mean by 'reference to arrays'?
> Can some one explain this to me ?
References are the same as pointers in C or Pascal. You can think of them as
the address of the array in the memory(*). References are scalars, too, so
they can be passed to functions and they don't get flattened.
So instead of passing two arrays you are passing the references to those two
arrays to the function.
For further details on references you may want to start with "perldoc
perlreftut" and then for the gory details please see "perldoc perlref".
(*): actually this is a white lie. There are quite significant differences
between pointers and references and they are no "just addresses". But on
your level you don't have to worry about that.
> #)Rewrite the following fragment of code to use a dispatch table:
> If ($answer eq "y"){
> Print "Yes";
> }
> If ($answer eq "n"){
> Print "No";
> }
> If ($answer eq "m"){
> Print "Maybe";
> }
>
> My doubt is simple...what is a dispatch table? i searched the internet
> a lot, but failed to find any promising information.
A dispatch table is a generic term for a mapping of some sort.
y => "Yes"
n => "No"
m => "Maybe"
Then instead of having a long list of "if ... then print ..." you would
have one single statement "print dispatchtable{$answer}".
There are many different ways how you can implement them but in Perl
generally you would use a hash. I do not know and cannot know if this is
what your teacher is looking for. You may want to ask him.
jue
------------------------------
Date: Sat, 03 May 2003 15:50:11 +0200
From: "Nico Coetzee" <abuse@mweb.co.za>
Subject: Re: basic doubts..
Message-Id: <pan.2003.05.03.13.50.09.225535@mweb.co.za>
On Sat, 03 May 2003 05:18:57 -0700, Rajesh M A wrote:
> Hello Group,
>
> This is my class assignment... there was more than a dozen of them,
> and i fixed all other except these few... i feel like stucked, so i am
> here...
>
> I dont want any 'ready made' answer to make life simple for me... i
> want to do all the below myself, but i feel stucked up with the
> resources available to me. So if you people can help me by explaining
> the real meaning of these questions or by giving some relavant
> links.... it will be a great help for me.
>
>
> #)Write a program that outputs "Hello World" but using both system()
> and backticks.
>
> I didnt understand anything after reading the system() functions
> documentation :-( and what are backticks?
>
>
> #)Write a statement using map() that will create a new array
> consisting of only the words with the character w prepended. The input
> array is @items = qw(ant hat ren hen ell)
>
> Hmm... what is the meaning of 'prepend w'?
>
>
> #)The intersection of two lists is the set of elements that they have
> in common. Write a subroutine that takes two references to arrays as
> its arguments, and returns the list of elements in the intersection if
> called in array context and returns the number of elements in the
> intersection if called in scalar context.
>
> What is the meaning of... 'references to arrays as its arguments'?
> i can only pass variables to an subroutine, right? something like
> &my_sub($var1,$var2,$var3);
> and if its an array, then only one array.
> &my_sub(@array);
>
> how can i send two arrays? what do they mean by 'reference to arrays'?
> Can some one explain this to me ?
>
>
> #)Rewrite the following fragment of code to use a dispatch table:
> If ($answer eq "y"){
> Print "Yes";
> }
> If ($answer eq "n"){
> Print "No";
> }
> If ($answer eq "m"){
> Print "Maybe";
> }
>
> My doubt is simple...what is a dispatch table? i searched the internet
> a lot, but failed to find any promising information.
>
> Thanking you all
> Vinod.
First of all, what books do you have? Many of the above have solutions in
the Perl Cookbook:
http://www.linux.org/books/ISBN_1565922433.html
http://jayts.cx/books/cookbook.s.html
I assume you have you tried 'perldoc -f system'? If you don't understand what that
says, I'm afraid you still have a long way to go...
Here are some simple pointers:
1) system() and 'backtics' ( literally `` ) are used to execute other
programs from within your Perl script. You can gather STDOUT output into a
variable like this:
$response = `date +%s`;
print "Response was: $response\n";
system() is very much the same - you should be able to understand the
documentaion now.
2) http://forums.devshed.com/t59483/sdfdc17ec34a67e89ac60ca7a0cf2b6f5.html
[ from Google:
http://www.google.com/search?hl=en&ie=ISO-8859-1&q=perl+map%28%29+function&btnG=Google+Search ]
3) Intersections are well covered in the cook book and so is references to
arrays
4) http://www.usenix.org/publications/login/2002-06/pdfs/turoff.pdf [ from
Google:
http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=perl+dispatch+table&btnG=Google+Search ]
Cheers
--
Nico Coetzee
http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/
To the systems programmer, users and applications serve only to provide a
test load.
------------------------------
Date: Sat, 03 May 2003 15:52:37 +0200
From: "Nico Coetzee" <abuse@mweb.co.za>
Subject: Re: basic doubts..
Message-Id: <pan.2003.05.03.13.52.36.171649@mweb.co.za>
On Sat, 03 May 2003 13:19:24 +0000, ebchang wrote:
> viijv@rediffmail.com (Rajesh M A) wrote in
> news:bf3db5a0.0305030418.668437f3@posting.google.com:
>
>> Hello Group,
>>
>> This is my class assignment... there was more than a dozen of them,
>> and i fixed all other except these few... i feel like stucked, so i am
>> here...
>
> I am very curious to know what class you are taking -- and what textbook
> you are using for it.
>
>> I dont want any 'ready made' answer to make life simple for me... i
>> want to do all the below myself, but i feel stucked up with the
>> resources available to me. So if you people can help me by explaining
>> the real meaning of these questions or by giving some relavant
>> links.... it will be a great help for me.
>
> The indicated questions are all exercises from the textbook "Practical Perl
> with CGI Applications" from Scott/Jones Publishers
> (http://www.scottjonespub.com/changperl.html). It is currently in press,
> and should be in print in about two weeks. All of the information needed
> to solve the exercises is explained in detail in the chapters which the
> exercises accompany.
>
>>#)Write a program that outputs "Hello World" but using both system()
>> and backticks.
>>
>> I didnt understand anything after reading the system() functions
>> documentation :-( and what are backticks?
>
> Read Chapter 5. Backticks are the same as backquotes (``). There are
> examples of both in the chapter - you use them to run your first "Hello
> World" program exercise from Chapter 2.
>
>>#)Write a statement using map() that will create a new array
>> consisting of only the words with the character w prepended. The input
>> array is @items = qw(ant hat ren hen ell)
>>
>> Hmm... what is the meaning of 'prepend w'?
>
> Read Chapter 6. The final version of the question said "create a new array
> consisting of the words with the character w added to the beginning of
> each." Does that help?
>
>>#)The intersection of two lists is the set of elements that they have
>> in common. Write a subroutine that takes two references to arrays as
>> its arguments, and returns the list of elements in the intersection if
>> called in array context and returns the number of elements in the
>> intersection if called in scalar context.
>
>> What is the meaning of... 'references to arrays as its arguments'?
>> i can only pass variables to an subroutine, right? something like
>> &my_sub($var1,$var2,$var3);
>> and if its an array, then only one array.
>> &my_sub(@array);
>
> Read Chapter 4 - where, incidentally, you will *NOT* be advised to use the
> &sub form of calling a subroutine. What outdated text are you using? Then
> read Chapter 7 to learn more about context.
>
>> how can i send two arrays? what do they mean by 'reference to arrays'?
>> Can some one explain this to me ?
>
> Chapter 4 introduces references sufficiently to solve this exercise. Read
> Chapter 7 for a deeper explanation.
>
>>#)Rewrite the following fragment of code to use a dispatch table:
>> If ($answer eq "y"){
>> Print "Yes";
>> }
>> If ($answer eq "n"){
>> Print "No";
>> }
>> If ($answer eq "m"){
>> Print "Maybe";
>> }
>>
>> My doubt is simple...what is a dispatch table? i searched the internet
>> a lot, but failed to find any promising information.
>
> Read Chapter 7. Specifically Section 7.3 Subroutine References and
> Dispatch Tables.
>
> Why are you searching the internet? If you are given these exercises in a
> class, your instructor should have required or recommended at least some
> textbooks or other resources that would provide the necesary information.
>
> (Apologies for sounding like an advertisement, but the OP did quote the
> exercises, and the information is all in the textbook, even if he couldn't
> possibly have it yet.)
Well then - there you have it...
--
Nico Coetzee
http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/
To the systems programmer, users and applications serve only to provide a
test load.
------------------------------
Date: 03 May 2003 09:42:34 GMT
From: David Scarlett <look@my.signature>
Subject: Differences between versions of Perl
Message-Id: <Xns9370C8AC9668dscarlett@210.49.20.254>
Anyone know where I could find a list of the changes made in each
version of Perl?
I need to write a script for Perl 5.004 and what to know what was
different in that version....
Thanks.
--
David Scarlett
dscarlett@_ _ _ _ _ _ _ _
_ _ _ _ _ optusnet.com.au
------------------------------
Date: Sat, 03 May 2003 15:46:57 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Differences between versions of Perl
Message-Id: <b90hc4$ed9ab$1@ID-184292.news.dfncis.de>
David Scarlett wrote:
> Anyone know where I could find a list of the changes made in each
> version of Perl?
perldelta
Each version of Perl includes a perldelta document where changes
compared to last version is described, so you could study such
documents for versions later than 5.004, e.g.
http://www.perldoc.com/perl5.8.0/pod/perl5005delta.html
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 03 May 2003 11:04:21 +0200
From: "Nico Coetzee" <abuse@mweb.co.za>
Subject: FreeTDS and DBD on Windows/Cygwin ???
Message-Id: <pan.2003.05.03.09.04.18.798351@mweb.co.za>
I want to port some of my dev stuff from Linux to Windows ( MS SQL Server
). The original Perl scripts were build with FreeTDS and DBD::Sybase ( if
I remember correctly ) on Linux to connect to the MS SQL Server.
Has anyone been able to build FreeTDS on Windows? Can I do it in Cygwin?
What are your thoughts?
Thanks for sharing your experiences :)
Cheers
--
Nico Coetzee
http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/
To the systems programmer, users and applications serve only to provide a
test load.
------------------------------
Date: Sat, 03 May 2003 08:32:49 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Is it possible to pass @somethig and $something_else to sub
Message-Id: <tfv6bvgbr8segr8cq8g329cvh8cgmuqmv3@4ax.com>
Michael P. Broida wrote:
> Well, I'll play with using () and NOT using & and try to
> figure out the prototypes so I'm "clean". <grin>
Prototypes are generally considered a bad idea. So if you don't have a
good grasp on them, and have a good reason to use them, better avoid
them.
See this article fopr a good intro on the good and bad of prototypes:
<http://www.perl.com/pub/a/language/misc/fmproto.html>
--
Bart.
------------------------------
Date: Sat, 3 May 2003 06:00:58 -0400
From: "Andrew" <45724remove@yahoo.com>
Subject: Re: Is there any way to debug PerlScript used in ASP?
Message-Id: <b90401$eb6e5$1@ID-51798.news.dfncis.de>
Thanks, what is it ?
> > Is there any way to debug PerlScript used in ASP?
>
> Yes.
------------------------------
Date: 3 May 2003 10:40:59 GMT
From: Rudolf Polzer <denshimeiru-sapmctacher@durchnull.ath.cx>
Subject: Re: Is there any way to debug PerlScript used in ASP?
Message-Id: <slrnbb7767.ouj.denshimeiru-sapmctacher@message-id.durchnull.ath.cx>
Scripsit iste aut ista »Andrew« <45724remove@yahoo.com>:
> > > Is there any way to debug PerlScript used in ASP?
> >
> > Yes.
>
> Thanks, what is it ?
If nothing else helps: print together with Data::Dumper. Open a logfile
and regularily print some debugging output to it.
That, however, only works if YOU have written the script. Would be
too much work otherwise. You will have to see "why does $VARX contain
'foo'? I checked for that before and it wasn't there" and try a binary
search for the error. If you know your code, that works really fast.
Whether there is some specialized debugger for ASP I don't know.
--
Koroshiteyaru. Koroshiteyaru. Koroshiteyaru. Koroshiteyaru...
[Asuka in Neon Genesis Evangelion - english: "I'll kill you"]
------------------------------
Date: Sat, 03 May 2003 11:00:48 +0200
From: "Nico Coetzee" <abuse@mweb.co.za>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <pan.2003.05.03.09.00.46.806802@mweb.co.za>
On Sat, 03 May 2003 03:14:53 +0000, John W. Krahn wrote:
> "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
I have similar code and sometines it really started as a 25-30 line block
which ends up that much. The only thing to do then is to start breaking it
down into logical sections, of which you then produce functions ( subs ).
Unfortunately this takes time and is not always fun - hence some of my
code still contains this 'feature' :)
Luckily with NEdit ( and I presume many of the others mentioned here ) we
have split screens, so I can see the first and last couple of lines at
once and it all makes sence again. NEdit also has a visual indicator to
show you the bracket pares ( when you move you curser over one, the 'mate'
is highlighted in red ).
Have fun...
--
Nico Coetzee
http://www.itfirms.co.za/
http://za.pm.org/
http://forums.databasejournal.com/
To the systems programmer, users and applications serve only to provide a
test load.
------------------------------
Date: 3 May 2003 10:43:34 GMT
From: Rudolf Polzer <denshimeiru-sapmctacher@durchnull.ath.cx>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <slrnbb77b1.ouj.denshimeiru-sapmctacher@message-id.durchnull.ath.cx>
Scripsit ille »Nico Coetzee« <abuse@mweb.co.za>:
> On Sat, 03 May 2003 03:14:53 +0000, John W. Krahn wrote:
> > "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
>
> I have similar code and sometines it really started as a 25-30 line block
> which ends up that much. The only thing to do then is to start breaking it
> down into logical sections, of which you then produce functions ( subs ).
> Unfortunately this takes time and is not always fun - hence some of my
> code still contains this 'feature' :)
>
> Luckily with NEdit ( and I presume many of the others mentioned here ) we
> have split screens, so I can see the first and last couple of lines at
> once and it all makes sence again. NEdit also has a visual indicator to
> show you the bracket pares ( when you move you curser over one, the 'mate'
> is highlighted in red ).
vi doesn't have that feature, but something else which might be good in those
cases:
You see:
# ...
}
else
{
# ...
}
Move over the closing brace before the else and press %. You will be
near the matching if.
--
Doch - alles, was dazu mich trieb,
Gott! war so gut! ach, war so lieb!
------------------------------
Date: Sat, 03 May 2003 06:05:08 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <Xns9370480B86749sdn.comcast@216.166.71.239>
"Michael P. Broida" <michael.p.broida@boeing.com> wrote in
news: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.
The indenting style, like just about everything else in emacs, is
incredibly customizable.
Emacs's Cperl-mode will also highlight a matching brace or parenthesis when
you move the cursor over one. Also, Meta-Control-b and Meta-Control-f will
move the cursor forward and backward over matching braces.
--
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
------------------------------
Date: Sat, 03 May 2003 13:54:06 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl Editor : Whats Recommended
Message-Id: <2SPsa.5426$gf3.1254@nwrddc03.gnilink.net>
Nico Coetzee wrote:
> On Sat, 03 May 2003 03:14:53 +0000, John W. Krahn wrote:
>
>> "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. :-)
>
> I have similar code and sometines it really started as a 25-30 line
> block which ends up that much. The only thing to do then is to start
> breaking it down into logical sections, of which you then produce
> functions ( subs ). Unfortunately this takes time and is not always
> fun - hence some of my code still contains this 'feature' :)
One of our basic rules we had at the university was that if a function did
not fit on a single screen (we were still using VT100 terminals) then you
better had a very good reason why or you would get a fail for your homework.
For those of us too young to remember VT100s: they had only 24 lines of
text, no GUI.
I still believe this is a very good rule even today. If a single function
has more than about 20 lines then it is too complex and too difficult to
read. Sooner or later you or someone else will pay the price.
An importent additional benefit I noticed is that being limited in size
forces you to think about the logic of your program much more clearly
because otherwise you won't be able to split it into meaningful separate
subroutines.
Of course there are exceptions like e.g. a large dispatch table where you
repeat the same task 100 times.
jue
------------------------------
Date: Sat, 03 May 2003 12:46:00 GMT
From: Justin <imarinejt@hotmail.com>
Subject: Perl Socket Question
Message-Id: <08e7bvcndck3ceo262qcilg7nr1sgk1rk3@4ax.com>
Hi,
I have the following code:
my $wb_server = IO::Docket::INET->new(LocalPort => $wb_server_port,
Proto => "tcp",
Listen => 250 ) or die "error";
my $lc_server = IO::Socket::INET->new(LocalPort => $lc_server_port,
Proto => "udp") or die "Error UDP";
This code works, however if I insert a listen => 10 into the UDP server connection I get
an error. Anyone explain why this is?
Cheers
Justin
------------------------------
Date: Sat, 03 May 2003 08:58:45 GMT
From: "joe" <tunmaster@hotmail.com>
Subject: string checking, before using in SENDMAIL -> 'één' has to become 'een'
Message-Id: <9xLsa.1165127$sj7.47770038@Flipper>
Hi there,
This is what it is. I'd like people to send emails through my site using
SENDMAIL. But I'm afraid using the users input in the email, can hang the
server if not checked properly. So I have to do some taintchecking. But I
don't know what to expect for an email.
I thought it to be a wise thing to replace all the not to often occurring
characters with a questionmark, like this:
$::x2 =~ s/[^\w\s\n.,:;+-=\[\]()!@#$%&?<>]/?/g;
I can perfectly live with that, wasn't it that a string like "Één
goedemiddag" will become "??n goedemiddag".
Is there a better way to make sure a string doesn't contain any dangerous
codes or if I like the above code, it's just fine. But how than can I make
"Een goedemiddag" out of the first string?
I'd really appreciate it if someone could help me out here!
TIA
Joe
------------------------------
Date: Sat, 03 May 2003 09:17:22 GMT
From: "Nils Petter Vaskinn" <no@spam.for.me.invalid>
Subject: Re: What is the best software to run for an aspiring Perl programer?
Message-Id: <pan.2003.05.03.09.17.22.297658@spam.for.me.invalid>
On Wed, 30 Apr 2003 11:51:32 -0700, dalgould wrote:
> Hello,
[snip]
> I would like to test my perl script locally
> on my computer first. What is the best software to run for an aspiring
> Perl programer, on my home computer?
[snip]
http://www.google.com/search?q=perl+cgi+debug gave a few interesting hits
(and lots of uninteresting ones to people's scripts called something with
debug)
http://perl.about.com/library/weekly/aa080901a.htm looked most promising
but I didn't read through it.
What webserver are your scripts running on? If possible try to get the
same webserver running at home, with configuration and environment as
close to the real server's as possible. While debugging single scripts is
nice seeing the complete site running before you load it on the real
server can prevent some embarassment.
In all programming it pays off to recreate the environment a program will
run in when testing, since if you test it on a development machine you
might not see errors from missing components (eg you depend on a perl
module that isn't on the server)
And ignore the advice to stop aspiring, everyone has to start somewhere
and noone knew everything right away.
regards
NP
------------------------------
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 4930
***************************************