Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 romping around the Monastery: (4)
As of 2018-09-23 23:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Eventually, "covfefe" will come to mean:













    Results (191 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!