A Basic CGI Script : CGI CGI Ruby



#!/usr/bin/ruby

puts "Content-type: text/htmlnn"
puts "<html><body>This is a test</body></html>"


If you called this script test.cgi then visiting http://www.example.com/test.cgi 

 

1 refers to the match of the first group : Regexps Group Development Ruby

#  the second group,and so on.

# Outside the pattern,the special variables $1, $2, and so on, serve the samepurpose. 

"12:50am" =~ /(dd):(dd)(..)/ # 0 
"Hour is #$1, minute #$2" # "Hour is 12, minute 50" 
"12:50am" =~ /((dd):(dd))(..)/ # 0 
"Time is #$1" # "Time is 12:50" 
"Hour is #$2, minute #$3" # "Hour is 12, minute 50" 
"AM/PM is #$4" # "AM/PM is am"