Re: [Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-10 Thread Balachandran Sivakumar
Hi,

On Sat, Dec 10, 2011 at 9:17 AM, Suraj Kumar su...@careergear.in wrote:



 I'd once again request you to stop demeaning the stuff you're trying to
 teach (or thrust your impartial views onto a public forum like this). Why
 would anyone want to learn something that is, according to your narrow
 understanding, is worthless?


 He is not demeaning anything. He has an opinion that he is
expressing. You talk like Mr . Kapil Sibal. I use Perl is my job and I
have used Python as well. I can tell you from experience that even
well written Perl code is quite difficult to read when compared to a
well written Python code. Please don't hurry to say Well, then it is
not well written. And to reply to your accusation, this is Randall
Schwartz says in his Learning Perl book.

Perl is good for quick-and-dirty programs that you can whip up in
three minutes.

Now, did Girish say something different ?

And the same book also says, Perl is kind of ugly, This is true..

You may love a language, but do jump at some one who points out a few
negatives of what you love.




 An illiterate will (almost always) write horrible poetry. This is a highly
 subjective (and highly inflammable ;) ) bait. Perhaps you're judging perl
 by your (or your peers') inability to write elegant code? A sword, to a
 Samurai, is more elegant than a pistol.


 You are getting into personal attacks which is a very bad trait.
When a language has a variable like $| and people use such stuff
frequently, I wouldn't call that language elegant. Another thing is,
you always seem to have the opinion that anyone who tells  something
negative about Perl is an illiterate or doesn't know how to write
Perl. That is not the case. When it comes to readability, I find
Python to be much much easier then Perl or C. C is a language that I
like very much. But when someone says Python is more readable and
looks more elegant, I would most certainly agree.


 For that matter, why were you not forced to learn even perl deeply?


Another personal attack ? Can't people attack the points
mentioned without attacking the person. Thanks

-- 
Thank you
Balachandran Sivakumar

Arise Awake and stop not till the goal is reached.
                                                             - Swami Vivekananda

Mail: benignb...@gmail.com
Blog: http://benignbala.wordpress.com/
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-10 Thread Balachandran Sivakumar
On Sat, Dec 10, 2011 at 3:16 PM, Balachandran Sivakumar
benignb...@gmail.com wrote:


 And the same book also says, Perl is kind of ugly, This is true..

 You may love a language, but do jump at some one who points out a few

  Well, I meant don't jump. Sorry for the typo.


-- 
Thank you
Balachandran Sivakumar

Arise Awake and stop not till the goal is reached.
                                                             - Swami Vivekananda

Mail: benignb...@gmail.com
Blog: http://benignbala.wordpress.com/
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-10 Thread 0


 An illiterate will (almost always) write horrible poetry. This is a highly
 subjective (and highly inflammable ;) ) bait. Perhaps you're judging perl
 by your (or your peers') inability to write elegant code? A sword, to a
 Samurai, is more elegant than a pistol.


   You are getting into personal attacks which is a very bad trait.

+1

Please avoid personal remarks in the list.

AFAIK, Teachers do add a bit of personal experience in their teaching. 
Your personal experience might be different and you are welcome to share it.

I know very little perl and I like Girish's tutorial emails. So, I hope, 
he continues his effort for the benefit of the list.

-- 
0
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-10 Thread Raja Subramanian
On Sat, Dec 10, 2011 at 3:16 PM, Balachandran Sivakumar
benignb...@gmail.com wrote:
 When a language has a variable like $| and people use such stuff
 frequently, I wouldn't call that language elegant.

You can always ask perl to use English.

Mathematics is full of symbols and it is very beautiful once you
understand their meaning. Perl is no different, and the symbols
are well chosen - Larry Wall is a linguist and considerable effort
has gone into these details.

Learning a programming language is much more than the
semantics. Suggest the focus of our discussion is directed
towards deeper topics.

- Raja
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-10 Thread ShivaS-InfoTech..
Hi Group,

Can anyone have Red-Hat 5, 5.4, 6 CD/iso images ?? If yes, please let me
know your tendency to help!!:)

Thanks in advance,
Siva..
9865524436
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-10 Thread Balachandran Sivakumar
Hi

On Sat, Dec 10, 2011 at 4:00 PM, Raja Subramanian
rajasuper...@gmail.com wrote:


 You can always ask perl to use English.


   I have seen people use that. But never used it myself. Also, it
seems to be less commonly used. Most discussions on the Internet do
not seem to use it.

 Mathematics is full of symbols and it is very beautiful once you
 understand their meaning. Perl is no different, and the symbols
 are well chosen - Larry Wall is a linguist and considerable effort
 has gone into these details.


 I agree that considerable discussions might have gone into
