O
orbit
Whot can I set value for variable which name cosist ather variable?
var1 = "@var2"
var1 = "@var2"
orbit said:Whot can I set value for variable which name cosist ather variable?
var1 = "@var2"
Whot can I set value for variable which name cosist ather variable?
var1 = "@var2"
I want, that as in Perl was
cat p1.pl
#!/usr/bin/perl
$foo = "xo-xo";
print "1 - foo = $foo\n";
$scalarref = \$foo;
$$scalarref = "xe-xe";
print "2 - foo = $foo\n";
../p1.pl
1 - foo = xo-xo
2 - foo = xe-xe
orbit said:(e-mail address removed) (orbit) wrote in message
I want, that as in Perl was
cat p1.pl
#!/usr/bin/perl
$foo = "xo-xo";
print "1 - foo = $foo\n";
$scalarref = \$foo;
$$scalarref = "xe-xe";
print "2 - foo = $foo\n";
./p1.pl
1 - foo = xo-xo
2 - foo = xe-xe
(e-mail address removed) (orbit) wrote in message
I want, that as in Perl was
cat p1.pl
#!/usr/bin/perl
$foo = "xo-xo";
print "1 - foo = $foo\n";
$scalarref = \$foo;
$$scalarref = "xe-xe";
print "2 - foo = $foo\n";
../p1.pl
1 - foo = xo-xo
2 - foo = xe-xe
I want, that as in Perl was
cat p1.pl
#!/usr/bin/perl
$foo = "xo-xo";
print "1 - foo = $foo\n";
$scalarref = \$foo;
$$scalarref = "xe-xe";
print "2 - foo = $foo\n";
../p1.pl
1 - foo = xo-xo
2 - foo = xe-xe
They do, but that example is a hard reference which isn't discouraged.Michael said:I think that even the royal perl monarchy discourage the use of
softrefs as "bad practice", no?
They do, but that example is a hard reference which isn't discouraged.
The following is a soft, or symbolic reference,
$foo = "xo-xo";
print "1 - foo = $foo\n";
$scalarref = "foo"; #"foo" rather than \$foo
$$scalarref = "xe-xe";
print "2 - foo = $foo\n";
String#replace replaces the contents of the string with the argument
passed.
But everything in ruby is done by reference, so there is no clean way
of doing what you are talking about that works for every type. This is
one of those things that really bugged me at first, but I eventually
liked; Not being able to do tricks like that doesn't seem to hamper my
code any, and leaves it much easier to understand.
I would recommend leaving the pointers to C and Perl
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.