views:

295

answers:

11

My programming experience: I know Java, understand OOP and know some recursion.

I would like to learn how to write "scripts" for text processing, file handling and stuff like that. I'm fine with learning either Ruby or Python for this. I want a book that focuses on what I've mentioned above but most books just teach more than that (OOP, Data Structures...) and I don't have enough time for those.

So far, the book that I think is the most suitable is actually Learning Perl (the Llama book) as it is only 300+ pages long and teach what I want to learn. However, I don't wanna learn Perl.

So, in short, is there any Python or Ruby book that teaches what Learning Perl teaches?

+3  A: 

For your specific needs I would suggest these 2 books:

Learning Ruby

Everyday Scripting in Ruby

Please note that the Learning Ruby book is EXTREMELY ELEMENTARY possibly more so than Learning Perl. If you want a more robust treatment of ruby at the beginners level than I would recommend this one:

Pickaxe Programming Ruby

ennuikiller
+4  A: 

Why don't you want to learn Perl? It's a great language and a fine introduction to the world of scripting. And as you've found it has some of the best introductory texts out there.

I happen to be a long-time Perl programmer now working mostly in Python and I can't say I've seen anything to equal Learning Perl. I got my feet wet with Dive Into Python, and it's a good book but hardly suitable for a beginner.

Since you mentioned Ruby though, I have to say that Why's (Poignant) Guide to Ruby is hilarious and absolutely worth a read:

http://mislav.uniqpath.com/poignant-guide/

It's a shame he had to go.

samtregar
second the vote for Why's guide
ennuikiller
Perl is a gross hack of a language, with no consistent design or design principles. It's the worst introduction to scripting imaginable. Keep away.
Glenn Maynard
+3  A: 

O'Reilly books are pretty good.

The Ruby Programming Language

Learning Python

Then there is the pickaxe book for Ruby.

Programming Ruby 1.9: The Pragmatic Programmers' Guide

However, if your just wanting to do some basic stuff, like the text processing and file handling that you mention, then using Google is a good choice. There is a lot of information on the web for free about these topics that you can find through some simple searches.

FModa3
+5  A: 

The Llama book is a bit more "tutorial-like" that the following recommendation, but in you choose Python, you'll find the Python Cookbook O'Reilly pub. (Martelli, Ravenscroft and Asher) quite insightful.

Like the Llama, its chapters are structured around functional areas (file I/O, Searching and Sorting, Databases/Persitence, Debugging, User Interface, XML...). As with "cookbooks" the chapters are collections of task-oriented recipes, but beyond the working snippets, you get a good explanation of what and how things are done, along with references, some online, if you wish to dig further.

In a nutshell, a great book for both beginners and advanced Python programmers, without the "programming 101" type of presentation you wish to avoid.

mjv
+1  A: 

I'm rubyist, so my advice is about Ruby only.

1) At first, you should give a look to try Ruby in your browser

2) There is single book for studying Ruby - Programming Ruby. The Pragmatic Programmer's Guide (it's on Amazon for purchase as well as on the official site for reading) It could be used as reference, not as coursebook - you know all the basics from the first point.

3)Don't forget to use irb - it is interactive Ruby shell. Excellent for testing some code, and experiments

Merry coding!

kirushik
you can also try python in your browser: http://www.trypython.org/
Ravi
This doesn't really help him deal with text processing, it just teaches him the basics of Ruby.
Pod
2Pod, sorry, I was too lazy to search for the book philip refers to.So I simply advised him how to learn Ruby if you know all the concepts ("text processing, file handling and stuff like that"). If you know what Regex is, all you have to is to know where gsub is located.2Ravi. Thanks, bookmarked.
kirushik
+1  A: 

Text Processing in Python by David Mertz

Denis Otkidach
-1, disagree. I have that book, and IMHO it spends far too much time trying to turn Python into Haskell or some such. He starts out Chapter 1 writing a bunch of high-order functions, then suggests you use them to solve your problems; I would prefer a book, like the Python Cookbook, that uses Python idioms throughout.
steveha
A: 

the ruby book recommendations above are good, there are a bunch more on Amazon. The OO models for ruby, python and Java are different, it's worth looking at that stuff. The perl OO model stands apart (I think that's a nice euphemism!)


python: I like the Pilgrim and Hetlund books

http://www.amazon.com/Beginning-Python-Novice-Professional-Second/dp/1590599829/

http://diveintopython.org/toc/index.html

Again, a bunch more on Amazon.

Gene T
"stands apart". Mmmm. Diplomatic.
Mike Woodhouse
+1  A: 

Don't overlook Practical Ruby for System Administration by André Ben Hamou which is a great book with a terrible name. Andre comes from a Perl background (amongst a lot else). He goes through all kinds of practical examples such as:

  • one-liners like:

    $ ruby -ne 'puts $_ if $_ =~ /andre/' /etc/passwd /etc/group
    
  • extending the built-in File class to provide open_locked and open_safely methods

  • using metaprogramming techniques to make a DSL allowing a server to be configured with:

    server "bitbucket.example.com" do |srv| 
      srv.shares "/homes", :over => ["afp", "smb"], :as => "HOMES" 
    end
    

It's a funny and wide-reaching book which covers a lot of ground and includes some tricks (and opinions) I've not seen anywhere else.

edavey
A: 

Actually I've been thinking about this a little more and I think this book is an excellent resource for a beginner looking to learn ruby. Not only does it go through the basics but it teaches oop at a beginner level quite effectively. It is also a pleasure to read and actually keeps the readers asttention and interest (which the majority of technical books fail so thoroughly to do!). All in all this book is a gem (pun intended!!), well worth the 40 bucks you can get it for at amazon:

Design Patterns in Ruby

ennuikiller
-1? Reveal yourself!
ennuikiller
A: 

No book, but the PLEAC project aims to implement the solutions from the Perl Cookbook in many other languages, also ruby and python. Not all topics are fully covered, but topics like Strings are.

andre-r