Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: read string (which is in binary) and make decision

by rjt (Deacon)
on Nov 17, 2012 at 13:32 UTC ( #1004311=note: print w/replies, xml ) Need Help??

in reply to read string (which is in binary) and make decision

I would favor something like this:

while (<DATA>) { my ($test, $_) = /^(.+?):\s?([01]+)$/ or do { warn "Line $. is invalid: $_"; next }; print "$test $_: ", /^ (0+|1+) $/x ? 'PASS' : /^(1+0+|0+1+)$/x ? 'CLEAN' : 'FAIL', "\n"; } __DATA__ test 1: 000000 test 2: 111111 test 3: 000011111 test 4: 1111111000 test 5:10001001110000011 ..... so on

This outputs:

test 1 000000: PASS test 2 111111: PASS test 3 000011111: CLEAN test 4 1111111000: CLEAN test 5 10001001110000011: FAIL Line 6 is invalid: ..... so on

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1004311]
[james28909]: yeah like wizard of oz lol. its just a joke though
[james28909]: i cannot understand how someone cant see that a cloud of gas that evolves into a solar system or galaxies. it just makes sense to me. everythign that has happened, had to have happened for anything on this planet to be.
[james28909]: /gas/gas and debris/
[james28909]: another thing, i used to be atheist. life experiences, personal evidence. and my own perception is the reason why i believe the things i do.
[erix]: and now you are agnostic?
[james28909]: arunbear, your picking bits of history to fit your own narrative. right now, humans are smarter than in any of those times.
[james28909]: in order for there to be a mutation, there has to be a universe with laws setup that even allow a mutation.

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (16)
As of 2017-12-15 14:50 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (433 votes). Check out past polls.