it. But may be mathematics might not be the right analogy. But again,
Perl was designed a couple of decades ago, and given its age, it might
have been the well chosen. Only that, in my opinion, it doesn't look
elegant. It does its job well, no doubt about that.

 Learning a programming language is much more than the
 semantics. Suggest the focus of our discussion is directed
 towards deeper topics.



   It had been mostly towards better things until this trend of
personal attacks started. But yes, there is more to learning a
language than its semantics. Thanks


-- 
Thank you
Balachandran Sivakumar

Arise Awake and stop not till the goal is reached.
                                                             - Swami Vivekananda

Mail: benignb...@gmail.com
Blog: http://benignbala.wordpress.com/
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-10 Thread 0

 Can anyone have Red-Hat 5, 5.4, 6 CD/iso images ?? If yes, please let me
 know your tendency to help!!:)


Don't hijack an existing thread, this thread deals with what the subject 
says. Create a *new* thread with proper subject and post your email 
again. By *new*, I mean *new*, Don't reply to an email and change the 
subject.

-- 
0
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-10 Thread Suraj Kumar
On Sat, Dec 10, 2011 at 3:16 PM, Balachandran Sivakumar 
benignb...@gmail.com wrote:

 He is not demeaning anything. He has an opinion that he is
 expressing. You talk like Mr . Kapil Sibal. I use Perl is my job and I


Thanks for that excellent piece of non-ad-hominem attack. :)



 have used Python as well. I can tell you from experience that even
 well written Perl code is quite difficult to read when compared to a
 well written Python code. Please don't hurry to say Well, then it is
 not well written. And to reply to your accusation, this is Randall
 Schwartz says in his Learning Perl book.



Agreed. English is the easiest to read. Python is easy. C is very difficult
(or would you prefer C to be placed before Perl?). Assembly is very very
difficult... and so on.




 You may love a language, but do jump at some one who points out a few
 negatives of what you love.


1. I just ask you to imagine replacing this entire analogy to introducing
GNU/Linux to the uninitiated. Imagine, if someone kept telling you that
GNU/Linux sucks compared to, say, OSX... yet you gotta learn GNU/Linux for
a reason not explained clearly.  Now, as a reader, I'd be (and was) highly
confused and become wary of approaching such a thing which is supposedly
sucky and the purpose of learning which I'm not clear.

2. Imagine, being told that writing code in C is not advisable in
comparison to Python because C requires careful memory management. Of
course, it is a true statement (when looked at partially). But an
incorrect, impartial statement.

... and imagine 1  2 happening on a public forum.

Hence, I'd asked the OP to consider not doing these two above outlined
things.

I owe an apology to whoever that may have interpreted whatever I may have
said knowingly or unknowingly to cause damage to their identity. Let's
please end this thread that has gone beserk.

regards,

  -Suraj

-- 
Career Gear - Industry Driven Talent Factory
http://careergear.in/
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-10 Thread Natarajan V
On Sat, Dec 10, 2011 at 3:16 PM, Balachandran Sivakumar
benignb...@gmail.com wrote:
 An illiterate will (almost always) write horrible poetry. This is a highly
 subjective (and highly inflammable ;) ) bait. Perhaps you're judging perl
 by your (or your peers') inability to write elegant code? A sword, to a
 Samurai, is more elegant than a pistol.

Warning: ThreadJacking :-)
A related article in SlashDot recently...
http://developers.slashdot.org/story/11/12/09/1533252/java-apps-have-the-most-flaws-cobol-the-least

--
Natarajan
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-09 Thread Suraj Kumar
On Fri, Dec 9, 2011 at 8:24 AM, Girish Venkatachalam 
girishvenkatacha...@gmail.com wrote:

 I have not yet understood how map() works. It is a functional
 programming concept.


map is a means of transforming (mapping) an array into another array. The
arguments to map are:

1. function which will take one element at a time and return one element
2. the array of elements

As an example, if one would like to calculate the square of numbers in an
array and store them in another array, one can use map to do it as follows:

@x = (1,2,3,4,5);
@y = map { $_ * $_; } @x;

or simply

@y = map { $_ * $_; } (1, 2, 3, 4, 5);

When map invokes the provided function (first arg) it is called with $_ set
to each element of the array and is called one time for each element in the
order of appearance of its arguments. Let's use map now to also print the
array @y:

map { print $_ . \n; } @y
1
4
9
16
25


