[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Article on oreilly.net on how to build Unix tools with Ruby

Xavier

9/19/2003 8:45:00 PM

Thought you'd like to know about this article
This links to the printable version, much easier to read.
http://linux.oreillynet.com/...

Enjoy.
23 Answers

Paul Brannan

9/23/2003 4:33:00 PM

0

On Sat, Sep 20, 2003 at 06:00:21AM +0900, Xavier wrote:
> Thought you''d like to know about this article
> This links to the printable version, much easier to read.
> http://linux.oreillynet.com/...
>
> Enjoy.

A pretty good article, though:
1. It would be nice if it mentioned optparse, which is a little
cleaner than getoptlong for what the author is doing.
2. Using "while line = gets do" is just as clean as "while gets", but
doesn''t require the use of $_. I suspect the author came from a
perl background.
3. I wish he''d mentioned the option of using #!/usr/bin/env ruby
instead of #!/usr/local/bin/ruby.

Paul


geoff

9/23/2003 6:09:00 PM

0

Xavier <NOSPAM@keepyourspam.com> wrote:
> Thought you''d like to know about this article
> This links to the printable version, much easier to read.
> http://linux.oreillynet.com/...

Nice script for handling CSVs. But it doesn''t handle commas embedded in
double quotes (yet).

--
Geoffrey S. Knauth | http://knau...

Jim Menard

9/23/2003 8:06:00 PM

0

geoff@knauth.org (Geoffrey S. Knauth) writes:

> Xavier <NOSPAM@keepyourspam.com> wrote:
> > Thought you''d like to know about this article
> > This links to the printable version, much easier to read.
> > http://linux.oreillynet.com/...
>
> Nice script for handling CSVs. But it doesn''t handle commas embedded in
> double quotes (yet).

If anyone wants one, I''ve got a DelimParser class that handles different
delimiters and quote marks as well as delimiters, escaped characters, and
doubled quotes that appear in the data.

It doesn''t use regexps. It''s a simple state machine that walks through each
character in the input.

Ask and thou shall receive.

Jim
--
Jim Menard, jimm@io.com, http://www.io....
"$665.95: The Retail Price of the Beast" -- Unknown

gabriele renzi

9/23/2003 8:50:00 PM

0

il 23 Sep 2003 15:06:01 -0500, Jim Menard <jimm@io.com> ha scritto::

>It doesn''t use regexps. It''s a simple state machine that walks through each
>character in the input.
>
>Ask and thou shall receive.


would you please send me a copy or publish it on RAA ?

Jim Menard

9/23/2003 9:44:00 PM

0

gabriele renzi <surrender_it@remove.yahoo.it> writes:


> il 23 Sep 2003 15:06:01 -0500, Jim Menard <jimm@io.com> ha scritto::
>
> >It doesn''t use regexps. It''s a simple state machine that walks through each
> >character in the input.
> >
> >Ask and thou shall receive.
>
>
> would you please send me a copy or publish it on RAA ?
>

Gabriele,

I emailed it to you and Michael and posted it to
<http://www.io....downloads/inde....

Jim
--
Jim Menard, jimm@io.com, http://www.io....
"Unix is extremely user-friendly. It also happens to be extremely
selective when picking its friends." -- Daniel E. Macks

Jim Freeze

9/23/2003 10:05:00 PM

0

On Wednesday, 24 September 2003 at 5:15:41 +0900, Jim Menard wrote:
> geoff@knauth.org (Geoffrey S. Knauth) writes:
>
> > Xavier <NOSPAM@keepyourspam.com> wrote:
> > > Thought you''d like to know about this article
> > > This links to the printable version, much easier to read.
> > > http://linux.oreillynet.com/...
> >
> > Nice script for handling CSVs. But it doesn''t handle commas embedded in
> > double quotes (yet).
>

I have found that the csv parser by NaHi to be very good and
full featured.

http://raa.ruby-lang.org/list.rhtm...


--
Jim Freeze
----------
God made the world in six days, and was arrested on the seventh.

Gavin Sinclair

9/23/2003 11:14:00 PM

0

On Wednesday, September 24, 2003, 2:33:01 AM, Paul wrote:

> 3. I wish he''d mentioned the option of using #!/usr/bin/env ruby
> instead of #!/usr/local/bin/ruby.


Can someone please explain to me what /usr/bin/env/ruby does?

Thanks,
Gavin


Michael W Thelen

9/23/2003 11:25:00 PM

0

* Gavin Sinclair <gsinclair@soyabean.com.au> [2003-09-23 17:16]:
> On Wednesday, September 24, 2003, 2:33:01 AM, Paul wrote:
> > 3. I wish he''d mentioned the option of using #!/usr/bin/env ruby
> > instead of #!/usr/local/bin/ruby.
>
> Can someone please explain to me what /usr/bin/env/ruby does?

Note that there''s no slash between "env" and "ruby"... env is a program that
lets you run a program in a modified environment, and it''s also useful on the
shebang line if you don''t know the exact location of the interpreter you want
to run. It will find the executable in the path before executing it.

-- Mike

--
Michael W. Thelen
Experience is what you get when you don''t get what you want.
-- Dan Stanford

Jim Freeze

9/24/2003 12:05:00 AM

0

On Wednesday, 24 September 2003 at 8:24:36 +0900, Michael W Thelen wrote:
> * Gavin Sinclair <gsinclair@soyabean.com.au> [2003-09-23 17:16]:
> > On Wednesday, September 24, 2003, 2:33:01 AM, Paul wrote:
> > > 3. I wish he''d mentioned the option of using #!/usr/bin/env ruby
> > > instead of #!/usr/local/bin/ruby.
> >
> > Can someone please explain to me what /usr/bin/env/ruby does?

Speaking of env, does this work on linux when options are passed
to ruby?

I''m not at a linux terminal right now, but when the shebang is:

/usr/bin/env ruby -w

I get the error that ruby -w is not found.
The gnu manual says that it should work, but it certainly
doesn''t work as it does on FreeBSD or Sun.

The distro is RH 7.3.


--
Jim Freeze
----------
Adore, v.:
To venerate expectantly.
-- Ambrose Bierce, "The Devil''s Dictionary"

Paul Brannan

9/24/2003 2:24:00 AM

0

On Wed, Sep 24, 2003 at 09:04:55AM +0900, Jim Freeze wrote:
> Speaking of env, does this work on linux when options are passed
> to ruby?

No, it doesn''t. I''ve seen a detailed explanation somewhere on a perl
mailing list or newsgroup, but I can''t remember the specifics.

Paul