T
Thomas Adam
Hi All,
I am having a rather weird problem with array manipulation.
I have a file with a load of text in it, and I have a line which looks
like:
vthread << File.new(pathname,
"r").readlines().to_s().grep(/^foobar/).uniq()
the expression /^foobar/ is repeated throughout, but there are
differences. Now, I would assume there to be a new entry added to the
array each time grep returns a match. However, while the code does what I
want it to, doing a:
vthread.length()
returns "1"
Printing this single element to the screen does indeed yield the results,
but what I want it to do is to add the match each time into a new element
in the array.
Am I doing something silly?
Thank You All,
Thomas Adam
=====
"The Linux Weekend Mechanic" -- http://linuxgazette.net
"TAG Editor" -- http://linuxgazette.net
________________________________________________________________________
BT Yahoo! Broadband - Save £80 when you order online today. Hurry! Offer ends 21st December 2003. The way the internet was meant to be. http://uk.rd.yahoo.com/evt=21064/*http://btyahoo.yahoo.co.uk
I am having a rather weird problem with array manipulation.
I have a file with a load of text in it, and I have a line which looks
like:
vthread << File.new(pathname,
"r").readlines().to_s().grep(/^foobar/).uniq()
the expression /^foobar/ is repeated throughout, but there are
differences. Now, I would assume there to be a new entry added to the
array each time grep returns a match. However, while the code does what I
want it to, doing a:
vthread.length()
returns "1"
Printing this single element to the screen does indeed yield the results,
but what I want it to do is to add the match each time into a new element
in the array.
Am I doing something silly?
Thank You All,
Thomas Adam
=====
"The Linux Weekend Mechanic" -- http://linuxgazette.net
"TAG Editor" -- http://linuxgazette.net
________________________________________________________________________
BT Yahoo! Broadband - Save £80 when you order online today. Hurry! Offer ends 21st December 2003. The way the internet was meant to be. http://uk.rd.yahoo.com/evt=21064/*http://btyahoo.yahoo.co.uk