Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by tilly (Archbishop)
on Oct 27, 2003 at 23:22 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://302567]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-26 08:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found