Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Wrong idioms

by educated_foo (Vicar)
on Mar 30, 2013 at 02:40 UTC ( #1026226=note: print w/replies, xml ) Need Help??

in reply to Wrong idioms

Why shouldn't I have a file named "0"?
Just as a side note... Regardless of correctness, "don't name your files with obnoxious names" is good advice if you want to avoid problems with others' software. "0" is kind of a corner case, but if you stick to alphanumerics, '-', and '_', you're less likely to have to fix other people's stuff. On the one hand, you're "technically correct" using all sorts of filenames. On the other hand, you're just asking for trouble.

Replies are listed 'Best First'.
Re^2: Wrong idioms
by vsespb (Chaplain) on Mar 30, 2013 at 09:39 UTC
    Hm, I think '-' can cause problems with getopts sometimes. Also - what other languages treat '0' as false?

      "Also - what other languages treat '0' as false?"

      It would be horrible if "0" were treated as true, given that the integer 0 is false and Perl silently converts between strings and numbers.

      What other languages? PHP does.

      package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
      Update: Post recomposed for better readability

      > Also - what other languages treat "0" as false?

    • JavaScript

      Num yes Str no

      >>> !! 0 false >>> !! "0" true

    • Python

      Num yes Str no

      >>> not not 0 False >>> not not "0" True

    • Ruby

      Num no Str no

      irb(main):002:0> !! 0 => true irb(main):003:0> !! "0" (irb):3: warning: string literal in condition => true

    • Perl

      Num yes Str yes

      DB<102> !! 0 => "" DB<103> !! "0" => ""

      Cheers Rolf

      ( addicted to the Perl Programming Language)

      Hm, I think '-' can cause problems with getopts sometimes.
      Oops! Starting filenames with '-' is just asking for trouble. Your life will be least painful if you start names with [a-z_], use only one '.', don't make them too long, and don't rely on case differences alone. If you find yourself wanting arbitrary filenames, either never pass them to other software, or consider using a database.
        I remember a colleague who used to create files named "-i" in directories he wanted to protect. That way, when you did "rm *", the file list expanded into "rm -i ..." and you got prompted for each file. I'm not recommending it, but he liked it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026226]
[Discipulus]: Ah! if so you must play with him not with us ;=)
[vrk]: Hope he gets better soon.
[Discipulus]: hdb sorry i profit; is known that a prime number is never a figurate one nor the sumattion of two adjacent figurates of the same order? like 3th triangular+3th tetrahedric
[Discipulus]: if known where i can read about the matter?
[choroba]: he's not really sick, we just got nobody to look after him today

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2017-04-27 07:55 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (501 votes). Check out past polls.