http://qs321.pair.com?node_id=302444


in reply to Re: How's your Perl?
in thread How's your Perl?

3. who cares about deprecated, they still work ;-)

3/6. overload is a module which isn't allowed (though there are ways to circumvent that), but more importantly bless is explicitly forbidden by the rules

the others look good :-)

UPDATE Re 9: it really is q, not qq. (notice the eval? :-)

UPDATE 2 As Roy Johnson pointed out, your 3b currently doesn't work (it's only a small one-char mistake though)

UPDATE 3 Your 9a doesn't work, they print differently but compare numerically equal. make sure to test your answers with perl -e '......; eval(q[$$foo]) != eval(q[0+$$foo]) or die' rather than using print, to avoid traps like these :-)

UPDATE 4 ex 11 works.. note that you can place it in front by using glob-assign

UPDATE 5 strictly speaking the semi isn't needed to make the condition true (which is the exercise), but even if you do include it it's still possible by dropping the "" from the sub

Replies are listed 'Best First'.
Re: Re: Re: How's your Perl?
by tilly (Archbishop) on Oct 27, 2003 at 23:22 UTC
    If by a fix you mean sub bar {$bar[$_[0]]} $foo = *bar; $bar[1]="hi";, that does not work to the given spec.

    Test it with print "yes" if \$foo->(1) eq \$foo->[1] and you see that it fails for me on 5.8.1. Get rid of the backslashes and it works, but the problem is that Perl's functions are pass by reference, return by value. Therefore the return of bar(1) is a new string with the same value as $bar[1], but you get something different by taking a reference to it.

      ah yes, you're right.. it needs more than a one-char fix :-)

      the overall idea is still right though (as in, the correct solution is very similar to this), but I overlooked some details of your implementation