Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Re: japhygesis

by srawls (Friar)
on Jun 22, 2001 at 21:59 UTC ( #90803=note: print w/replies, xml ) Need Help??

in reply to Re: japhygesis
in thread japhygesis

Nice, too few people realise that you can just return a string to evaluate as zero, but still be true. I often return things like "0 but true" when I want the 0 value to be true; that way you can return 0 on errors too. A little trick I picked up was if you need to print the value, you can just use "0\0" It's 0 plus the null character, so it's true, but it only prints 0.

The 15 year old, freshman programmer,
Stephen Rawls

Replies are listed 'Best First'.
(tye)Re: japhygesis
by tye (Sage) on Jun 24, 2001 at 10:10 UTC
    #!/usr/bin/perl -w print 0+"0 but true",$/; print 0+"0\0",$/; __END__ Argument "0" isn't numeric in addition (+) at - line 3 0 0

    Not only does it generate warnings, but they are confusing warnings. I'd probably use "00" over "0\0" if you wanted something that printed out nicer. (:

            - tye (but my friends call me "Tye")

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://90803]
[Corion]: thezip: The Canary Islands - they have a constant climate
[Corion]: Maybe a bit too many old people, but for some do-nothing vacation for R&R exactly the right thing ;)=
[thezip]: That's awesome. I bet you feel totally rejuvenated and ready for the next thing.
[stevieb]: A couple of years ago I went to Curacao on a business trip which is a few parallels south of Canary Islands, but one thing I liked was it was 90 degrees at all times consistently. Much different experience than living in Canada :)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2017-02-23 17:07 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (349 votes). Check out past polls.