When I receive lines one by one, why do programmers sometimes write:
set line = ($<)
set line = ($line)
What exactly do those rows mean?
When I receive lines one by one, why do programmers sometimes write:
set line = ($<)
set line = ($line)
What exactly do those rows mean?
Hi Chan,
I found a csh overview here: http://linux.die.net/man/1/csh
I appreciate you may not use Linux but I always found O'Reilly's Linux in a Nutshell book great for shell scripting.
To specifically address your questions (from the post above so I could be wrong!)
Of course, like all things with Csh - you should probably just use Bash and live happier :)
Dan
set line = ($<)
This reads a line of input from stdin and then splits it into an array, separating words by white-space, so that $line[1]
is the first word, $line[2]
is the second word and so on.
set line = ($line)
This does the same as above, but where $line might have been a single word, it will become an array of words. i.e.:
set line = ($<)
is the same as:
set line = "$<"
set line = ($line)