Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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
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

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. :-)

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 pondering the Monastery: (2)
As of 2014-09-21 02:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (166 votes), past polls