Noob question

this may be a stupid question, and i might have even overlooked it in the
pickaxe, but what code do i need to insert in my program so it takes
parameters passed by the shell as variables?
greetings, Dirk.

ARGV are the parameters. $0 is the program name.

ARGF is another odd tool for some tasks. I recommend avoiding it
unless it is for simple scripts.

Brian.

···

On 9/25/05, Dirk Meijer <hawkman.gelooft@gmail.com> wrote:

this may be a stupid question, and i might have even overlooked it in the
pickaxe, but what code do i need to insert in my program so it takes
parameters passed by the shell as variables?
greetings, Dirk.

parameters passed in through the shell can be grabbed through the global
array ARGV

so .. for example, if in the shell i were to type:

% ruby crawl.rb July 2005

"July" would be ARGV[0]
and "2005" would be ARGV[1]

luke

ps) i'm a n00b too, so as far as i know this is right :> works for me with
ssh anyway.

"Dirk Meijer" <hawkman.gelooft@gmail.com> wrote in message
news:b1188aec0509252225733ce9b@mail.gmail.com...
this may be a stupid question, and i might have even overlooked it in the
pickaxe, but what code do i need to insert in my program so it takes
parameters passed by the shell as variables?
greetings, Dirk.

<snip>

ARGF is another odd tool for some tasks.

That strikes me as a peculiar statement.

I recommend avoiding it unless it is for simple scripts.

Why?

Regards,
Doug

···

On Mon, Sep 26, 2005 at 02:32:15PM +0900, Brian Mitchell wrote:

I'm not sure why you say this.

ARGF is a tool for building Unix style filters. If you believe filters are the way to go in data processing, as I do, you use it all the time.

James Edward Gray II

···

On Sep 26, 2005, at 12:32 AM, Brian Mitchell wrote:

ARGF is another odd tool for some tasks. I recommend avoiding it
unless it is for simple scripts.

To clarify the statement, it has multiple behaviors and can change the
semantics of the command line. Odd behavior that happens to fit
naturally with data filters. I guess it depends on how you look at it.

I tend to avoid it like I said, as I like to be more explicit about my
how I treat my parameters. Again, I should have noted that it was more
opinion than hard fact. Sorry for the lazy posting. :slight_smile:

Brian.

···

On 9/26/05, James Edward Gray II <james@grayproductions.net> wrote:

On Sep 26, 2005, at 12:32 AM, Brian Mitchell wrote:

> ARGF is another odd tool for some tasks. I recommend avoiding it
> unless it is for simple scripts.

I'm not sure why you say this.

ARGF is a tool for building Unix style filters. If you believe
filters are the way to go in data processing, as I do, you use it all
the time.

James Edward Gray II