From the doc
-0digit =>
specifies the input record separator ($/) as an octal number. If no digits given, the null character is the separator. Other switches may follow the digits. -00 turns Ruby into paragraph mode. -0777 makes Ruby read whole file at once as a single string, since there is no legal character with that value.
My bad! Couldn’t digest it at all. So let’s started to play with it.
C:\>ruby -0777 -e 'a= gets; puts a '
Hi, This is Ram.
Could you help me here?
^Z #~~~> pressed ENTER here after CTRL+Z and got the output as below-
Hi, This is Ram.
Could you help me here?
C:\>ruby #~~~> return the prompt
C:\>ruby -000 -e 'a= gets; puts a '
Hi, This is Ram.
Could you help me here?
^Z #~~~> pressed ENTER here after CTRL+Z and got the output as below-
Hi, This is Ram.
Could you help me here?
C:\>ruby #~~~> return the prompt
C:\>ruby -00 -e 'a= gets; puts a '
Hi, This is Ram.
Could you help me here? #~~~> pressed ENTER
#~~~> pressed ENTER here and got the output as below-
Hi, This is Ram.
Could you help me here?
C:\>ruby #~~~> return the prompt
Question: 1 – Can I set such octal or $/ to as below ?
carraige return (\r)
tab (\t)
If so, Can I have one example for each to see their behaviours?
Question: 2 – I also tried to print the value of "$/" and nothing printed. So how should I see that?
C:\>ruby -00 -e 'a= gets; puts a ;puts "here is: #{$/}"'
hi
hi
here is:
C:\>ruby -0777 -e 'a= gets; puts a ;puts "here is: #{$/}"'
Hey! Arjun
Are you going school?
^Z
Hey! Arjun
Are you going school?
here is:
C:\>
From the Using as
Finally I found out the way about how to set the
carraige return (\r) and tab (\t).Find the below code:
Finally I could print with
.inspectas below :Want to share my whole day’s with ruby : 🙂
From the above link : ASCII Code
I got the octal code of many more escape characters and also played with them with Ruby command line
-0<digit>option:Here is the full list of example.. read and digest it. 🙂