Hi
I would be really great full , if any one can give me some light on how
to progress on bellow.
i am familiar with simple loop but this one seems complex.
Basically i am trying to do the something in bellow link but with ruby
( I don’t need full solution, i just need help with start the program)
Thanks for your help
i want to loop through some lines but condition will be :-
1)loop will start if line has word call “Base”
2) if it see a line has word
“Maximum size with extensions”
“Current size with extensions”
it will separate the value( I know how to do that )
It will scan lines till it finds a word call “Current size”
it will then escape all line until it find another word call “Base”
and will do the same till word call “Current Size”
Example :
Base file “dirs.dat”:
Device = /var/opt/omni/server/db40/datafiles/cdb
Number of extensions = 0
Maximum size = 2096128 [kB]
Current size = 88896 [kB]
Maximum size with extensions = 2096128 [kB]
Current size with extensions = 88896 [kB]
Base file “fn1.ext”:
Device = /var/opt/omni/server/db40/datafiles/cdb
Number of extensions = 0
Maximum size = 2096128 [kB]
Current size = 216640 [kB]
Maximum size with extensions = 2096128 [kB]
Current size with extensions = 216640 [kB]
if any one can help with Looping part… that will be really good .
Hi
I would be really great full , if any one can give me some light on how
to progress on bellow.
something like that ?
h={}
fname=“unknown”
File.read(IN).split(/\n/).each do |line|
label,value=line.split(/\s*=\s*/,2)
ivalue=value.scan(/\d+/).first.to_i if value
case line
when /^Base/
fname=line.scan(/(")(.*?)(")/).first[1] || “unknown”
h[fname]={max:-1,cur: -1}
when /^Maximum size with extensions/ then h[fname][:max]=ivalue
when /^Current size with extensions/ then h[fname][:cur]=ivalue
end
end
p h