/* * call-seq: * global_variables => array * * Returns an array of the names of global variables. * * global_variables.grep /std/ #=> ["$stderr", "$stdout", "$stdin"] */ VALUE rb_f_global_variables() { VALUE ary = rb_ary_new(); char buf[4]; char *s = "&`'+123456789"; st_foreach(rb_global_tbl, gvar_i, ary); if (!NIL_P(rb_backref_get())) { while (*s) { sprintf(buf, "$%c", *s++); rb_ary_push(ary, rb_str_new2(buf)); } } return ary; }