Here is an exercise to the reader: Using a combination of regexes and map,
read a HTML file and turn all its a href=(.*?)(.*?)/a into a hash
where the URI is the key of the hash and the marked up text (anchor text)
becomes the value. The following is a sample test input string:

$string = EOM;

a href=/blahGo to blah/a and a href=/blah/searchlook for all the
blahs/a... and here is a a href=/multimulti
line
 emnested/em HTML markup
/a
EOM

In a lot of ways perl is messy and with a syntax that is so odd that
 it is often called

 The write once forget language

 In other words perl is used for quick and dirty jobs.


I'd once again request you to stop demeaning the stuff you're trying to
teach (or thrust your impartial views onto a public forum like this). Why
would anyone want to learn something that is, according to your narrow
understanding, is worthless?

If you think something is tough, it will remain tough and unapproachable
(because the problem of 'toughness', etc., is in your mind). If you're full
of your own preconceived notions, it is very difficult to change it unless
you're willing to throw away those notions and then explore and learn about
it (there is nothing to lose when learning, except time :) ).

Think about it, programming a computer was not any friendlier back then,
yet, that is what paved way for generic abstractions that allowed us to
build cooler stuff on top. Perl too, if you approached it this way, can be
effectively used to abstract away problems and build generic solutions on
top. But you should be willing to invest time in abstracting and designing
your code thus. If you expect a scissor to do what a chainsaw can (and vice
versa) then it is not the tool that is at fault.


Perl on the other hand is a high level language. It is a scripting
 language; which means that it is a
  language used to express your ideas in a language that looks like English.

 This could be said of python but perl is not even half as elegant.


