Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Re: How's your Perl?

by tilly (Archbishop)
on Oct 27, 2003 at 23:22 UTC ( #302567=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re: Re: Re: Re: How's your Perl?
by xmath (Hermit) on Oct 28, 2003 at 00:27 UTC
    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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://302567]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2018-11-14 10:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (171 votes). Check out past polls.

    Notices?