--=-WcM5+U4SL0cR+iGFMkvS
Content-Type: multipart/alternative; boundary="=-AWc4XdvKKeRBoE7GubRp"


--=-AWc4XdvKKeRBoE7GubRp
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

On Fri, 2007-07-09 at 14:17 +0900, Todd A. Jacobs wrote:

> Contrary to my expectations, if I have some variable assignments in an
> external file, I can't simply call:
>=20
>     load rcfile
>=20
> to have it sourced. Instead, I found myself having to do this:
>=20
>     IO.foreach(rcfile) do |line|
> 	eval line
>     end
>=20
> which seems lame. Is there a better way?



#test1.rb:

        @a =3D 5
        @b =3D 4
       =20
        require 'test2'
       =20
        p @a
        p @b
        p @c

#----8<-----

#test2.rb:

        @b =3D 3
        @c =3D 2


$ ruby test1.rb
5
3
2
$

Or am I missing something?
--=20
Michael T. Richter <ttmrichter / gmail.com> (GoogleTalk:
ttmrichter / gmail.com)
So much of what we call management consists in making it difficult for
people to work. (Peter Drucker)

--=-AWc4XdvKKeRBoE7GubRp
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; CHARSET=3DUTF-8">
  <META NAME=3D"GENERATOR" CONTENT=3D"GtkHTML/3.12.1">
</HEAD>
<BODY>
On Fri, 2007-07-09 at 14:17 +0900, Todd A. Jacobs wrote:
<BLOCKQUOTE TYPE=3DCITE>
<PRE>
<FONT COLOR=3D"#000000">Contrary to my expectations, if I have some variabl=
e assignments in an</FONT>
<FONT COLOR=3D"#000000">external file, I can't simply call:</FONT>

<FONT COLOR=3D"#000000">    load rcfile</FONT>

<FONT COLOR=3D"#000000">to have it sourced. Instead, I found myself having =
to do this:</FONT>

<FONT COLOR=3D"#000000">    IO.foreach(rcfile) do |line|</FONT>
<FONT COLOR=3D"#000000">	eval line</FONT>
<FONT COLOR=3D"#000000">    end</FONT>

<FONT COLOR=3D"#000000">which seems lame. Is there a better way?</FONT>
</PRE>
</BLOCKQUOTE>
<PRE>

</PRE>
#test1.rb:<BR>
<BLOCKQUOTE>
    <TT>@a =3D 5</TT><BR>
    <TT>@b =3D 4</TT><BR>
    <BR>
    <TT>require 'test2'</TT><BR>
    <BR>
    <TT>p @a</TT><BR>
    <TT>p @b</TT><BR>
    <TT>p @c</TT><BR>
</BLOCKQUOTE>
#----8&lt;-----<BR>
<BR>
#test2.rb:<BR>
<BLOCKQUOTE>
    <TT>@b =3D 3</TT><BR>
    <TT>@c =3D 2</TT><BR>
</BLOCKQUOTE>
<BR>
<TT>$ </TT><TT><B>ruby test1.rb</B></TT><BR>
<I><TT>5</TT></I><BR>
<I><TT>3</TT></I><BR>
<I><TT>2</TT></I><BR>
<TT>$</TT><BR>
<BR>
Or am I missing something?<BR>
<TABLE CELLSPACING=3D"0" CELLPADDING=3D"0" WIDTH=3D"100%">
<TR>
<TD>
-- <BR>
<B>Michael T. Richter</B> &lt;<A HREF=3D"mailto:ttmrichter / gmail.com">ttmri=
chter / gmail.com</A>&gt; (<B>GoogleTalk:</B> ttmrichter / gmail.com)<BR>
<I>So much of what we call management consists in making it difficult for p=
eople to work. (Peter Drucker)</I>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>

--=-AWc4XdvKKeRBoE7GubRp--

--=-WcM5+U4SL0cR+iGFMkvS
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQBG4OPmLqyWkKVQ54QRAonVAJ9VAX9SOQ/2Q6wq5btN/cCSijdgIgCfXVBn
D7TCmkerXek1CS9KkDRrCIY=
=g3BK
-----END PGP SIGNATURE-----

--=-WcM5+U4SL0cR+iGFMkvS--