An illiterate will (almost always) write horrible poetry. This is a highly
subjective (and highly inflammable ;) ) bait. Perhaps you're judging perl
by your (or your peers') inability to write elegant code? A sword, to a
Samurai, is more elegant than a pistol.


 Why was I not forced to learn Python deeply? But perl is something I
 use everywhere. This should give you a hint.


For that matter, why were you not forced to learn even perl deeply?

Cheers,

  -Suraj

-- 
Career Gear - Industry Driven Talent Factory
http://careergear.in/
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


Re: [Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-09 Thread Pratap Chakravarthy
I know couple of friends who rave about perl. Especially I hear that
the first 2 chapters of Programming Perl by Larry Wall is a must read
for every programmers. With all its goodness Perl seem to foster a
kind of cryptic programming, demanding a lot of meditation to
understand its logic, especially when the logic was crafted by some
one else. The OP has got some truth in his article, although slightly
out of context, but hey every one is entitled to their opinion don't
they ? May be it is more to do with the style of writing and less to
do with their opinion. May be.

Cheers,

On Sat, Dec 10, 2011 at 9:17 AM, Suraj Kumar su...@careergear.in wrote:
 On Fri, Dec 9, 2011 at 8:24 AM, Girish Venkatachalam 
 girishvenkatacha...@gmail.com wrote:

 I have not yet understood how map() works. It is a functional
 programming concept.


 map is a means of transforming (mapping) an array into another array. The
 arguments to map are:

 1. function which will take one element at a time and return one element
 2. the array of elements

 As an example, if one would like to calculate the square of numbers in an
 array and store them in another array, one can use map to do it as follows:

 @x = (1,2,3,4,5);
 @y = map { $_ * $_; } @x;

 or simply

 @y = map { $_ * $_; } (1, 2, 3, 4, 5);

 When map invokes the provided function (first arg) it is called with $_ set
 to each element of the array and is called one time for each element in the
 order of appearance of its arguments. Let's use map now to also print the
 array @y:

 map { print $_ . \n; } @y
 1
 4
 9
 16
 25


 Here is an exercise to the reader: Using a combination of regexes and map,
 read a HTML file and turn all its a href=(.*?)(.*?)/a into a hash
 where the URI is the key of the hash and the marked up text (anchor text)
 becomes the value. The following is a sample test input string:

 $string = EOM;

 a href=/blahGo to blah/a and a href=/blah/searchlook for all the
 blahs/a... and here is a a href=/multimulti
 line
  emnested/em HTML markup
 /a
 EOM

 In a lot of ways perl is messy and with a syntax that is so odd that
 it is often called

 The write once forget language

 In other words perl is used for quick and dirty jobs.


 I'd once again request you to stop demeaning the stuff you're trying to
 teach (or thrust your impartial views onto a public forum like this). Why
 would anyone want to learn something that is, according to your narrow
 understanding, is worthless?

 If you think something is tough, it will remain tough and unapproachable
 (because the problem of 'toughness', etc., is in your mind). If you're full
 of your own preconceived notions, it is very difficult to change it unless
 you're willing to throw away those notions and then explore and learn about
 it (there is nothing to lose when learning, except time :) ).

 Think about it, programming a computer was not any friendlier back then,
 yet, that is what paved way for generic abstractions that allowed us to
 build cooler stuff on top. Perl too, if you approached it this way, can be
 effectively used to abstract away problems and build generic solutions on
 top. But you should be willing to invest time in abstracting and designing
 your code thus. If you expect a scissor to do what a chainsaw can (and vice
 versa) then it is not the tool that is at fault.


 Perl on the other hand is a high level language. It is a scripting
 language; which means that it is a
  language used to express your ideas in a language that looks like English.

 This could be said of python but perl is not even half as elegant.


 An illiterate will (almost always) write horrible poetry. This is a highly
 subjective (and highly inflammable ;) ) bait. Perhaps you're judging perl
 by your (or your peers') inability to write elegant code? A sword, to a
 Samurai, is more elegant than a pistol.


 Why was I not forced to learn Python deeply? But perl is something I
 use everywhere. This should give you a hint.


 For that matter, why were you not forced to learn even perl deeply?

 Cheers,

  -Suraj

 --
 Career Gear - Industry Driven Talent Factory
 http://careergear.in/
 ___
 ILUGC Mailing List:
 http://www.ae.iitm.ac.in/mailman/listinfo/ilugc



-- 
Pratap.
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc


[Ilugc] [TIP] perl tutorial VII (perl tricks)

2011-12-08 Thread Girish Venkatachalam
Perl is a language full of tricks because it is nothing but UNIX command line
tools with some innovations of its own like regex extensions, easy and
 well integrated OO to solve complex problems easily, easy file I/O, easy
 socket I/O, easy IPC facilities in UNIX and so on.

However using pack(), vec(), map() and so on is hard.

I have not yet understood how map() works. It is a functional
programming concept.

pack() is used for binary protocols and for encoding in various forms.

In a lot of ways perl is messy and with a syntax that is so odd that
it is often called

The write once forget language

In other words perl is used for quick and dirty jobs.

But that is not strictly true. Perl is also used a lot in serious
tasks and many UNIX utilities
 are built with perl. The entire package management in OpenBSD which
is the best package management tool
in the UNIX world developed by Marc Espie, a French gentleman is in
perl using perl OO.

Perl is slow and not really as fast as C. It can never be faster than C.

In fact C is a middle level language which acts as a low level
language in the kernel(particularly bootup startup code)
 and as a high level language when used for GUI like GTK and as  a
middle level language in most applications
like networking, I/O and so on.

Perl on the other hand is a high level language. It is a scripting
language; which means that it is a
 language used to express your ideas in a language that looks like English.

This could be said of python but perl is not even half as elegant.

It is only its integration with UNIX ideas, its superb ability to copy
great ideas and integrate well that it
 is such a hit amongst UNIX geeks like me.

Why was I not forced to learn Python deeply? But perl is something I
use everywhere. This should give you a hint.

Anyway let us get down to business.

die The program does not have any sense!\n unless(/something important/);

This is an example to prove that perhaps perl is like English and a script.

What is a script?

A script is written by hand or a poem or Haiku or a scrawl.

Perl can be used that way. It can be used without much thought about
efficiency or variable scoping, typing
 or declaring.

All perl variables are by default global. By global people say file
scope, package scope and so on.

Anyway let us not get into that.

Let us see another example.

$ perl i.pl /etc/passwd
88ced295c57a727aadab4e626dad47b1df6c98e3
$ sha1 /etc/passwd
SHA1 (/etc/passwd) = 88ced295c57a727aadab4e626dad47b1df6c98e3
$ cat i.pl
use Digest::SHA1 qw(sha1_hex);

$digest = sha1_hex();

print $digest\n;

sha1 is a command in OpenBSD. On Linux you say sha1_sum which a GNU thing.

Anyway there are plenty of tricks one could do with the UNIX in perl.

Look at this:

$ cat i.pl
open PIPE, netstat -a|;

while(PIPE) {
print;
}

Here what we do is open a pipe to the netstat -a command. It lists all
the sockets in the system.

We can of course do this:

$ perl i.pl
   2   8  37
$ cat i.pl
open PIPE, |wc;

print PIPE What are you doing?\n;

print PIPE Let me count now\n;

close PIPE;

-Girish


-- 
G3 Tech
Networking appliance company
web: http://g3tech.in  mail: gir...@g3tech.in
___
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc