Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re (tilly) 3: (Golf) Strings-to-Array

by tilly (Archbishop)
on Sep 01, 2001 at 05:13 UTC ( #109590=note: print w/ replies, xml ) Need Help??


in reply to Re: Re (tilly) 1: (Golf) Strings-to-Array
in thread (Golf) Strings-to-Array

In Perl 5.6.0 if you passed in literal strings, you got an error about, "Modification of a read-only value attempted". Recopying @_ fixed that.

And the time when $s and $s.0 are different in boolean context is when $s is "0". So when you remove those two characters, you get a bug.

UPDATE
An example that shows the bug:

print map "$_\n", r("0a1", "b0", "0");


Comment on Re (tilly) 3: (Golf) Strings-to-Array
Download Code
Replies are listed 'Best First'.
Re: Re (tilly) 3: (Golf) Strings-to-Array
by demerphq (Chancellor) on Sep 01, 2001 at 18:27 UTC
    Hi Tilly.

    Ok so on that input it doesnt work.

    I guess now I'm being a pain, but japhy's spec *did* say make a function that takes any number of equal-length strings

    However I do believe in defensive programming, so I can see why you did that.

    Very interesting, and food for thought

    Yves

    $\="\n"; $,=","; print r("0000", "0000", "0000"); #outputs #000,000,000,000
      And what happens if you call r('0000')?

      Any number includes 1. :-)

Re: Re (tilly) 3: (Golf) Strings-to-Array
by demerphq (Chancellor) on Sep 01, 2001 at 05:37 UTC
    Hmm, and I reran it with literal params (I was using an @array) and I got that warnings as well. Interesting. OST. It follows from the fact @_ alises not copies, but still somehow surprising.

    And it is also very interesting to learn that '00' evals to true. Definitely *not* what I expected. I was thinking that it would fall under the evals to 0 rule, but now I see not. Thanx.

    On the other hand I tested a bunch of cases with 0's in them and I couldnt see how it affected the solution?

    Yves

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2015-07-07 23:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls